src/video/windows/SDL_windowswindow.c
changeset 5483 ccec742c9b7d
parent 5478 6b65ff3cee62
child 5494 78b351c52f53
equal deleted inserted replaced
5482:2c0477323626 5483:ccec742c9b7d
   343 WIN_SetWindowPosition(_THIS, SDL_Window * window)
   343 WIN_SetWindowPosition(_THIS, SDL_Window * window)
   344 {
   344 {
   345     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
   345     SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
   346     HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
   346     HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
   347     RECT rect;
   347     RECT rect;
   348     SDL_Rect bounds;
       
   349     DWORD style;
   348     DWORD style;
   350     HWND top;
   349     HWND top;
   351     BOOL menu;
   350     BOOL menu;
   352     int x, y;
   351     int x, y;
   353     int w, h;
   352     int w, h;
   369     menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
   368     menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
   370 #endif
   369 #endif
   371     AdjustWindowRectEx(&rect, style, menu, 0);
   370     AdjustWindowRectEx(&rect, style, menu, 0);
   372     w = (rect.right - rect.left);
   371     w = (rect.right - rect.left);
   373     h = (rect.bottom - rect.top);
   372     h = (rect.bottom - rect.top);
   374     x = window->x + rect.left;
   373 
   375     y = window->y + rect.top;
   374     WIN_GetDisplayBounds(_this, display, &bounds);
       
   375     if (SDL_WINDOWPOS_ISCENTERED(window->x)) {
       
   376         x = bounds.x + (bounds.w - w) / 2;
       
   377     } else {
       
   378         x = window->x + rect.left;
       
   379     }
       
   380     if (SDL_WINDOWPOS_ISCENTERED(window->y)) {
       
   381         y = bounds.y + (bounds.h - h) / 2;
       
   382     } else {
       
   383         y = window->y + rect.top;
       
   384     }
   376 
   385 
   377     SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
   386     SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE));
   378 }
   387 }
   379 
   388 
   380 void
   389 void