From 2bfb40265926e684e9dbc40dc88d970361352a8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20P=2E=20Tjern=C3=B8?= Date: Mon, 15 Jul 2013 11:57:18 -0700 Subject: [PATCH] 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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index 58b666f03..b79663b25 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -201,10 +201,13 @@ static void 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