src/video/cocoa/SDL_cocoawindow.m
changeset 8729 94af945dbb57
parent 8652 8514fc57f124
child 8738 354dabd2cb58
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Apr 19 13:15:41 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sat Apr 19 13:15:53 2014 -0700
     1.3 @@ -89,9 +89,10 @@
     1.4  
     1.5  static Uint32 s_moveHack;
     1.6  
     1.7 -static void ConvertNSRect(NSRect *r)
     1.8 +static void ConvertNSRect(NSScreen *screen, NSRect *r)
     1.9  {
    1.10 -    r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
    1.11 +    NSRect visibleScreen = [screen visibleFrame];
    1.12 +    r->origin.y = visibleScreen.size.height - r->origin.y - r->size.height;
    1.13  }
    1.14  
    1.15  static void
    1.16 @@ -410,7 +411,7 @@
    1.17      SDL_Window *window = _data->window;
    1.18      NSWindow *nswindow = _data->nswindow;
    1.19      NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.20 -    ConvertNSRect(&rect);
    1.21 +    ConvertNSRect([nswindow screen], &rect);
    1.22  
    1.23      if (s_moveHack) {
    1.24          SDL_bool blockMove = ((SDL_GetTicks() - s_moveHack) < 500);
    1.25 @@ -421,7 +422,7 @@
    1.26              /* Cocoa is adjusting the window in response to a mode change */
    1.27              rect.origin.x = window->x;
    1.28              rect.origin.y = window->y;
    1.29 -            ConvertNSRect(&rect);
    1.30 +            ConvertNSRect([nswindow screen], &rect);
    1.31              [nswindow setFrameOrigin:rect.origin];
    1.32              return;
    1.33          }
    1.34 @@ -446,7 +447,7 @@
    1.35      NSWindow *nswindow = _data->nswindow;
    1.36      int x, y, w, h;
    1.37      NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.38 -    ConvertNSRect(&rect);
    1.39 +    ConvertNSRect([nswindow screen], &rect);
    1.40      x = (int)rect.origin.x;
    1.41      y = (int)rect.origin.y;
    1.42      w = (int)rect.size.width;
    1.43 @@ -931,7 +932,7 @@
    1.44      /* Fill in the SDL window with the window data */
    1.45      {
    1.46          NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.47 -        ConvertNSRect(&rect);
    1.48 +        ConvertNSRect([nswindow screen], &rect);
    1.49          window->x = (int)rect.origin.x;
    1.50          window->y = (int)rect.origin.y;
    1.51          window->w = (int)rect.size.width;
    1.52 @@ -1007,7 +1008,7 @@
    1.53      rect.origin.y = window->y;
    1.54      rect.size.width = window->w;
    1.55      rect.size.height = window->h;
    1.56 -    ConvertNSRect(&rect);
    1.57 +    ConvertNSRect([[NSScreen screens] objectAtIndex:0], &rect);
    1.58  
    1.59      style = GetWindowStyle(window);
    1.60  
    1.61 @@ -1135,7 +1136,7 @@
    1.62      rect.origin.y = window->y;
    1.63      rect.size.width = window->w;
    1.64      rect.size.height = window->h;
    1.65 -    ConvertNSRect(&rect);
    1.66 +    ConvertNSRect([nswindow screen], &rect);
    1.67  
    1.68      moveHack = s_moveHack;
    1.69      s_moveHack = 0;
    1.70 @@ -1335,7 +1336,7 @@
    1.71          rect.origin.y = bounds.y;
    1.72          rect.size.width = bounds.w;
    1.73          rect.size.height = bounds.h;
    1.74 -        ConvertNSRect(&rect);
    1.75 +        ConvertNSRect([nswindow screen], &rect);
    1.76  
    1.77          /* Hack to fix origin on Mac OS X 10.4 */
    1.78          NSRect screenRect = [[nswindow screen] frame];
    1.79 @@ -1353,7 +1354,7 @@
    1.80          rect.origin.y = window->windowed.y;
    1.81          rect.size.width = window->windowed.w;
    1.82          rect.size.height = window->windowed.h;
    1.83 -        ConvertNSRect(&rect);
    1.84 +        ConvertNSRect([nswindow screen], &rect);
    1.85  
    1.86          if ([nswindow respondsToSelector: @selector(setStyleMask:)]) {
    1.87              [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)];