diff src/events/SDL_mouse.c @ 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 b530ef003506
line wrap: on
line diff
--- a/src/events/SDL_mouse.c	Mon Jul 05 22:45:45 2010 -0700
+++ b/src/events/SDL_mouse.c	Mon Jul 05 22:48:13 2010 -0700
@@ -112,7 +112,7 @@
 }
 
 int
-SDL_SendMouseMotion(int relative, int x, int y)
+SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y)
 {
     SDL_Mouse *mouse = &SDL_mouse;
     int posted;
@@ -120,6 +120,10 @@
     int yrel;
     int x_max = 0, y_max = 0;
 
+    if (window) {
+        SDL_SetMouseFocus(window);
+    }
+
     /* the relative motion is calculated regarding the system cursor last position */
     if (relative) {
         xrel = x;
@@ -194,12 +198,16 @@
 }
 
 int
-SDL_SendMouseButton(Uint8 state, Uint8 button)
+SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button)
 {
     SDL_Mouse *mouse = &SDL_mouse;
     int posted;
     Uint32 type;
 
+    if (window) {
+        SDL_SetMouseFocus(window);
+    }
+
     /* Figure out which event to perform */
     switch (state) {
     case SDL_PRESSED:
@@ -239,11 +247,15 @@
 }
 
 int
-SDL_SendMouseWheel(int x, int y)
+SDL_SendMouseWheel(SDL_Window * window, int x, int y)
 {
     SDL_Mouse *mouse = &SDL_mouse;
     int posted;
 
+    if (window) {
+        SDL_SetMouseFocus(window);
+    }
+
     if (!x && !y) {
         return 0;
     }
@@ -304,8 +316,7 @@
     if (mouse->WarpMouse) {
         mouse->WarpMouse(mouse, window, x, y);
     } else {
-        SDL_SetMouseFocus(window);
-        SDL_SendMouseMotion(0, x, y);
+        SDL_SendMouseMotion(window, 0, x, y);
     }
 }