From d3aa22ac12e3322c561ab3140e1105e4fa1214c1 Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 29 Jun 2014 16:10:12 -0300 Subject: [PATCH] Mac OS X: Hide native mouse cursor (related to issue 350) --- src/allegro/src/macosx/qzmouse.m | 4 +++- src/allegro/src/macosx/system.m | 15 ++++++++++++--- src/allegro/src/mouse.c | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/allegro/src/macosx/qzmouse.m b/src/allegro/src/macosx/qzmouse.m index a8879bbab..18ed987d8 100644 --- a/src/allegro/src/macosx/qzmouse.m +++ b/src/allegro/src/macosx/qzmouse.m @@ -178,6 +178,9 @@ static int osx_mouse_init(void) osx_emulate_mouse_buttons = (max_buttons == 1) ? TRUE : FALSE; _unix_unlock_mutex(osx_event_mutex); + _mouse_on = TRUE; + [NSCursor performSelectorOnMainThread: @selector(hide) withObject: nil waitUntilDone: NO]; + return max_buttons; } @@ -344,7 +347,6 @@ int osx_mouse_show(BITMAP *bmp, int x, int y) return -1; osx_change_cursor(requested_cursor); - return 0; } diff --git a/src/allegro/src/macosx/system.m b/src/allegro/src/macosx/system.m index 858f18260..3425d7575 100644 --- a/src/allegro/src/macosx/system.m +++ b/src/allegro/src/macosx/system.m @@ -223,7 +223,10 @@ void osx_event_handler() mx = point.x; my = frame.size.height - point.y; buttons = 0; - _mouse_on = TRUE; + if (!_mouse_on) { + _mouse_on = TRUE; + [NSCursor performSelectorOnMainThread: @selector(hide) withObject: nil waitUntilDone: NO]; + } } } if (osx_window) @@ -292,8 +295,11 @@ void osx_event_handler() mx = point.x; my = frame.size.height - point.y; buttons = 0; - _mouse_on = TRUE; gotmouseevent = YES; + if (!_mouse_on) { + _mouse_on = TRUE; + [NSCursor performSelectorOnMainThread: @selector(hide) withObject: nil waitUntilDone: NO]; + } } } [NSApp sendEvent: event]; @@ -302,8 +308,11 @@ void osx_event_handler() case NSMouseExited: if ([event trackingNumber] == osx_mouse_tracking_rect) { if (_mouse_installed) { - _mouse_on = FALSE; gotmouseevent = YES; + if (_mouse_on) { + _mouse_on = FALSE; + [NSCursor performSelectorOnMainThread: @selector(unhide) withObject: nil waitUntilDone: NO]; + } } } [NSApp sendEvent: event]; diff --git a/src/allegro/src/mouse.c b/src/allegro/src/mouse.c index 46780cce8..dd7519ece 100644 --- a/src/allegro/src/mouse.c +++ b/src/allegro/src/mouse.c @@ -56,7 +56,7 @@ int _mouse_y = 0; int _mouse_z = 0; int _mouse_w = 0; int _mouse_b = 0; -int _mouse_on = TRUE; +int _mouse_on = FALSE; static int mon = TRUE;