Fixed bug 3058 - Slight mistake in GetWindowStyle in SDL_windowswindow.c
authorSam Lantinga <slouken@libsdl.org>
Sat, 12 Aug 2017 16:44:00 -0700
changeset 112514de70b7f43af
parent 11250 c9b15b9a04e3
child 11252 1017272c981f
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.
src/video/windows/SDL_windowswindow.c
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Sat Aug 12 16:02:33 2017 -0700
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Sat Aug 12 16:44:00 2017 -0700
     1.3 @@ -65,12 +65,10 @@
     1.4  
     1.5      if (window->flags & SDL_WINDOW_FULLSCREEN) {
     1.6          style |= STYLE_FULLSCREEN;
     1.7 +    } else if (window->flags & SDL_WINDOW_BORDERLESS) {
     1.8 +        style |= STYLE_BORDERLESS;
     1.9      } else {
    1.10 -        if (window->flags & SDL_WINDOW_BORDERLESS) {
    1.11 -            style |= STYLE_BORDERLESS;
    1.12 -        } else {
    1.13 -            style |= STYLE_NORMAL;
    1.14 -        }
    1.15 +        style |= STYLE_NORMAL;
    1.16          if (window->flags & SDL_WINDOW_RESIZABLE) {
    1.17              style |= STYLE_RESIZABLE;
    1.18          }
    1.19 @@ -513,15 +511,11 @@
    1.20  {
    1.21      SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    1.22      HWND hwnd = data->hwnd;
    1.23 -    DWORD style = GetWindowLong(hwnd, GWL_STYLE);
    1.24 +    DWORD style;
    1.25  
    1.26 -    if (bordered) {
    1.27 -        style &= ~STYLE_BORDERLESS;
    1.28 -        style |= STYLE_NORMAL;
    1.29 -    } else {
    1.30 -        style &= ~STYLE_NORMAL;
    1.31 -        style |= STYLE_BORDERLESS;
    1.32 -    }
    1.33 +    style = GetWindowLong(hwnd, GWL_STYLE);
    1.34 +    style &= ~STYLE_MASK;
    1.35 +    style |= GetWindowStyle(window);
    1.36  
    1.37      data->in_border_change = SDL_TRUE;
    1.38      SetWindowLong(hwnd, GWL_STYLE, style);
    1.39 @@ -534,13 +528,11 @@
    1.40  {
    1.41      SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    1.42      HWND hwnd = data->hwnd;
    1.43 -    DWORD style = GetWindowLong(hwnd, GWL_STYLE);
    1.44 +    DWORD style;
    1.45  
    1.46 -    if (resizable) {
    1.47 -        style |= STYLE_RESIZABLE;
    1.48 -    } else {
    1.49 -        style &= ~STYLE_RESIZABLE;
    1.50 -    }
    1.51 +    style = GetWindowLong(hwnd, GWL_STYLE);
    1.52 +    style &= ~STYLE_MASK;
    1.53 +    style |= GetWindowStyle(window);
    1.54  
    1.55      SetWindowLong(hwnd, GWL_STYLE, style);
    1.56  }