Fixed window size when leaving fullscreen mode (thanks Eric!)
authorSam Lantinga <slouken@libsdl.org>
Sat, 09 Sep 2017 09:31:12 -0700
changeset 11481490c36e2945d
parent 11480 e7a79b236dc0
child 11482 05aa6d232dca
Fixed window size when leaving fullscreen mode (thanks Eric!)
src/video/windows/SDL_windowswindow.c
     1.1 --- a/src/video/windows/SDL_windowswindow.c	Sat Sep 09 08:36:37 2017 -0700
     1.2 +++ b/src/video/windows/SDL_windowswindow.c	Sat Sep 09 09:31:12 2017 -0700
     1.3 @@ -81,33 +81,33 @@
     1.4  }
     1.5  
     1.6  static void
     1.7 -WIN_AdjustWindowRectWithStyle( SDL_Window * window, DWORD style, BOOL menu, int * x, int * y, int * width, int * height )
     1.8 +WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL menu, int *x, int *y, int *width, int *height, SDL_bool use_current)
     1.9  {
    1.10      RECT rect;
    1.11  
    1.12      rect.left = 0;
    1.13      rect.top = 0;
    1.14 -    rect.right = window->w;
    1.15 -    rect.bottom = window->h;
    1.16 -    AdjustWindowRectEx( &rect, style, menu, 0 );
    1.17 +    rect.right = (use_current ? window->w : window->windowed.w);
    1.18 +    rect.bottom = (use_current ? window->h : window->windowed.h);
    1.19 +    AdjustWindowRectEx(&rect, style, menu, 0);
    1.20  
    1.21 -    *x = window->x + rect.left;
    1.22 -    *y = window->y + rect.top;
    1.23 +    *x = (use_current ? window->x : window->windowed.x) + rect.left;
    1.24 +    *y = (use_current ? window->y : window->windowed.y) + rect.top;
    1.25      *width = (rect.right - rect.left);
    1.26      *height = (rect.bottom - rect.top);
    1.27  }
    1.28  
    1.29  static void
    1.30 -WIN_AdjustWindowRect( SDL_Window * window, int * x, int * y, int * width, int * height )
    1.31 +WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_bool use_current)
    1.32  {
    1.33      SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    1.34      HWND hwnd = data->hwnd;
    1.35      DWORD style;
    1.36      BOOL menu;
    1.37  
    1.38 -    style = GetWindowLong( hwnd, GWL_STYLE );
    1.39 -    menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu( hwnd ) != NULL);
    1.40 -    WIN_AdjustWindowRectWithStyle( window, style, menu, x, y, width, height );
    1.41 +    style = GetWindowLong(hwnd, GWL_STYLE);
    1.42 +    menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
    1.43 +    WIN_AdjustWindowRectWithStyle(window, style, menu, x, y, width, height, use_current);
    1.44  }
    1.45  
    1.46  static void
    1.47 @@ -126,7 +126,7 @@
    1.48          top = HWND_NOTOPMOST;
    1.49      }
    1.50  
    1.51 -    WIN_AdjustWindowRect( window, &x, &y, &w, &h );    
    1.52 +    WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_TRUE);    
    1.53  
    1.54      data->expected_resize = SDL_TRUE;
    1.55      SetWindowPos(hwnd, top, x, y, w, h, flags);
    1.56 @@ -192,7 +192,7 @@
    1.57                  int w, h;
    1.58  
    1.59                  /* Figure out what the window area will be */
    1.60 -                WIN_AdjustWindowRect( window, &x, &y, &w, &h );
    1.61 +                WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_TRUE);
    1.62                  SetWindowPos(hwnd, HWND_NOTOPMOST, x, y, w, h, SWP_NOCOPYBITS | SWP_NOZORDER | SWP_NOACTIVATE);
    1.63              } else {
    1.64                  window->w = w;
    1.65 @@ -287,7 +287,7 @@
    1.66      style |= GetWindowStyle(window);
    1.67  
    1.68      /* Figure out what the window area will be */
    1.69 -    WIN_AdjustWindowRectWithStyle( window, style, FALSE, &x, &y, &w, &h );
    1.70 +    WIN_AdjustWindowRectWithStyle(window, style, FALSE, &x, &y, &w, &h, SDL_TRUE);
    1.71  
    1.72      hwnd =
    1.73          CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, parent, NULL,
    1.74 @@ -594,7 +594,7 @@
    1.75              data->windowed_mode_was_maximized = SDL_FALSE;
    1.76          }
    1.77  
    1.78 -        WIN_AdjustWindowRect( window, &x, &y, &w, &h );
    1.79 +        WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_FALSE);
    1.80      }
    1.81      SetWindowLong(hwnd, GWL_STYLE, style);
    1.82      data->expected_resize = SDL_TRUE;