Created
March 1, 2013 19:55
-
-
Save jorgenpt/5067271 to your computer and use it in GitHub Desktop.
SDL2: Fix for missing movement updates when losing focus.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /tmp/tmp.4049.39 2013-03-01 11:53:56.199276885 -0800 | |
+++ src/events/SDL_mouse.c 2013-03-01 11:52:47.390674778 -0800 | |
@@ -33,6 +33,8 @@ | |
/* The mouse state */ | |
static SDL_Mouse SDL_mouse; | |
+static int | |
+SDL_PrivateSendMouseMotion(SDL_Window * window, int relative, int x, int y); | |
/* Public functions */ | |
int | |
@@ -154,8 +156,9 @@ | |
#endif | |
if (window == mouse->focus) { | |
#ifdef DEBUG_MOUSE | |
- printf("Mouse left window, synthesizing focus lost event\n"); | |
+ printf("Mouse left window, synthesizing move & focus lost event\n"); | |
#endif | |
+ SDL_PrivateSendMouseMotion(window, 0, x, y); | |
SDL_SetMouseFocus(NULL); | |
} | |
return SDL_FALSE; | |
@@ -176,18 +179,25 @@ | |
int | |
SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) | |
{ | |
- SDL_Mouse *mouse = SDL_GetMouse(); | |
- int posted; | |
- int xrel; | |
- int yrel; | |
- int x_max = 0, y_max = 0; | |
- | |
if (window && !relative) { | |
+ SDL_Mouse *mouse = SDL_GetMouse(); | |
if (!SDL_UpdateMouseFocus(window, x, y, mouse->buttonstate)) { | |
return 0; | |
} | |
} | |
+ return SDL_PrivateSendMouseMotion(window, relative, x, y); | |
+} | |
+ | |
+static int | |
+SDL_PrivateSendMouseMotion(SDL_Window * window, int relative, int x, int y) | |
+{ | |
+ SDL_Mouse *mouse = SDL_GetMouse(); | |
+ int posted; | |
+ int xrel; | |
+ int yrel; | |
+ int x_max = 0, y_max = 0; | |
+ | |
/* relative motion is calculated regarding the system cursor last position */ | |
if (relative) { | |
xrel = x; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment