Fixed bug where changing the window border would change the window size on Windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 2aa1814..e08d029 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -665,7 +665,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
style = GetWindowLong(hwnd, GWL_STYLE);
/* DJM - according to the docs for GetMenu(), the
return value is undefined if hwnd is a child window.
- Aparently it's too difficult for MS to check
+ Apparently it's too difficult for MS to check
inside their function, so I have to do it here.
*/
menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL);
@@ -702,6 +702,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
RECT rect;
int x, y;
int w, h;
+
+ if (data->in_border_change) {
+ break;
+ }
if (!GetClientRect(hwnd, &rect) || IsRectEmpty(&rect)) {
break;
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 38e97a7..8ff85a3 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -108,9 +108,9 @@ WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags)
x = window->x + rect.left;
y = window->y + rect.top;
- data->expected_resize = TRUE;
- SetWindowPos(hwnd, top, x, y, w, h, flags);
- data->expected_resize = FALSE;
+ data->expected_resize = SDL_TRUE;
+ SetWindowPos( hwnd, top, x, y, w, h, flags );
+ data->expected_resize = SDL_FALSE;
}
static int
@@ -470,9 +470,9 @@ WIN_MaximizeWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
HWND hwnd = data->hwnd;
- data->expected_resize = TRUE;
+ data->expected_resize = SDL_TRUE;
ShowWindow(hwnd, SW_MAXIMIZE);
- data->expected_resize = FALSE;
+ data->expected_resize = SDL_FALSE;
}
void
@@ -485,7 +485,8 @@ WIN_MinimizeWindow(_THIS, SDL_Window * window)
void
WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
{
- HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+ SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+ HWND hwnd = data->hwnd;
DWORD style = GetWindowLong(hwnd, GWL_STYLE);
if (bordered) {
@@ -496,8 +497,10 @@ WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
style |= STYLE_BORDERLESS;
}
- SetWindowLong(hwnd, GWL_STYLE, style);
- WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOREPOSITION | SWP_NOZORDER |SWP_NOACTIVATE | SWP_NOSENDCHANGING);
+ data->in_border_change = SDL_TRUE;
+ SetWindowLong( hwnd, GWL_STYLE, style );
+ WIN_SetWindowPositionInternal(_this, window, SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOACTIVATE);
+ data->in_border_change = SDL_FALSE;
}
void
@@ -505,9 +508,9 @@ WIN_RestoreWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
HWND hwnd = data->hwnd;
- data->expected_resize = TRUE;
+ data->expected_resize = SDL_TRUE;
ShowWindow(hwnd, SW_RESTORE);
- data->expected_resize = FALSE;
+ data->expected_resize = SDL_FALSE;
}
void
@@ -553,9 +556,9 @@ WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display,
y = window->windowed.y + rect.top;
}
SetWindowLong(hwnd, GWL_STYLE, style);
- data->expected_resize = TRUE;
+ data->expected_resize = SDL_TRUE;
SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS | SWP_NOACTIVATE);
- data->expected_resize = FALSE;
+ data->expected_resize = SDL_FALSE;
}
int
diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h
index c428887..0da8682 100644
--- a/src/video/windows/SDL_windowswindow.h
+++ b/src/video/windows/SDL_windowswindow.h
@@ -37,7 +37,8 @@ typedef struct
WNDPROC wndproc;
SDL_bool created;
WPARAM mouse_button_flags;
- BOOL expected_resize;
+ SDL_bool expected_resize;
+ SDL_bool in_border_change;
SDL_bool in_title_click;
SDL_bool in_modal_loop;
struct SDL_VideoData *videodata;