mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 12:44:53 +00:00
Fix more OS X cursor issues
Fixed problems with a hidden mouse cursor when we activated Aseprite window from other windows, or from the Mission Control, or with Cmd+Alt.
This commit is contained in:
parent
13fc8e03d2
commit
51061894de
@ -153,6 +153,46 @@ static RETSIGTYPE osx_signal_handler(int num)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL handle_mouse_enter(
|
||||||
|
NSRect frame, NSRect view, NSPoint point,
|
||||||
|
int* mx, int* my, int* buttons)
|
||||||
|
{
|
||||||
|
if (_mouse_installed && !_mouse_on &&
|
||||||
|
(osx_window) && (NSPointInRect(point, view))) {
|
||||||
|
*mx = point.x;
|
||||||
|
*my = frame.size.height - point.y;
|
||||||
|
*buttons = 0;
|
||||||
|
|
||||||
|
_mouse_on = TRUE;
|
||||||
|
osx_hide_native_mouse();
|
||||||
|
if (osx_mouse_enter_callback)
|
||||||
|
osx_mouse_enter_callback();
|
||||||
|
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static BOOL handle_mouse_leave()
|
||||||
|
{
|
||||||
|
if (_mouse_installed) {
|
||||||
|
if (_mouse_on) {
|
||||||
|
_mouse_on = FALSE;
|
||||||
|
osx_show_native_mouse();
|
||||||
|
if (osx_mouse_leave_callback)
|
||||||
|
osx_mouse_leave_callback();
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* osx_event_handler:
|
/* osx_event_handler:
|
||||||
* Event handling function; gets repeatedly called inside a dedicated thread.
|
* Event handling function; gets repeatedly called inside a dedicated thread.
|
||||||
*/
|
*/
|
||||||
@ -164,8 +204,8 @@ void osx_event_handler()
|
|||||||
NSPoint point;
|
NSPoint point;
|
||||||
NSRect frame, view;
|
NSRect frame, view;
|
||||||
int dx = 0, dy = 0, dz = 0;
|
int dx = 0, dy = 0, dz = 0;
|
||||||
int mx=_mouse_x;
|
int mx = _mouse_x;
|
||||||
int my=_mouse_y;
|
int my = _mouse_y;
|
||||||
static int buttons = 0;
|
static int buttons = 0;
|
||||||
int event_type;
|
int event_type;
|
||||||
BOOL gotmouseevent = NO;
|
BOOL gotmouseevent = NO;
|
||||||
@ -225,19 +265,10 @@ void osx_event_handler()
|
|||||||
case NSLeftMouseDown:
|
case NSLeftMouseDown:
|
||||||
case NSOtherMouseDown:
|
case NSOtherMouseDown:
|
||||||
case NSRightMouseDown:
|
case NSRightMouseDown:
|
||||||
|
/* App is regaining focus */
|
||||||
if (![NSApp isActive]) {
|
if (![NSApp isActive]) {
|
||||||
/* App is regaining focus */
|
handle_mouse_enter(frame, view, point, &mx, &my, &buttons);
|
||||||
if (_mouse_installed) {
|
|
||||||
if ((osx_window) && (NSPointInRect(point, view))) {
|
|
||||||
mx = point.x;
|
|
||||||
my = frame.size.height - point.y;
|
|
||||||
buttons = 0;
|
|
||||||
if (!_mouse_on) {
|
|
||||||
_mouse_on = TRUE;
|
|
||||||
osx_hide_native_mouse();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (osx_window)
|
if (osx_window)
|
||||||
[osx_window invalidateCursorRectsForView: [osx_window contentView]];
|
[osx_window invalidateCursorRectsForView: [osx_window contentView]];
|
||||||
if (_keyboard_installed)
|
if (_keyboard_installed)
|
||||||
@ -259,6 +290,9 @@ void osx_event_handler()
|
|||||||
case NSLeftMouseUp:
|
case NSLeftMouseUp:
|
||||||
case NSOtherMouseUp:
|
case NSOtherMouseUp:
|
||||||
case NSRightMouseUp:
|
case NSRightMouseUp:
|
||||||
|
if ([NSApp isActive])
|
||||||
|
handle_mouse_enter(frame, view, point, &mx, &my, &buttons);
|
||||||
|
|
||||||
buttons &= ~((event_type == NSLeftMouseUp) ? 0x1 : 0);
|
buttons &= ~((event_type == NSLeftMouseUp) ? 0x1 : 0);
|
||||||
buttons &= ~((event_type == NSRightMouseUp) ? 0x2 : 0);
|
buttons &= ~((event_type == NSRightMouseUp) ? 0x2 : 0);
|
||||||
buttons &= ~((event_type == NSOtherMouseUp) ? 0x4 : 0);
|
buttons &= ~((event_type == NSOtherMouseUp) ? 0x4 : 0);
|
||||||
@ -271,11 +305,14 @@ void osx_event_handler()
|
|||||||
case NSRightMouseDragged:
|
case NSRightMouseDragged:
|
||||||
case NSOtherMouseDragged:
|
case NSOtherMouseDragged:
|
||||||
case NSMouseMoved:
|
case NSMouseMoved:
|
||||||
|
if ([NSApp isActive])
|
||||||
|
handle_mouse_enter(frame, view, point, &mx, &my, &buttons);
|
||||||
|
|
||||||
dx += [event deltaX];
|
dx += [event deltaX];
|
||||||
dy += [event deltaY];
|
dy += [event deltaY];
|
||||||
|
|
||||||
mx=point.x;
|
mx = point.x;
|
||||||
my=frame.size.height-point.y;
|
my = frame.size.height - point.y;
|
||||||
|
|
||||||
[NSApp sendEvent: event];
|
[NSApp sendEvent: event];
|
||||||
gotmouseevent = YES;
|
gotmouseevent = YES;
|
||||||
@ -288,35 +325,16 @@ void osx_event_handler()
|
|||||||
|
|
||||||
case NSMouseEntered:
|
case NSMouseEntered:
|
||||||
if (([event trackingNumber] == osx_mouse_tracking_rect) && ([NSApp isActive])) {
|
if (([event trackingNumber] == osx_mouse_tracking_rect) && ([NSApp isActive])) {
|
||||||
if (_mouse_installed) {
|
if (handle_mouse_enter(frame, view, point, &mx, &my, &buttons))
|
||||||
mx = point.x;
|
|
||||||
my = frame.size.height - point.y;
|
|
||||||
buttons = 0;
|
|
||||||
gotmouseevent = YES;
|
gotmouseevent = YES;
|
||||||
if (!_mouse_on) {
|
|
||||||
_mouse_on = TRUE;
|
|
||||||
osx_hide_native_mouse();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (osx_mouse_enter_callback)
|
|
||||||
osx_mouse_enter_callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[NSApp sendEvent: event];
|
[NSApp sendEvent: event];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSMouseExited:
|
case NSMouseExited:
|
||||||
if ([event trackingNumber] == osx_mouse_tracking_rect) {
|
if ([event trackingNumber] == osx_mouse_tracking_rect) {
|
||||||
if (_mouse_installed) {
|
if (handle_mouse_leave())
|
||||||
gotmouseevent = YES;
|
gotmouseevent = YES;
|
||||||
if (_mouse_on) {
|
|
||||||
_mouse_on = FALSE;
|
|
||||||
osx_show_native_mouse();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (osx_mouse_leave_callback)
|
|
||||||
osx_mouse_leave_callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
[NSApp sendEvent: event];
|
[NSApp sendEvent: event];
|
||||||
break;
|
break;
|
||||||
@ -328,6 +346,8 @@ void osx_event_handler()
|
|||||||
[osx_window invalidateCursorRectsForView: [osx_window contentView]];
|
[osx_window invalidateCursorRectsForView: [osx_window contentView]];
|
||||||
if (_keyboard_installed)
|
if (_keyboard_installed)
|
||||||
osx_keyboard_focused(TRUE, 0);
|
osx_keyboard_focused(TRUE, 0);
|
||||||
|
|
||||||
|
handle_mouse_enter(frame, view, point, &mx, &my, &buttons);
|
||||||
}
|
}
|
||||||
_switch_in();
|
_switch_in();
|
||||||
break;
|
break;
|
||||||
@ -335,6 +355,7 @@ void osx_event_handler()
|
|||||||
case NSApplicationDeactivatedEventType:
|
case NSApplicationDeactivatedEventType:
|
||||||
if (osx_window && _keyboard_installed)
|
if (osx_window && _keyboard_installed)
|
||||||
osx_keyboard_focused(FALSE, 0);
|
osx_keyboard_focused(FALSE, 0);
|
||||||
|
handle_mouse_leave();
|
||||||
_switch_out();
|
_switch_out();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user