Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
authorSam Lantinga <slouken@libsdl.org>
Sat, 09 Sep 2017 10:31:44 -0700
changeset 1148205aa6d232dca
parent 11481 490c36e2945d
child 11483 6f723ec1d371
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).
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Sep 09 09:31:12 2017 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Sep 09 10:31:44 2017 -0700
     1.3 @@ -520,6 +520,11 @@
     1.4      NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
     1.5      ConvertNSRect([nswindow screen], fullscreen, &rect);
     1.6  
     1.7 +    if (inFullscreenTransition) {
     1.8 +        /* We'll take care of this at the end of the transition */
     1.9 +        return;
    1.10 +    }
    1.11 +
    1.12      if (s_moveHack) {
    1.13          SDL_bool blockMove = ((SDL_GetTicks() - s_moveHack) < 500);
    1.14  
    1.15 @@ -719,6 +724,7 @@
    1.16           */
    1.17          window->w = 0;
    1.18          window->h = 0;
    1.19 +        [self windowDidMove:aNotification];
    1.20          [self windowDidResize:aNotification];
    1.21      }
    1.22  }
    1.23 @@ -727,13 +733,13 @@
    1.24  {
    1.25      SDL_Window *window = _data->window;
    1.26  
    1.27 +    isFullscreenSpace = NO;
    1.28 +    inFullscreenTransition = YES;
    1.29 +
    1.30      /* As of OS X 10.11, the window seems to need to be resizable when exiting
    1.31         a Space, in order for it to resize back to its windowed-mode size.
    1.32       */
    1.33      SetWindowStyle(window, GetWindowStyle(window) | NSWindowStyleMaskResizable);
    1.34 -
    1.35 -    isFullscreenSpace = NO;
    1.36 -    inFullscreenTransition = YES;
    1.37  }
    1.38  
    1.39  - (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification
    1.40 @@ -801,6 +807,7 @@
    1.41           */
    1.42          window->w = 0;
    1.43          window->h = 0;
    1.44 +        [self windowDidMove:aNotification];
    1.45          [self windowDidResize:aNotification];
    1.46  
    1.47          /* FIXME: Why does the window get hidden? */