mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
[macOS] Ignore mouse move event caused by mouse mode switch.
This commit is contained in:
parent
b9aa2d0dfb
commit
d756f6a294
@ -93,6 +93,7 @@ public:
|
||||
|
||||
List<WarpEvent> warp_events;
|
||||
NSTimeInterval last_warp = 0;
|
||||
bool ignore_warp = false;
|
||||
|
||||
Vector<KeyEvent> key_event_buffer;
|
||||
int key_event_pos;
|
||||
|
@ -871,6 +871,15 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, i
|
||||
NSPoint delta = NSMakePoint([event deltaX], [event deltaY]);
|
||||
NSPoint mpos = [event locationInWindow];
|
||||
|
||||
if (DS_OSX->ignore_warp) {
|
||||
// Discard late events, before warp
|
||||
if (([event timestamp]) < DS_OSX->last_warp) {
|
||||
return;
|
||||
}
|
||||
DS_OSX->ignore_warp = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (DS_OSX->mouse_mode == DisplayServer::MOUSE_MODE_CONFINED) {
|
||||
// Discard late events
|
||||
if (([event timestamp]) < DS_OSX->last_warp) {
|
||||
@ -2098,6 +2107,8 @@ void DisplayServerOSX::mouse_set_mode(MouseMode p_mode) {
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
}
|
||||
|
||||
last_warp = [[NSProcessInfo processInfo] systemUptime];
|
||||
ignore_warp = true;
|
||||
warp_events.clear();
|
||||
mouse_mode = p_mode;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user