Mac: Fix SDL_WarpMouseInWindow in fullscreen.
authorJørgen P. Tjernø <jorgen@valvesoftware.com>
Mon, 15 Jul 2013 11:57:18 -0700
changeset 7464 7cdeb64faa72
parent 7463 f2f794cf85c0
child 7465 1bcf7aac5623
Mac: Fix SDL_WarpMouseInWindow in fullscreen. If you switched from a window to fullscreen, your SDL_WarpMouseInWindow calls would be offset by the x and y coordinates of the original window.
src/video/cocoa/SDL_cocoamouse.m
--- a/src/video/cocoa/SDL_cocoamouse.m	Mon Jul 15 14:38:19 2013 -0400
+++ b/src/video/cocoa/SDL_cocoamouse.m	Mon Jul 15 11:57:18 2013 -0700
@@ -201,10 +201,13 @@
 Cocoa_WarpMouse(SDL_Window * window, int x, int y)
 {
     SDL_Mouse *mouse = SDL_GetMouse();
-    CGPoint point;
+    CGPoint point = CGMakePoint(x, y);
 
-    point.x = (float)window->x + x;
-    point.y = (float)window->y + y;
+    if (!(window->flags & SDL_WINDOW_FULLSCREEN))
+    {
+        point.x += window->x;
+        point.y += window->y;
+    }
 
     {
         /* This makes Cocoa_HandleMouseEvent ignore this delta in the next