src/video/cocoa/SDL_cocoawindow.m
changeset 6666 018f8019ce36
parent 6662 698c2e533a7e
child 6681 5a0396a933b5
     1.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Thu Nov 08 01:07:29 2012 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Thu Nov 08 02:26:40 2012 -0800
     1.3 @@ -200,10 +200,8 @@
     1.4          y = (int)(window->h - point.y);
     1.5  
     1.6          if (x >= 0 && x < window->w && y >= 0 && y < window->h) {
     1.7 -            if (SDL_GetMouseFocus() != window) {
     1.8 -                [self mouseEntered:nil];
     1.9 -            }
    1.10              SDL_SendMouseMotion(window, 0, x, y);
    1.11 +            SDL_SetCursor(NULL);
    1.12          }
    1.13      }
    1.14  
    1.15 @@ -309,38 +307,6 @@
    1.16      [self mouseUp:theEvent];
    1.17  }
    1.18  
    1.19 -- (void)mouseEntered:(NSEvent *)theEvent
    1.20 -{
    1.21 -    SDL_SetMouseFocus(_data->window);
    1.22 -
    1.23 -    SDL_SetCursor(NULL);
    1.24 -}
    1.25 -
    1.26 -- (void)mouseExited:(NSEvent *)theEvent
    1.27 -{
    1.28 -    SDL_Window *window = _data->window;
    1.29 -
    1.30 -    if (SDL_GetMouseFocus() == window) {
    1.31 -        if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
    1.32 -            int x, y;
    1.33 -            NSPoint point;
    1.34 -            CGPoint cgpoint;
    1.35 -
    1.36 -            point = [theEvent locationInWindow];
    1.37 -            point.y = window->h - point.y;
    1.38 -
    1.39 -            SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y);
    1.40 -            SDL_GetMouseState(&x, &y);
    1.41 -            cgpoint.x = window->x + x;
    1.42 -            cgpoint.y = window->y + y;
    1.43 -            CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
    1.44 -        } else {
    1.45 -            SDL_SetMouseFocus(NULL);
    1.46 -            SDL_SetCursor(NULL);
    1.47 -        }
    1.48 -    }
    1.49 -}
    1.50 -
    1.51  - (void)mouseMoved:(NSEvent *)theEvent
    1.52  {
    1.53      SDL_Mouse *mouse = SDL_GetMouse();
    1.54 @@ -357,15 +323,26 @@
    1.55      y = (int)(window->h - point.y);
    1.56  
    1.57      if (x < 0 || x >= window->w || y < 0 || y >= window->h) {
    1.58 -        if (SDL_GetMouseFocus() == window) {
    1.59 -            [self mouseExited:theEvent];
    1.60 +        if (window->flags & SDL_WINDOW_INPUT_GRABBED) {
    1.61 +            CGPoint cgpoint;
    1.62 +
    1.63 +            if (x < 0) {
    1.64 +                x = 0;
    1.65 +            } else if (x >= window->w) {
    1.66 +                x = window->w - 1;
    1.67 +            }
    1.68 +            if (y < 0) {
    1.69 +                y = 0;
    1.70 +            } else if (y >= window->h) {
    1.71 +                y = window->h - 1;
    1.72 +            }
    1.73 +
    1.74 +            cgpoint.x = window->x + x;
    1.75 +            cgpoint.y = window->y + y;
    1.76 +            CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint);
    1.77          }
    1.78 -    } else {
    1.79 -        if (SDL_GetMouseFocus() != window) {
    1.80 -            [self mouseEntered:theEvent];
    1.81 -        }
    1.82 -        SDL_SendMouseMotion(window, 0, x, y);
    1.83      }
    1.84 +    SDL_SendMouseMotion(window, 0, x, y);
    1.85  }
    1.86  
    1.87  - (void)mouseDragged:(NSEvent *)theEvent