From 04abe922b7df4ba6ea0beb3da54fcabe58d0b9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Pa=CC=81lsson?= Date: Sun, 6 Oct 2013 16:54:52 +0200 Subject: [PATCH 1/5] OSX fixed set cursor pos in HIDDEN and NORMAL mode --- src/cocoa_window.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 85dfa6363..b381211ba 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1065,6 +1065,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) CGWarpMouseCursorPosition(CGPointMake(globalPoint.x, transformY(globalPoint.y))); } + + if (window->cursorMode != GLFW_CURSOR_DISABLED) + { + CGAssociateMouseAndMouseCursorPosition(true); + } } void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) From 9369545bb4a83dbd6b4f6d60779da679858f8000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Pa=CC=81lsson?= Date: Sun, 6 Oct 2013 16:55:39 +0200 Subject: [PATCH 2/5] OSX fixed cursor flickering If the mouse was moved outside of the window in HIDDEN mode and glfwSetCursorPos moved the mouse inside the window, then the cursor was not hidden. --- src/cocoa_window.m | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index b381211ba..486cddfd5 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1070,6 +1070,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) { CGAssociateMouseAndMouseCursorPosition(true); } + setModeCursor(window, window->cursorMode); } void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode) From 28a0dc0fb9871b9a34868bb2da8d05de5340feec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Pa=CC=81lsson?= Date: Sun, 6 Oct 2013 17:03:07 +0200 Subject: [PATCH 3/5] OSX set cursor position not working in fullscreen mode The cursor position was not set because the fullscreen window was not considered to be in focus. --- src/cocoa_window.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 486cddfd5..1f92d46e3 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -60,6 +60,8 @@ static void enterFullscreenMode(_GLFWwindow* window) [window->ns.view enterFullScreenMode:window->monitor->ns.screen withOptions:nil]; + + _glfwInputWindowFocus(window, GL_TRUE); } // Leave fullscreen mode From 6a26ef0920d30f96225f9fa415547892517d6a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Pa=CC=81lsson?= Date: Sun, 6 Oct 2013 17:51:37 +0200 Subject: [PATCH 4/5] OSX fixed set cursor position on retina in fullscr. Weird behavior. glfwSetCursorPos worked fine in fullscreen if I had monitor connected to the laptop, on either display. But was offset by about 200px in fullscreen if no monitor was connected. --- src/cocoa_window.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 1f92d46e3..68fcf7959 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -1058,6 +1058,10 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double x, double y) CGDisplayMoveCursorToPoint(window->monitor->ns.displayID, CGPointMake(x, y)); } + else if ([window->ns.view isInFullScreenMode]) + { + CGWarpMouseCursorPosition(CGPointMake(x, y)); + } else { const NSRect contentRect = [window->ns.view frame]; From 3e1b931033b5afd2bfd155df6d5d7f1472ad1dd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andri=20Pa=CC=81lsson?= Date: Tue, 8 Oct 2013 22:33:19 +0200 Subject: [PATCH 5/5] OSX fix for changing cursor mode from NORMAL to DISABLED If you set the cursor to NORMAL mode and then to DISABLED then the cursor would not get hidden. --- src/input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/input.c b/src/input.c index 1bd7e6d8f..25170d61d 100644 --- a/src/input.c +++ b/src/input.c @@ -48,6 +48,8 @@ static void setCursorMode(_GLFWwindow* window, int newMode) oldMode = window->cursorMode; if (oldMode == newMode) return; + + window->cursorMode = newMode; if (window == _glfw.focusedWindow) { @@ -72,7 +74,6 @@ static void setCursorMode(_GLFWwindow* window, int newMode) _glfwPlatformSetCursorMode(window, newMode); } - window->cursorMode = newMode; } // Set sticky keys mode for the specified window