Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
bastien.bouclet

When exiting a "fullscreen space" on OS X, windows don't go to their defined "windowed mode size", but go back to their previous size.

Steps to reproduce:
1. Create a windowed mode SDL window
2. Toggle it to fullscreen with the SDL_WINDOW_FULLSCREEN_DESKTOP flag
3. While in fullscreen, change the windowed mode size using SDL_SetWindowSize
4. Toggle the window back to windowed mode

Expected result:
- The window has the size specified during step 3.

Actual result:
- The window has the size specified when creating the window in step 1.

Attached is a minimal reproduction test case.
The attached test case works as expected on X11 and Windows.
  • Loading branch information
slouken committed Aug 30, 2017
1 parent 846a9ab commit 8fc1fb0
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -752,12 +752,21 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification
[NSMenu setMenuBarVisible:YES];

pendingWindowOperation = PENDING_OPERATION_NONE;
/* Force the size change event in case it was delivered earlier
while the window was still animating into place.
*/
window->w = 0;
window->h = 0;
[self windowDidResize:aNotification];

/* Restore windowed size and position in case it changed while fullscreen */
{
NSRect rect;
rect.origin.x = window->windowed.x;
rect.origin.y = window->windowed.y;
rect.size.width = window->windowed.w;
rect.size.height = window->windowed.h;
ConvertNSRect([nswindow screen], NO, &rect);

s_moveHack = 0;
[nswindow setContentSize:rect.size];
[nswindow setFrameOrigin:rect.origin];
s_moveHack = SDL_GetTicks();
}

/* FIXME: Why does the window get hidden? */
if (window->flags & SDL_WINDOW_SHOWN) {
Expand Down

0 comments on commit 8fc1fb0

Please sign in to comment.