src/video/SDL_video.c
changeset 5479 5c4635640bf9
parent 5478 6b65ff3cee62
child 5480 55a687c55676
--- 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 \