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

The window is now resized to its specified size, but it moves to the top left corner of the screen. That is unexpected because neither the user nor the program moved it there. Test program attached (the same one as before).
  • Loading branch information
slouken committed Sep 9, 2017
1 parent fcd9c19 commit 676c3a9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -520,6 +520,11 @@ - (void)windowDidMove:(NSNotification *)aNotification
NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
ConvertNSRect([nswindow screen], fullscreen, &rect);

if (inFullscreenTransition) {
/* We'll take care of this at the end of the transition */
return;
}

if (s_moveHack) {
SDL_bool blockMove = ((SDL_GetTicks() - s_moveHack) < 500);

Expand Down Expand Up @@ -719,6 +724,7 @@ - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
*/
window->w = 0;
window->h = 0;
[self windowDidMove:aNotification];
[self windowDidResize:aNotification];
}
}
Expand All @@ -727,13 +733,13 @@ - (void)windowWillExitFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;

isFullscreenSpace = NO;
inFullscreenTransition = YES;

/* As of OS X 10.11, the window seems to need to be resizable when exiting
a Space, in order for it to resize back to its windowed-mode size.
*/
SetWindowStyle(window, GetWindowStyle(window) | NSWindowStyleMaskResizable);

isFullscreenSpace = NO;
inFullscreenTransition = YES;
}

- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
Expand Down Expand Up @@ -801,6 +807,7 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification
*/
window->w = 0;
window->h = 0;
[self windowDidMove:aNotification];
[self windowDidResize:aNotification];

/* FIXME: Why does the window get hidden? */
Expand Down

0 comments on commit 676c3a9

Please sign in to comment.