src/video/cocoa/SDL_cocoawindow.m
changeset 7990 a05a48e493c0
parent 7970 6dc794be47aa
child 8083 3782a12331d6
equal deleted inserted replaced
7989:c13adfce24a9 7990:a05a48e493c0
    84         if (window->flags & SDL_WINDOW_RESIZABLE) {
    84         if (window->flags & SDL_WINDOW_RESIZABLE) {
    85             style |= NSResizableWindowMask;
    85             style |= NSResizableWindowMask;
    86         }
    86         }
    87     }
    87     }
    88     return style;
    88     return style;
       
    89 }
       
    90 
       
    91 static SDL_bool
       
    92 SetWindowStyle(SDL_Window * window, unsigned int style)
       
    93 {
       
    94     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
       
    95     NSWindow *nswindow = data->nswindow;
       
    96 
       
    97     if (![nswindow respondsToSelector: @selector(setStyleMask:)]) {
       
    98         return SDL_FALSE;
       
    99     }
       
   100 
       
   101     /* The view responder chain gets messed with during setStyleMask */
       
   102     if ([[nswindow contentView] nextResponder] == data->listener) {
       
   103         [[nswindow contentView] setNextResponder:nil];
       
   104     }
       
   105 
       
   106     [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)style];
       
   107 
       
   108     /* The view responder chain gets messed with during setStyleMask */
       
   109     if ([[nswindow contentView] nextResponder] != data->listener) {
       
   110         [[nswindow contentView] setNextResponder:data->listener];
       
   111     }
       
   112 
       
   113     return SDL_TRUE;
    89 }
   114 }
    90 
   115 
    91 
   116 
    92 @implementation Cocoa_WindowListener
   117 @implementation Cocoa_WindowListener
    93 
   118 
   420 }
   445 }
   421 
   446 
   422 - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
   447 - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
   423 {
   448 {
   424     SDL_Window *window = _data->window;
   449     SDL_Window *window = _data->window;
   425     NSWindow *nswindow = _data->nswindow;
       
   426 
   450 
   427     window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
   451     window->flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
   428     [nswindow setStyleMask:(NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask)];
   452     SetWindowStyle(window, (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask|NSResizableWindowMask));
   429 
   453 
   430     isFullscreenSpace = YES;
   454     isFullscreenSpace = YES;
   431     inFullscreenTransition = YES;
   455     inFullscreenTransition = YES;
   432 }
   456 }
   433 
   457 
   452 }
   476 }
   453 
   477 
   454 - (void)windowWillExitFullScreen:(NSNotification *)aNotification
   478 - (void)windowWillExitFullScreen:(NSNotification *)aNotification
   455 {
   479 {
   456     SDL_Window *window = _data->window;
   480     SDL_Window *window = _data->window;
   457     NSWindow *nswindow = _data->nswindow;
       
   458 
   481 
   459     window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
   482     window->flags &= ~SDL_WINDOW_FULLSCREEN_DESKTOP;
   460     [nswindow setStyleMask:GetWindowStyle(window)];
   483     SetWindowStyle(window, GetWindowStyle(window));
   461 
   484 
   462     isFullscreenSpace = NO;
   485     isFullscreenSpace = NO;
   463     inFullscreenTransition = YES;
   486     inFullscreenTransition = YES;
   464 }
   487 }
   465 
   488 
  1171 
  1194 
  1172 void
  1195 void
  1173 Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
  1196 Cocoa_SetWindowBordered(_THIS, SDL_Window * window, SDL_bool bordered)
  1174 {
  1197 {
  1175     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  1198     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
  1176     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
  1199     if (SetWindowStyle(window, GetWindowStyle(window))) {
  1177     if ([nswindow respondsToSelector:@selector(setStyleMask:)]) {
       
  1178         [nswindow setStyleMask:GetWindowStyle(window)];
       
  1179         if (bordered) {
  1200         if (bordered) {
  1180             Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
  1201             Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
  1181         }
  1202         }
  1182     }
  1203     }
  1183     [pool release];
  1204     [pool release];