src/video/cocoa/SDL_cocoawindow.m
changeset 9086 c5e33f9a0d03
parent 9041 89e97caa2387
child 9236 a845edf98a80
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sun Aug 17 14:44:53 2014 -0700
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Aug 17 14:57:52 2014 -0700
     1.3 @@ -103,8 +103,7 @@
     1.4  
     1.5  static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r)
     1.6  {
     1.7 -    NSRect visibleScreen = fullscreen ? [screen frame] : [screen visibleFrame];
     1.8 -    r->origin.y = (visibleScreen.origin.y + visibleScreen.size.height) - r->origin.y - r->size.height;
     1.9 +    r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height;
    1.10  }
    1.11  
    1.12  static void
    1.13 @@ -389,11 +388,11 @@
    1.14          isMoving = NO;
    1.15  
    1.16          SDL_Mouse *mouse = SDL_GetMouse();
    1.17 -        if (pendingWindowWarpX >= 0 && pendingWindowWarpY >= 0) {
    1.18 -            mouse->WarpMouse(_data->window, pendingWindowWarpX, pendingWindowWarpY);
    1.19 -            pendingWindowWarpX = pendingWindowWarpY = -1;
    1.20 +        if (pendingWindowWarpX != INT_MAX && pendingWindowWarpY != INT_MAX) {
    1.21 +            mouse->WarpMouseGlobal(pendingWindowWarpX, pendingWindowWarpY);
    1.22 +            pendingWindowWarpX = pendingWindowWarpY = INT_MAX;
    1.23          }
    1.24 -        if (mouse->relative_mode && SDL_GetMouseFocus() == _data->window) {
    1.25 +        if (mouse->relative_mode && !mouse->relative_mode_warp && mouse->focus == _data->window) {
    1.26              mouse->SetRelativeMouseMode(SDL_TRUE);
    1.27          }
    1.28      }
    1.29 @@ -413,7 +412,7 @@
    1.30  - (void)windowWillMove:(NSNotification *)aNotification
    1.31  {
    1.32      if ([_data->nswindow isKindOfClass:[SDLWindow class]]) {
    1.33 -        pendingWindowWarpX = pendingWindowWarpY = -1;
    1.34 +        pendingWindowWarpX = pendingWindowWarpY = INT_MAX;
    1.35          isMoving = YES;
    1.36      }
    1.37  }
    1.38 @@ -500,7 +499,7 @@
    1.39  {
    1.40      SDL_Window *window = _data->window;
    1.41      SDL_Mouse *mouse = SDL_GetMouse();
    1.42 -    if (mouse->relative_mode && ![self isMoving]) {
    1.43 +    if (mouse->relative_mode && !mouse->relative_mode_warp && ![self isMoving]) {
    1.44          mouse->SetRelativeMouseMode(SDL_TRUE);
    1.45      }
    1.46  
    1.47 @@ -532,7 +531,7 @@
    1.48  - (void)windowDidResignKey:(NSNotification *)aNotification
    1.49  {
    1.50      SDL_Mouse *mouse = SDL_GetMouse();
    1.51 -    if (mouse->relative_mode) {
    1.52 +    if (mouse->relative_mode && !mouse->relative_mode_warp) {
    1.53          mouse->SetRelativeMouseMode(SDL_FALSE);
    1.54      }
    1.55