Fixed bug 3058 - Slight mistake in GetWindowStyle in SDL_windowswindow.c

Coriiander

There's a slight mistake in the function "GetWindowStyle" found in file "SDL_windowswindow.c".

When a window is marked to be resizable, the resizable style is being added regardless of whether the window has a border or not. While for some arcane, hidden semantics this can be ok, it's still inconsistent in this case.
This commit is contained in:
Sam Lantinga 2017-08-12 16:44:00 -07:00
parent e3f3a757f3
commit 45cec28bc4
1 changed files with 11 additions and 19 deletions

View File

@ -65,12 +65,10 @@ GetWindowStyle(SDL_Window * window)
if (window->flags & SDL_WINDOW_FULLSCREEN) { if (window->flags & SDL_WINDOW_FULLSCREEN) {
style |= STYLE_FULLSCREEN; style |= STYLE_FULLSCREEN;
} else { } else if (window->flags & SDL_WINDOW_BORDERLESS) {
if (window->flags & SDL_WINDOW_BORDERLESS) {
style |= STYLE_BORDERLESS; style |= STYLE_BORDERLESS;
} else { } else {
style |= STYLE_NORMAL; style |= STYLE_NORMAL;
}
if (window->flags & SDL_WINDOW_RESIZABLE) { if (window->flags & SDL_WINDOW_RESIZABLE) {
style |= STYLE_RESIZABLE; style |= STYLE_RESIZABLE;
} }
@ -513,15 +511,11 @@ WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
{ {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
HWND hwnd = data->hwnd; HWND hwnd = data->hwnd;
DWORD style = GetWindowLong(hwnd, GWL_STYLE); DWORD style;
if (bordered) { style = GetWindowLong(hwnd, GWL_STYLE);
style &= ~STYLE_BORDERLESS; style &= ~STYLE_MASK;
style |= STYLE_NORMAL; style |= GetWindowStyle(window);
} else {
style &= ~STYLE_NORMAL;
style |= STYLE_BORDERLESS;
}
data->in_border_change = SDL_TRUE; data->in_border_change = SDL_TRUE;
SetWindowLong(hwnd, GWL_STYLE, style); SetWindowLong(hwnd, GWL_STYLE, style);
@ -534,13 +528,11 @@ WIN_SetWindowResizable(_THIS, SDL_Window * window, SDL_bool resizable)
{ {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
HWND hwnd = data->hwnd; HWND hwnd = data->hwnd;
DWORD style = GetWindowLong(hwnd, GWL_STYLE); DWORD style;
if (resizable) { style = GetWindowLong(hwnd, GWL_STYLE);
style |= STYLE_RESIZABLE; style &= ~STYLE_MASK;
} else { style |= GetWindowStyle(window);
style &= ~STYLE_RESIZABLE;
}
SetWindowLong(hwnd, GWL_STYLE, style); SetWindowLong(hwnd, GWL_STYLE, style);
} }