Skip to content

Commit 30f0aeb

Browse files
StrangePanKontrabant
authored andcommitted
Check NSWindow::isVisible before sending SDL_WINDOWEVENT_RESTORED during Cocoa_WindowListener::windowDidResize
1 parent 49b6bb5 commit 30f0aeb

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/video/cocoa/SDL_cocoawindow.m

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,21 +1199,27 @@ - (void)windowDidResize:(NSNotification *)aNotification
11991199

12001200
ScheduleContextUpdates(_data);
12011201

1202-
/* isZoomed always returns true if the window is not resizable
1203-
* and fullscreen windows are considered zoomed.
1202+
/* The OS can resize the window automatically if the display density
1203+
* changes while the window is miniaturized or hidden.
12041204
*/
1205-
if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed] &&
1206-
!(window->flags & SDL_WINDOW_FULLSCREEN) && ![self isInFullscreenSpace]) {
1207-
zoomed = YES;
1208-
} else {
1209-
zoomed = NO;
1210-
}
1211-
if (!zoomed) {
1212-
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0);
1213-
} else {
1214-
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0);
1215-
if ([self windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) {
1216-
[nswindow miniaturize:nil];
1205+
if ([nswindow isVisible])
1206+
{
1207+
/* isZoomed always returns true if the window is not resizable
1208+
* and fullscreen windows are considered zoomed.
1209+
*/
1210+
if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed] &&
1211+
!(window->flags & SDL_WINDOW_FULLSCREEN) && ![self isInFullscreenSpace]) {
1212+
zoomed = YES;
1213+
} else {
1214+
zoomed = NO;
1215+
}
1216+
if (!zoomed) {
1217+
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0);
1218+
} else {
1219+
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0);
1220+
if ([self windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) {
1221+
[nswindow miniaturize:nil];
1222+
}
12171223
}
12181224
}
12191225

0 commit comments

Comments
 (0)