src/video/cocoa/SDL_cocoawindow.m
changeset 3507 3712547eac4f
parent 3506 e829b6098435
child 3508 a12068b6f44f
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Tue Dec 01 11:50:00 2009 +0000
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Tue Dec 01 12:08:34 2009 +0000
     1.3 @@ -98,11 +98,10 @@
     1.4  - (void)windowDidMove:(NSNotification *)aNotification
     1.5  {
     1.6      int x, y;
     1.7 -    NSRect disp = CGDisplayBounds(_data->display);
     1.8      NSRect rect = [_data->window contentRectForFrameRect:[_data->window frame]];
     1.9      ConvertNSRect(&rect);
    1.10 -    x = (int)rect.origin.x - disp.origin.x;
    1.11 -    y = (int)rect.origin.y - disp.origin.y;
    1.12 +    x = (int)rect.origin.x;
    1.13 +    y = (int)rect.origin.y;
    1.14      SDL_SendWindowEvent(_data->windowID, SDL_WINDOWEVENT_MOVED, x, y);
    1.15  }
    1.16  
    1.17 @@ -245,11 +244,11 @@
    1.18          point.x = point.x - rect.origin.x;
    1.19          point.y = rect.size.height - point.y;
    1.20      } else {
    1.21 -        rect = [_data->window contentRectForFrameRect:[_data->window frame]];
    1.22 -        point.y = rect.size.height - (point.y - rect.origin.y);
    1.23 +        point.x -= window->x;
    1.24 +        point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - window->y;
    1.25      }
    1.26 -    if ( point.x < 0 || point.x >= rect.size.width ||
    1.27 -         point.y < 0 || point.y >= rect.size.height ) {
    1.28 +    if ( point.x < 0 || point.x >= window->w ||
    1.29 +         point.y < 0 || point.y >= window->h ) {
    1.30          if (mouse->focus != 0) {
    1.31              SDL_SetMouseFocus(index, 0);
    1.32          }
    1.33 @@ -332,11 +331,10 @@
    1.34  
    1.35      /* Fill in the SDL window with the window data */
    1.36      {
    1.37 -        NSRect disp = CGDisplayBounds(data->display);
    1.38          NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]];
    1.39          ConvertNSRect(&rect);
    1.40 -        window->x = (int)rect.origin.x - disp.origin.x;
    1.41 -        window->y = (int)rect.origin.y - disp.origin.y;
    1.42 +        window->x = (int)rect.origin.x;
    1.43 +        window->y = (int)rect.origin.y;
    1.44          window->w = (int)rect.size.width;
    1.45          window->h = (int)rect.size.height;
    1.46      }
    1.47 @@ -401,13 +399,13 @@
    1.48          || window->x == SDL_WINDOWPOS_CENTERED) {
    1.49          rect.origin.x += (rect.size.width - window->w) / 2;
    1.50      } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
    1.51 -        rect.origin.x += window->x;
    1.52 +        rect.origin.x = window->x;
    1.53      }
    1.54      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.55          || window->y == SDL_WINDOWPOS_CENTERED) {
    1.56          rect.origin.y += (rect.size.height - window->h) / 2;
    1.57      } else if (window->x != SDL_WINDOWPOS_UNDEFINED) {
    1.58 -        rect.origin.y += window->y;
    1.59 +        rect.origin.y = window->y;
    1.60      }
    1.61      rect.size.width = window->w;
    1.62      rect.size.height = window->h;
    1.63 @@ -500,13 +498,13 @@
    1.64          || window->x == SDL_WINDOWPOS_CENTERED) {
    1.65          rect.origin.x += (rect.size.width - window->w) / 2;
    1.66      } else {
    1.67 -        rect.origin.x += window->x;
    1.68 +        rect.origin.x = window->x;
    1.69      }
    1.70      if ((window->flags & SDL_WINDOW_FULLSCREEN)
    1.71          || window->y == SDL_WINDOWPOS_CENTERED) {
    1.72          rect.origin.y += (rect.size.height - window->h) / 2;
    1.73      } else {
    1.74 -        rect.origin.y += window->y;
    1.75 +        rect.origin.y = window->y;
    1.76      }
    1.77      rect.size.width = window->w;
    1.78      rect.size.height = window->h;