SetWindowMinimumSize Windows implementation
authorstopiccot
Mon, 19 Nov 2012 00:39:19 +0300
changeset 6682a0cbe4e5a07a
parent 6681 5a0396a933b5
child 6683 b1124b32b07d
SetWindowMinimumSize Windows implementation
src/video/windows/SDL_windowsevents.c
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Sun Nov 18 15:45:12 2012 +0300
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Mon Nov 19 00:39:19 2012 +0300
     1.3 @@ -426,16 +426,13 @@
     1.4              RECT size;
     1.5              int x, y;
     1.6              int w, h;
     1.7 +            int min_w, min_h;
     1.8              int style;
     1.9              BOOL menu;
    1.10  
    1.11              /* If we allow resizing, let the resize happen naturally */
    1.12 -            if(SDL_IsShapedWindow(data->window))
    1.13 +            if (SDL_IsShapedWindow(data->window))
    1.14                  Win32_ResizeWindowShape(data->window);
    1.15 -            if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
    1.16 -                returnCode = 0;
    1.17 -                break;
    1.18 -            }
    1.19  
    1.20              /* Get the current position of our window */
    1.21              GetWindowRect(hwnd, &size);
    1.22 @@ -444,12 +441,18 @@
    1.23  
    1.24              /* Calculate current size of our window */
    1.25              SDL_GetWindowSize(data->window, &w, &h);
    1.26 +            SDL_GetWindowMinimumSize(data->window, &min_w, &min_h);
    1.27 +
    1.28 +            /* Store in min_w and min_h difference between current size and minimal 
    1.29 +               size so we don't need to call AdjustWindowRectEx twice */
    1.30 +            min_w -= w;
    1.31 +            min_h -= h;
    1.32 +
    1.33              size.top = 0;
    1.34              size.left = 0;
    1.35              size.bottom = h;
    1.36              size.right = w;
    1.37  
    1.38 -
    1.39              style = GetWindowLong(hwnd, GWL_STYLE);
    1.40              /* DJM - according to the docs for GetMenu(), the
    1.41                 return value is undefined if hwnd is a child window.
    1.42 @@ -463,14 +466,19 @@
    1.43  
    1.44              /* Fix our size to the current size */
    1.45              info = (MINMAXINFO *) lParam;
    1.46 -            info->ptMaxSize.x = w;
    1.47 -            info->ptMaxSize.y = h;
    1.48 -            info->ptMaxPosition.x = x;
    1.49 -            info->ptMaxPosition.y = y;
    1.50 -            info->ptMinTrackSize.x = w;
    1.51 -            info->ptMinTrackSize.y = h;
    1.52 -            info->ptMaxTrackSize.x = w;
    1.53 -            info->ptMaxTrackSize.y = h;
    1.54 +            if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) {
    1.55 +                info->ptMinTrackSize.x = w + min_w;
    1.56 +                info->ptMinTrackSize.y = h + min_h;
    1.57 +            } else {
    1.58 +                info->ptMaxSize.x = w;
    1.59 +                info->ptMaxSize.y = h;
    1.60 +                info->ptMaxPosition.x = x;
    1.61 +                info->ptMaxPosition.y = y;
    1.62 +                info->ptMinTrackSize.x = w;
    1.63 +                info->ptMinTrackSize.y = h;
    1.64 +                info->ptMaxTrackSize.x = w;
    1.65 +                info->ptMaxTrackSize.y = h;
    1.66 +            }
    1.67          }
    1.68          returnCode = 0;
    1.69          break;