From 96a641672595fad483f22d3aa2d68ca6c757d97c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 7 Sep 2019 10:47:28 +1000 Subject: [PATCH] Fix cursor staying hidden when showing dialog boxes on OSX This is particularly annoying for the crash dialog box. Although you can still press Enter to dismiss it. --- src/Window.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Window.c b/src/Window.c index c6c89d845..92964315c 100644 --- a/src/Window.c +++ b/src/Window.c @@ -1753,7 +1753,7 @@ void Window_Create(int width, int height) { kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute | kWindowInWindowMenuAttribute | kWindowLiveResizeAttribute, &r, &win_handle); - if (res) Logger_Abort2(res, "Failed to create window"); + if (res) Logger_Abort2(res, "Creating window failed"); Window_RefreshBounds(); AcquireRootMenu(); @@ -1916,12 +1916,14 @@ void Cursor_SetPosition(int x, int y) { CGDisplayMoveCursorToPoint(CGMainDisplayID(), point); } +static bool cursorVisible = true; void Cursor_SetVisible(bool visible) { if (visible) { CGDisplayShowCursor(CGMainDisplayID()); } else { CGDisplayHideCursor(CGMainDisplayID()); } + cursorVisible = visible; } void Window_ShowDialog(const char* title, const char* msg) { @@ -1933,7 +1935,12 @@ void Window_ShowDialog(const char* title, const char* msg) { CreateStandardAlert(kAlertPlainAlert, titleCF, msgCF, NULL, &dialog); CFRelease(titleCF); CFRelease(msgCF); + + /* If cursor is hidden, showing a dialog doesn't cause it to reappear */ + /* So just manually make the cursor reappear */ + if (!cursorVisible) CGDisplayShowCursor(CGMainDisplayID()); RunStandardAlert(dialog, NULL, &itemHit); + if (!cursorVisible) CGDisplayHideCursor(CGMainDisplayID()); } static CGrafPtr fb_port;