From 12ae2973ae876b54c03ac966244f64c0ea7eb358 Mon Sep 17 00:00:00 2001 From: LD Date: Tue, 31 May 2022 21:17:11 +0200 Subject: [PATCH] cocoadisplay: Disable the event suppression interval when moving the position of the mouse pointer --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 747951108f..90699ef26d 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -145,9 +145,11 @@ move_pointer(int device, int x, int y) { y + _properties.get_y_origin()); } - // I don't know what the difference between these two methods is. if - // (CGWarpMouseCursorPosition(point) == kCGErrorSuccess) { - if (CGDisplayMoveCursorToPoint(_display, point) == kCGErrorSuccess) { + if (CGWarpMouseCursorPosition(point) == kCGErrorSuccess) { + //After moving (or warping) the mouse position, CG starts an event + // suppression interval during which no more mouse events can occur + // This interval can be interupted by the following call : + CGAssociateMouseAndMouseCursorPosition(YES); // Generate a mouse event. NSPoint pos = [_window mouseLocationOutsideOfEventStream]; NSPoint loc = [_view convertPoint:pos fromView:nil]; @@ -1991,6 +1993,10 @@ handle_mouse_moved_event(bool in_window, double x, double y, bool absolute) { } if (CGWarpMouseCursorPosition(point) == kCGErrorSuccess) { + //After moving (or warping) the mouse position, CG starts an event + // suppression interval during which no more mouse events can occur + // This interval can be interupted by the following call : + CGAssociateMouseAndMouseCursorPosition(YES); in_window = true; } else { cocoadisplay_cat.warning() << "Failed to return mouse pointer to window\n";