Wait for the fullscreen transition to complete before allowing the application to continue.
authorSam Lantinga <slouken@libsdl.org>
Wed, 04 Jun 2014 09:39:08 -0700
changeset 8810901ac824a18b
parent 8809 054ec268f363
child 8811 3f0b8a86c65b
Wait for the fullscreen transition to complete before allowing the application to continue.
This fixes Alt-Enter in the Steam streaming client, which sets the window size and position immediately after switching out of fullscreen mode.
src/video/cocoa/SDL_cocoawindow.m
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Wed Jun 04 01:56:14 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Wed Jun 04 09:39:08 2014 -0700
     1.3 @@ -1544,6 +1544,20 @@
     1.4  
     1.5      if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
     1.6          succeeded = SDL_TRUE;
     1.7 +
     1.8 +        /* Wait for the transition to complete, so application changes
     1.9 +           take effect properly (e.g. setting the window size, etc.)
    1.10 +         */
    1.11 +        const int limit = 10000;
    1.12 +        int count = 0;
    1.13 +        while ([data->listener isInFullscreenSpaceTransition]) {
    1.14 +            if ( ++count == limit ) {
    1.15 +                /* Uh oh, transition isn't completing. Should we assert? */
    1.16 +                break;
    1.17 +            }
    1.18 +            SDL_Delay(1);
    1.19 +            SDL_PumpEvents();
    1.20 +        }
    1.21      }
    1.22  
    1.23      [pool release];