From 84caf787aa7af2971cb773adcec690d33a9ec8b6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 3 Feb 2019 08:58:16 +0530 Subject: [PATCH] macOS: Workaround for cocoa bug that could cause the mouse cursor to become hidden in other applications in rare circumstances Use window focus gained/lost events instead of mouse enter/exit events to hide/show the mouse cursor. Fixes #1218 --- docs/changelog.rst | 3 +++ glfw/cocoa_window.m | 8 ++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 28811c394..3efc08e91 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,9 @@ To update |kitty|, :doc:`follow the instructions `. - macOS: Add an option :opt:`macos_show_window_title_in_menubar` to not show the current window title in the menu-bar (:iss:`1066`) +- macOS: Workaround for cocoa bug that could cause the mouse cursor to become + hidden in other applications in rare circumstances (:iss:`1218`) + - Fix using remote control to set cursor text color causing errors when creating new windows (:iss:`1326`) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 261d56d69..9766c7602 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -457,6 +457,7 @@ - (void)windowDidBecomeKey:(NSNotification *)notification _glfwInputWindowFocus(window, GLFW_TRUE); updateCursorMode(window); + if (window->cursorMode == GLFW_CURSOR_HIDDEN) hideCursor(window); if (_glfw.ns.disabledCursorWindow != window && cursorInClientArea(window)) { double x = 0, y = 0; @@ -469,6 +470,7 @@ - (void)windowDidResignKey:(NSNotification *)notification { if (window->monitor && window->autoIconify) _glfwPlatformIconifyWindow(window); + showCursor(window); _glfwInputWindowFocus(window, GLFW_FALSE); } @@ -720,17 +722,11 @@ - (void)otherMouseUp:(NSEvent *)event - (void)mouseExited:(NSEvent *)event { - if (window->cursorMode == GLFW_CURSOR_HIDDEN) - showCursor(window); - _glfwInputCursorEnter(window, GLFW_FALSE); } - (void)mouseEntered:(NSEvent *)event { - if (window->cursorMode == GLFW_CURSOR_HIDDEN) - hideCursor(window); - _glfwInputCursorEnter(window, GLFW_TRUE); }