Fixed min/max window size handling for borderless resizable windows
authorSam Lantinga <slouken@libsdl.org>
Thu, 08 Feb 2018 18:07:14 -0800
changeset 118579e521a040926
parent 11856 713fd3ac3c9b
child 11858 323976dcc3d1
Fixed min/max window size handling for borderless resizable windows
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Thu Feb 08 17:07:47 2018 +0300
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Thu Feb 08 18:07:14 2018 -0800
     1.3 @@ -697,8 +697,6 @@
     1.4              int w, h;
     1.5              int min_w, min_h;
     1.6              int max_w, max_h;
     1.7 -            int style;
     1.8 -            BOOL menu;
     1.9              BOOL constrain_max_size;
    1.10  
    1.11              if (SDL_IsShapedWindow(data->window))
    1.12 @@ -731,21 +729,23 @@
    1.13                  constrain_max_size = FALSE;
    1.14              }
    1.15  
    1.16 -            size.top = 0;
    1.17 -            size.left = 0;
    1.18 -            size.bottom = h;
    1.19 -            size.right = w;
    1.20 +            if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS)) {
    1.21 +                LONG style = GetWindowLong(hwnd, GWL_STYLE);
    1.22 +                /* DJM - according to the docs for GetMenu(), the
    1.23 +                   return value is undefined if hwnd is a child window.
    1.24 +                   Apparently it's too difficult for MS to check
    1.25 +                   inside their function, so I have to do it here.
    1.26 +                 */
    1.27 +                BOOL menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
    1.28 +                size.top = 0;
    1.29 +                size.left = 0;
    1.30 +                size.bottom = h;
    1.31 +                size.right = w;
    1.32  
    1.33 -            style = GetWindowLong(hwnd, GWL_STYLE);
    1.34 -            /* DJM - according to the docs for GetMenu(), the
    1.35 -               return value is undefined if hwnd is a child window.
    1.36 -               Apparently it's too difficult for MS to check
    1.37 -               inside their function, so I have to do it here.
    1.38 -             */
    1.39 -            menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
    1.40 -            AdjustWindowRectEx(&size, style, menu, 0);
    1.41 -            w = size.right - size.left;
    1.42 -            h = size.bottom - size.top;
    1.43 +                AdjustWindowRectEx(&size, style, menu, 0);
    1.44 +                w = size.right - size.left;
    1.45 +                h = size.bottom - size.top;
    1.46 +            }
    1.47  
    1.48              /* Fix our size to the current size */
    1.49              info = (MINMAXINFO *) lParam;