Commit 9807496e authored by Sam Lantinga's avatar Sam Lantinga

Fixed fullscreen window position

Fixed position calculation for centered windows
parent 9fad608a
...@@ -186,7 +186,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -186,7 +186,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
{ {
SDL_VideoDisplay *display = window->display; SDL_VideoDisplay *display = window->display;
HWND hwnd; HWND hwnd;
HWND top;
RECT rect; RECT rect;
SDL_Rect bounds; SDL_Rect bounds;
DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN); DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
...@@ -204,11 +203,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -204,11 +203,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
} }
/* Figure out what the window area will be */ /* Figure out what the window area will be */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
top = HWND_TOPMOST;
} else {
top = HWND_NOTOPMOST;
}
rect.left = 0; rect.left = 0;
rect.top = 0; rect.top = 0;
rect.right = window->w; rect.right = window->w;
...@@ -218,9 +212,17 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -218,9 +212,17 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
h = (rect.bottom - rect.top); h = (rect.bottom - rect.top);
WIN_GetDisplayBounds(_this, display, &bounds); WIN_GetDisplayBounds(_this, display, &bounds);
if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* The bounds when this window is visible is the fullscreen mode */
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
bounds.w = fullscreen_mode.w;
bounds.h = fullscreen_mode.h;
}
}
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) { || window->x == SDL_WINDOWPOS_CENTERED) {
x = bounds.x + (bounds.w - window->w) / 2; x = bounds.x + (bounds.w - w) / 2;
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) { } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
if (bounds.x == 0) { if (bounds.x == 0) {
x = CW_USEDEFAULT; x = CW_USEDEFAULT;
...@@ -232,7 +234,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) ...@@ -232,7 +234,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window)
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) { || window->y == SDL_WINDOWPOS_CENTERED) {
y = bounds.y + (bounds.h - window->h) / 2; y = bounds.y + (bounds.h - h) / 2;
} else if (window->x == SDL_WINDOWPOS_UNDEFINED) { } else if (window->x == SDL_WINDOWPOS_UNDEFINED) {
if (bounds.x == 0) { if (bounds.x == 0) {
y = CW_USEDEFAULT; y = CW_USEDEFAULT;
...@@ -389,6 +391,7 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) ...@@ -389,6 +391,7 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
HWND top; HWND top;
BOOL menu; BOOL menu;
int x, y; int x, y;
int w, h;
/* Figure out what the window area will be */ /* Figure out what the window area will be */
if (window->flags & SDL_WINDOW_FULLSCREEN) { if (window->flags & SDL_WINDOW_FULLSCREEN) {
...@@ -407,17 +410,27 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) ...@@ -407,17 +410,27 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window)
menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
#endif #endif
AdjustWindowRectEx(&rect, style, menu, 0); AdjustWindowRectEx(&rect, style, menu, 0);
w = (rect.right - rect.left);
h = (rect.bottom - rect.top);
WIN_GetDisplayBounds(_this, display, &bounds); WIN_GetDisplayBounds(_this, display, &bounds);
if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* The bounds when this window is visible is the fullscreen mode */
SDL_DisplayMode fullscreen_mode;
if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) {
bounds.w = fullscreen_mode.w;
bounds.h = fullscreen_mode.h;
}
}
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->x == SDL_WINDOWPOS_CENTERED) { || window->x == SDL_WINDOWPOS_CENTERED) {
x = bounds.x + (bounds.w - window->w) / 2; x = bounds.x + (bounds.w - w) / 2;
} else { } else {
x = bounds.x + window->x + rect.left; x = bounds.x + window->x + rect.left;
} }
if ((window->flags & SDL_WINDOW_FULLSCREEN) if ((window->flags & SDL_WINDOW_FULLSCREEN)
|| window->y == SDL_WINDOWPOS_CENTERED) { || window->y == SDL_WINDOWPOS_CENTERED) {
y = bounds.y + (bounds.h - window->h) / 2; y = bounds.y + (bounds.h - h) / 2;
} else { } else {
y = bounds.y + window->y + rect.top; y = bounds.y + window->y + rect.top;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment