diff src/video/cocoa/SDL_cocoawindow.m @ 4484:9322f7db8603

Cleaned up the mouse window focus handling: you always pass in the relative window when sending a mouse event. Fixed a bug where only mouse wheel up was sent on Mac OS X Fixed a bug where mouse window focus was getting hosed by the fullscreen mouse code on Mac OS X
author Sam Lantinga <slouken@libsdl.org>
date Mon, 05 Jul 2010 22:48:13 -0700
parents 3e69e077cb95
children 3d91e31fcf71
line wrap: on
line diff
--- a/src/video/cocoa/SDL_cocoawindow.m	Mon Jul 05 22:45:45 2010 -0700
+++ b/src/video/cocoa/SDL_cocoawindow.m	Mon Jul 05 22:48:13 2010 -0700
@@ -171,7 +171,7 @@
         button = [theEvent buttonNumber];
         break;
     }
-    SDL_SendMouseButton(SDL_PRESSED, button);
+    SDL_SendMouseButton(_data->window, SDL_PRESSED, button);
 }
 
 - (void)rightMouseDown:(NSEvent *)theEvent
@@ -202,7 +202,7 @@
         button = [theEvent buttonNumber];
         break;
     }
-    SDL_SendMouseButton(SDL_RELEASED, button);
+    SDL_SendMouseButton(_data->window, SDL_RELEASED, button);
 }
 
 - (void)rightMouseUp:(NSEvent *)theEvent
@@ -228,8 +228,7 @@
             SDL_SetMouseFocus(NULL);
         }
     } else {
-        SDL_SetMouseFocus(_data->window);
-        SDL_SendMouseMotion(0, (int)point.x, (int)point.y);
+        SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y);
     }
 }
 
@@ -250,7 +249,20 @@
 
 - (void)scrollWheel:(NSEvent *)theEvent
 {
-    SDL_SendMouseWheel((int)([theEvent deltaX]+0.9f), (int)([theEvent deltaY]+0.9f));
+    float x = [theEvent deltaX];
+    float y = [theEvent deltaY];
+
+    if (x > 0) {
+        x += 0.9f;
+    } else if (x < 0) {
+        x -= 0.9f;
+    }
+    if (y > 0) {
+        y += 0.9f;
+    } else if (y < 0) {
+        y -= 0.9f;
+    }
+    SDL_SendMouseWheel(_data->window, (int)x, (int)y);
 }
 
 @end