src/video/cocoa/SDL_cocoamouse.m
changeset 4465 3e69e077cb95
parent 3685 64ce267332c6
child 4484 9322f7db8603
--- a/src/video/cocoa/SDL_cocoamouse.m	Sun May 09 19:55:28 2010 -0700
+++ b/src/video/cocoa/SDL_cocoamouse.m	Sun May 09 20:47:22 2010 -0700
@@ -29,11 +29,6 @@
 void
 Cocoa_InitMouse(_THIS)
 {
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_Mouse mouse;
-
-    SDL_zero(mouse);
-    data->mouse = SDL_AddMouse(&mouse, "Mouse", 0, 0, 1);
 }
 
 static int
@@ -54,10 +49,8 @@
 void
 Cocoa_HandleMouseEvent(_THIS, NSEvent *event)
 {
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-    SDL_Mouse *mouse = SDL_GetMouse(data->mouse);
     int i;
-    NSPoint point;
+    NSPoint point = { 0, 0 };
     SDL_Window *window;
 
     /* See if there are any fullscreen windows that might handle this event */
@@ -73,44 +66,38 @@
             point = [NSEvent mouseLocation];
             point.x = point.x - bounds.x;
             point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - bounds.y;
-            if (point.x < 0 || point.x >= candidate->w ||
-                point.y < 0 || point.y >= candidate->h) {
-                /* The mouse is out of this fullscreen display */
-                if (mouse->focus == candidate) {
-                    SDL_SetMouseFocus(data->mouse, 0);
-                }
-            } else {
+            if ((point.x >= 0 && point.x < candidate->w) ||
+                (point.y >= 0 && point.y < candidate->h)) {
                 /* This is it! */
                 window = candidate;
                 break;
             }
         }
     }
-    if (!window) {
-        return;
-    }
 
     /* Set the focus appropriately */
-    if (mouse->focus != window) {
-        SDL_SetMouseFocus(data->mouse, window);
+    SDL_SetMouseFocus(window);
+
+    if (window) {
+        return;
     }
 
     switch ([event type]) {
     case NSLeftMouseDown:
     case NSOtherMouseDown:
     case NSRightMouseDown:
-        SDL_SendMouseButton(data->mouse, SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber]));
+        SDL_SendMouseButton(SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber]));
         break;
     case NSLeftMouseUp:
     case NSOtherMouseUp:
     case NSRightMouseUp:
-        SDL_SendMouseButton(data->mouse, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
+        SDL_SendMouseButton(SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber]));
         break;
     case NSLeftMouseDragged:
     case NSRightMouseDragged:
     case NSOtherMouseDragged: /* usually middle mouse dragged */
     case NSMouseMoved:
-        SDL_SendMouseMotion(data->mouse, 0, (int)point.x, (int)point.y, 0);
+        SDL_SendMouseMotion(0, (int)point.x, (int)point.y);
         break;
     default: /* just to avoid compiler warnings */
         break;
@@ -120,9 +107,6 @@
 void
 Cocoa_QuitMouse(_THIS)
 {
-    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
-
-    SDL_DelMouse(data->mouse);
 }
 
 /* vi: set ts=4 sw=4 expandtab: */