Fixed bug 2067 - Window size limit calculation issue when exiting fullscreen on Windows Also fixed minimize and maximize state detection for 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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
old mode 100644
new mode 100755
index 613bf4c..66aa255
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -621,9 +621,9 @@ SDL_GetIndexOfDisplay(SDL_VideoDisplay *display)
void *
SDL_GetDisplayDriverData( int displayIndex )
{
- CHECK_DISPLAY_INDEX( displayIndex, NULL );
+ CHECK_DISPLAY_INDEX( displayIndex, NULL );
- return _this->displays[displayIndex].driverdata;
+ return _this->displays[displayIndex].driverdata;
}
const char *
@@ -1627,8 +1627,29 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h)
return;
}
+ /* Make sure we don't exceed any window size limits */
+ if (window->min_w && w < window->min_w)
+ {
+ w = window->min_w;
+ }
+ if (window->max_w && w > window->max_w)
+ {
+ w = window->max_w;
+ }
+ if (window->min_h && h < window->min_h)
+ {
+ h = window->min_h;
+ }
+ if (window->max_h && h > window->max_h)
+ {
+ h = window->max_h;
+ }
+
/* FIXME: Should this change fullscreen modes? */
- if (!(window->flags & SDL_WINDOW_FULLSCREEN)) {
+ if (window->flags & SDL_WINDOW_FULLSCREEN) {
+ window->windowed.w = w;
+ window->windowed.h = h;
+ } else {
window->w = w;
window->h = h;
if (_this->SetWindowSize) {
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
old mode 100644
new mode 100755
index ec278d2..6a0dd44
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -312,15 +312,15 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
#ifdef WMMSG_DEBUG
- {
- char message[1024];
- if (msg > MAX_WMMSG) {
- SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%X, 0x%X\n", hwnd, msg, wParam, lParam);
- } else {
- SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%X, 0x%X\n", hwnd, wmtab[msg], wParam, lParam);
- }
- OutputDebugStringA(message);
- }
+ {
+ char message[1024];
+ if (msg > MAX_WMMSG) {
+ SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%X, 0x%X\n", hwnd, msg, wParam, lParam);
+ } else {
+ SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%X, 0x%X\n", hwnd, wmtab[msg], wParam, lParam);
+ }
+ OutputDebugStringA(message);
+ }
#endif /* WMMSG_DEBUG */
if (IME_HandleMessage(hwnd, msg, wParam, &lParam, data->videodata))
@@ -348,12 +348,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
SHORT keyState;
SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_SHOWN, 0, 0);
- SDL_SendWindowEvent(data->window,
- SDL_WINDOWEVENT_RESTORED, 0, 0);
- if (IsZoomed(hwnd)) {
- SDL_SendWindowEvent(data->window,
- SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
- }
if (SDL_GetKeyboardFocus() != data->window) {
SDL_SetKeyboardFocus(data->window);
}
@@ -400,10 +394,6 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (SDL_GetKeyboardFocus() == data->window) {
SDL_SetKeyboardFocus(NULL);
}
- if (minimized) {
- SDL_SendWindowEvent(data->window,
- SDL_WINDOWEVENT_MINIMIZED, 0, 0);
- }
}
}
returnCode = 0;
@@ -596,10 +586,14 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
BOOL menu;
BOOL constrain_max_size;
- /* If we allow resizing, let the resize happen naturally */
if (SDL_IsShapedWindow(data->window))
Win32_ResizeWindowShape(data->window);
+ /* If this is an expected size change, allow it */
+ if (data->expected_resize) {
+ break;
+ }
+
/* Get the current position of our window */
GetWindowRect(hwnd, &size);
x = size.left;
@@ -693,6 +687,26 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
break;
+ case WM_SIZE:
+ {
+ switch (wParam)
+ {
+ case SIZE_MAXIMIZED:
+ SDL_SendWindowEvent(data->window,
+ SDL_WINDOWEVENT_MAXIMIZED, 0, 0);
+ break;
+ case SIZE_MINIMIZED:
+ SDL_SendWindowEvent(data->window,
+ SDL_WINDOWEVENT_MINIMIZED, 0, 0);
+ break;
+ default:
+ SDL_SendWindowEvent(data->window,
+ SDL_WINDOWEVENT_RESTORED, 0, 0);
+ break;
+ }
+ }
+ break;
+
case WM_SETCURSOR:
{
Uint16 hittest;
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
old mode 100644
new mode 100755
index 1a6849d..c7055e4
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -79,7 +79,8 @@ GetWindowStyle(SDL_Window * window)
static void
WIN_SetWindowPositionInternal(_THIS, SDL_Window * window, UINT flags)
{
- HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+ SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+ HWND hwnd = data->hwnd;
RECT rect;
DWORD style;
HWND top;
@@ -105,7 +106,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;
}
static int
@@ -410,8 +413,11 @@ WIN_RaiseWindow(_THIS, SDL_Window * window)
void
WIN_MaximizeWindow(_THIS, SDL_Window * window)
{
- HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
+ SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+ HWND hwnd = data->hwnd;
+ data->expected_resize = TRUE;
ShowWindow(hwnd, SW_MAXIMIZE);
+ data->expected_resize = FALSE;
}
void
@@ -442,9 +448,11 @@ WIN_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
void
WIN_RestoreWindow(_THIS, SDL_Window * window)
{
- HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
-
+ SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
+ HWND hwnd = data->hwnd;
+ data->expected_resize = TRUE;
ShowWindow(hwnd, SW_RESTORE);
+ data->expected_resize = FALSE;
}
void
@@ -490,7 +498,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;
SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS);
+ data->expected_resize = FALSE;
}
int
diff --git a/src/video/windows/SDL_windowswindow.h b/src/video/windows/SDL_windowswindow.h
old mode 100644
new mode 100755
index e85c201..a4c035f
--- a/src/video/windows/SDL_windowswindow.h
+++ b/src/video/windows/SDL_windowswindow.h
@@ -33,6 +33,7 @@ typedef struct
WNDPROC wndproc;
SDL_bool created;
WPARAM mouse_button_flags;
+ BOOL expected_resize;
struct SDL_VideoData *videodata;
} SDL_WindowData;