Browse Source

cocoadisplay: Disable the event suppression interval when moving the position of the mouse pointer

LD 3 years ago
parent
commit
12ae2973ae
1 changed files with 9 additions and 3 deletions
  1. 9 3
      panda/src/cocoadisplay/cocoaGraphicsWindow.mm

+ 9 - 3
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";