src/video/cocoa/SDL_cocoawindow.m
changeset 9904 e9b49510e51b
parent 9903 2bbb11de1e60
child 9905 fcf85090f816
equal deleted inserted replaced
9903:2bbb11de1e60 9904:e9b49510e51b
   644     
   644     
   645     SetWindowStyle(window, GetWindowStyle(window));
   645     SetWindowStyle(window, GetWindowStyle(window));
   646 
   646 
   647     isFullscreenSpace = NO;
   647     isFullscreenSpace = NO;
   648     inFullscreenTransition = NO;
   648     inFullscreenTransition = NO;
   649 
       
   650     /* Try again? Not sure what else to do, the application wants to be fullscreen. */
       
   651     [self setFullscreenSpace:YES];
       
   652 }
   649 }
   653 
   650 
   654 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
   651 - (void)windowDidEnterFullScreen:(NSNotification *)aNotification
   655 {
   652 {
   656     SDL_Window *window = _data->window;
   653     SDL_Window *window = _data->window;
   691     
   688     
   692     SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));
   689     SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));
   693     
   690     
   694     isFullscreenSpace = YES;
   691     isFullscreenSpace = YES;
   695     inFullscreenTransition = NO;
   692     inFullscreenTransition = NO;
   696 
       
   697     /* Try again? Not sure what else to do, the application wants to be non-fullscreen. */
       
   698     [self setFullscreenSpace:NO];
       
   699 }
   693 }
   700 
   694 
   701 - (void)windowDidExitFullScreen:(NSNotification *)aNotification
   695 - (void)windowDidExitFullScreen:(NSNotification *)aNotification
   702 {
   696 {
   703     SDL_Window *window = _data->window;
   697     SDL_Window *window = _data->window;
  1702 {
  1696 {
  1703     SDL_bool succeeded = SDL_FALSE;
  1697     SDL_bool succeeded = SDL_FALSE;
  1704     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  1698     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
  1705 
  1699 
  1706     if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
  1700     if ([data->listener setFullscreenSpace:(state ? YES : NO)]) {
       
  1701         const int maxattempts = 3;
       
  1702         int attempt = 0;
       
  1703         while (++attempt <= maxattempts) {
       
  1704             /* Wait for the transition to complete, so application changes
       
  1705              take effect properly (e.g. setting the window size, etc.)
       
  1706              */
       
  1707             const int limit = 10000;
       
  1708             int count = 0;
       
  1709             while ([data->listener isInFullscreenSpaceTransition]) {
       
  1710                 if ( ++count == limit ) {
       
  1711                     /* Uh oh, transition isn't completing. Should we assert? */
       
  1712                     break;
       
  1713                 }
       
  1714                 SDL_Delay(1);
       
  1715                 SDL_PumpEvents();
       
  1716             }
       
  1717             if ([data->listener isInFullscreenSpace] == (state ? YES : NO))
       
  1718                 break;
       
  1719             /* Try again, the last attempt was interrupted by user gestures */
       
  1720             if (![data->listener setFullscreenSpace:(state ? YES : NO)])
       
  1721                 break; /* ??? */
       
  1722         }
       
  1723         /* Return TRUE to prevent non-space fullscreen logic from running */
  1707         succeeded = SDL_TRUE;
  1724         succeeded = SDL_TRUE;
  1708 
       
  1709         /* Wait for the transition to complete, so application changes
       
  1710            take effect properly (e.g. setting the window size, etc.)
       
  1711          */
       
  1712         const int limit = 10000;
       
  1713         int count = 0;
       
  1714         while ([data->listener isInFullscreenSpaceTransition]) {
       
  1715             if ( ++count == limit ) {
       
  1716                 /* Uh oh, transition isn't completing. Should we assert? */
       
  1717                 break;
       
  1718             }
       
  1719             SDL_Delay(1);
       
  1720             SDL_PumpEvents();
       
  1721         }
       
  1722     }
  1725     }
  1723 
  1726 
  1724     return succeeded;
  1727     return succeeded;
  1725 }}
  1728 }}
  1726 
  1729