Fixed bug where changing the window border would change the window size on Windows.
authorSam Lantinga <slouken@libsdl.org>
Wed, 04 Jun 2014 10:56:30 -0700
changeset 881713003597b6c4
parent 8816 7e2f5d693149
child 8818 3b075068bf2e
Fixed bug where changing the window border would change the window size on Windows.
src/video/windows/SDL_windowsevents.c
src/video/windows/SDL_windowswindow.c
src/video/windows/SDL_windowswindow.h
     1.1 --- a/src/video/windows/SDL_windowsevents.c	Wed Jun 04 10:56:17 2014 -0700
     1.2 +++ b/src/video/windows/SDL_windowsevents.c	Wed Jun 04 10:56:30 2014 -0700
     1.3 @@ -665,7 +665,7 @@
     1.4              style = GetWindowLong(hwnd, GWL_STYLE);
     1.5              /* DJM - according to the docs for GetMenu(), the
     1.6                 return value is undefined if hwnd is a child window.
     1.7 -               Aparently it's too difficult for MS to check
     1.8 +               Apparently it's too difficult for MS to check
     1.9                 inside their function, so I have to do it here.
    1.10               */
    1.11              menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
    1.12 @@ -702,6 +702,10 @@
    1.13              RECT rect;
    1.14              int x, y;
    1.15              int w, h;
    1.16 +            
    1.17 +            if (data->in_border_change) {
    1.18 +                break;
    1.19 +            }
    1.20  
    1.21              if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
    1.22                  break;
     2.1 --- a/src/video/windows/SDL_windowswindow.c	Wed Jun 04 10:56:17 2014 -0700
     2.2 +++ b/src/video/windows/SDL_windowswindow.c	Wed Jun 04 10:56:30 2014 -0700
     2.3 @@ -108,9 +108,9 @@
     2.4      x = window->x + rect.left;
     2.5      y = window->y + rect.top;
     2.6  
     2.7 -    data->expected_resize = TRUE;
     2.8 -    SetWindowPos(hwnd, top, x, y, w, h, flags);
     2.9 -    data->expected_resize = FALSE;
    2.10 +    data->expected_resize = SDL_TRUE;
    2.11 +    SetWindowPos( hwnd, top, x, y, w, h, flags );
    2.12 +    data->expected_resize = SDL_FALSE;
    2.13  }
    2.14  
    2.15  static int
    2.16 @@ -470,9 +470,9 @@
    2.17  {
    2.18      SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    2.19      HWND hwnd = data->hwnd;
    2.20 -    data->expected_resize = TRUE;
    2.21 +    data->expected_resize = SDL_TRUE;
    2.22      ShowWindow(hwnd, SW_MAXIMIZE);
    2.23 -    data->expected_resize = FALSE;
    2.24 +    data->expected_resize = SDL_FALSE;
    2.25  }
    2.26  
    2.27  void
    2.28 @@ -485,7 +485,8 @@
    2.29  void
    2.30  WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
    2.31  {
    2.32 -    HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
    2.33 +    SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    2.34 +    HWND hwnd = data->hwnd;
    2.35      DWORD style = GetWindowLong(hwnd, GWL_STYLE);
    2.36  
    2.37      if (bordered) {
    2.38 @@ -496,8 +497,10 @@
    2.39          style |= STYLE_BORDERLESS;
    2.40      }
    2.41  
    2.42 -    SetWindowLong(hwnd, GWL_STYLE, style);
    2.43 -    WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOREPOSITION | SWP_NOZORDER |SWP_NOACTIVATE | SWP_NOSENDCHANGING);
    2.44 +    data->in_border_change = SDL_TRUE;
    2.45 +    SetWindowLong( hwnd, GWL_STYLE, style );
    2.46 +    WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE);
    2.47 +    data->in_border_change = SDL_FALSE;
    2.48  }
    2.49  
    2.50  void
    2.51 @@ -505,9 +508,9 @@
    2.52  {
    2.53      SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    2.54      HWND hwnd = data->hwnd;
    2.55 -    data->expected_resize = TRUE;
    2.56 +    data->expected_resize = SDL_TRUE;
    2.57      ShowWindow(hwnd, SW_RESTORE);
    2.58 -    data->expected_resize = FALSE;
    2.59 +    data->expected_resize = SDL_FALSE;
    2.60  }
    2.61  
    2.62  void
    2.63 @@ -553,9 +556,9 @@
    2.64          y = window->windowed.y + rect.top;
    2.65      }
    2.66      SetWindowLong(hwnd, GWL_STYLE, style);
    2.67 -    data->expected_resize = TRUE;
    2.68 +    data->expected_resize = SDL_TRUE;
    2.69      SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS | SWP_NOACTIVATE);
    2.70 -    data->expected_resize = FALSE;
    2.71 +    data->expected_resize = SDL_FALSE;
    2.72  }
    2.73  
    2.74  int
     3.1 --- a/src/video/windows/SDL_windowswindow.h	Wed Jun 04 10:56:17 2014 -0700
     3.2 +++ b/src/video/windows/SDL_windowswindow.h	Wed Jun 04 10:56:30 2014 -0700
     3.3 @@ -37,7 +37,8 @@
     3.4      WNDPROC wndproc;
     3.5      SDL_bool created;
     3.6      WPARAM mouse_button_flags;
     3.7 -    BOOL expected_resize;
     3.8 +    SDL_bool expected_resize;
     3.9 +    SDL_bool in_border_change;
    3.10      SDL_bool in_title_click;
    3.11      SDL_bool in_modal_loop;
    3.12      struct SDL_VideoData *videodata;