# HG changeset patch # User Sam Lantinga # Date 1299896199 28800 # Node ID 5c4635640bf960f1f0e07b6157fc4e3ca1e93ce1 # Parent 6b65ff3cee62311beb6c33de657972b5058466af Fixed bug 1165 (SDL_GetMouseState() returns wrong location after switch to/from fullscreen) I'm solving this by moving the mouse to the correct location after a fullscreen mode switch. diff -r 6b65ff3cee62 -r 5c4635640bf9 src/video/SDL_video.c --- a/src/video/SDL_video.c Fri Mar 11 16:54:43 2011 -0800 +++ b/src/video/SDL_video.c Fri Mar 11 18:16:39 2011 -0800 @@ -1018,6 +1018,17 @@ } static void +SDL_RestoreMousePosition(SDL_Window *window) +{ + int x, y; + + if (window == SDL_GetMouseFocus()) { + SDL_GetMouseState(&x, &y); + SDL_WarpMouseInWindow(window, x, y); + } +} + +static void SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) { SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); @@ -1070,6 +1081,8 @@ } else { SDL_OnWindowResized(other); } + + SDL_RestoreMousePosition(other); return; } } @@ -1085,6 +1098,9 @@ /* Generate a mode change event here */ SDL_OnWindowResized(window); + + /* Restore the cursor position */ + SDL_RestoreMousePosition(window); } #define CREATE_FLAGS \