src/video/cocoa/SDL_cocoawindow.m
changeset 8801 98173814b673
parent 8798 2703c0c19f45
child 8809 054ec268f363
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Mon Jun 02 09:06:38 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Jun 02 09:09:40 2014 -0700
     1.3 @@ -49,6 +49,9 @@
     1.4  #endif
     1.5  
     1.6  
     1.7 +#define FULLSCREEN_MASK (SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_FULLSCREEN)
     1.8 +
     1.9 +
    1.10  @interface SDLWindow : NSWindow
    1.11  /* These are needed for borderless/fullscreen windows */
    1.12  - (BOOL)canBecomeKeyWindow;
    1.13 @@ -89,9 +92,9 @@
    1.14  
    1.15  static Uint32 s_moveHack;
    1.16  
    1.17 -static void ConvertNSRect(NSScreen *screen, NSRect *r)
    1.18 +static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r)
    1.19  {
    1.20 -    NSRect visibleScreen = [screen visibleFrame];
    1.21 +    NSRect visibleScreen = fullscreen ? [screen frame] : [screen visibleFrame];
    1.22      r->origin.y = (visibleScreen.origin.y + visibleScreen.size.height) - r->origin.y - r->size.height;
    1.23  }
    1.24  
    1.25 @@ -412,8 +415,9 @@
    1.26      int x, y;
    1.27      SDL_Window *window = _data->window;
    1.28      NSWindow *nswindow = _data->nswindow;
    1.29 +    BOOL fullscreen = window->flags & FULLSCREEN_MASK;
    1.30      NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.31 -    ConvertNSRect([nswindow screen], &rect);
    1.32 +    ConvertNSRect([nswindow screen], fullscreen, &rect);
    1.33  
    1.34      if (s_moveHack) {
    1.35          SDL_bool blockMove = ((SDL_GetTicks() - s_moveHack) < 500);
    1.36 @@ -424,7 +428,7 @@
    1.37              /* Cocoa is adjusting the window in response to a mode change */
    1.38              rect.origin.x = window->x;
    1.39              rect.origin.y = window->y;
    1.40 -            ConvertNSRect([nswindow screen], &rect);
    1.41 +            ConvertNSRect([nswindow screen], fullscreen, &rect);
    1.42              [nswindow setFrameOrigin:rect.origin];
    1.43              return;
    1.44          }
    1.45 @@ -449,7 +453,7 @@
    1.46      NSWindow *nswindow = _data->nswindow;
    1.47      int x, y, w, h;
    1.48      NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.49 -    ConvertNSRect([nswindow screen], &rect);
    1.50 +    ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect);
    1.51      x = (int)rect.origin.x;
    1.52      y = (int)rect.origin.y;
    1.53      w = (int)rect.size.width;
    1.54 @@ -934,7 +938,7 @@
    1.55      /* Fill in the SDL window with the window data */
    1.56      {
    1.57          NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.58 -        ConvertNSRect([nswindow screen], &rect);
    1.59 +        ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect);
    1.60          window->x = (int)rect.origin.x;
    1.61          window->y = (int)rect.origin.y;
    1.62          window->w = (int)rect.size.width;
    1.63 @@ -1010,7 +1014,7 @@
    1.64      rect.origin.y = window->y;
    1.65      rect.size.width = window->w;
    1.66      rect.size.height = window->h;
    1.67 -    ConvertNSRect([[NSScreen screens] objectAtIndex:0], &rect);
    1.68 +    ConvertNSRect([[NSScreen screens] objectAtIndex:0], (window->flags & FULLSCREEN_MASK), &rect);
    1.69  
    1.70      style = GetWindowStyle(window);
    1.71  
    1.72 @@ -1138,7 +1142,7 @@
    1.73      rect.origin.y = window->y;
    1.74      rect.size.width = window->w;
    1.75      rect.size.height = window->h;
    1.76 -    ConvertNSRect([nswindow screen], &rect);
    1.77 +    ConvertNSRect([nswindow screen], (window->flags & FULLSCREEN_MASK), &rect);
    1.78  
    1.79      moveHack = s_moveHack;
    1.80      s_moveHack = 0;
    1.81 @@ -1338,7 +1342,7 @@
    1.82          rect.origin.y = bounds.y;
    1.83          rect.size.width = bounds.w;
    1.84          rect.size.height = bounds.h;
    1.85 -        ConvertNSRect([nswindow screen], &rect);
    1.86 +        ConvertNSRect([nswindow screen], fullscreen, &rect);
    1.87  
    1.88          /* Hack to fix origin on Mac OS X 10.4 */
    1.89          NSRect screenRect = [[nswindow screen] frame];
    1.90 @@ -1356,7 +1360,7 @@
    1.91          rect.origin.y = window->windowed.y;
    1.92          rect.size.width = window->windowed.w;
    1.93          rect.size.height = window->windowed.h;
    1.94 -        ConvertNSRect([nswindow screen], &rect);
    1.95 +        ConvertNSRect([nswindow screen], fullscreen, &rect);
    1.96  
    1.97          if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
    1.98              [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];