app: [macOS] don't miss pointer presses

We used to track the pressed pointer buttons through the global function
[NSEvent pressedMouseButtons]. However, it's possible that at the time a pointer
press event is delivered, the pointer button is up again. To ensure a consistent
view of the pointer press state, track it through the buttonNumber property on
delivered events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-07-26 11:47:05 +02:00
parent fc5689ea44
commit 0f51cb9084
2 changed files with 15 additions and 15 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ static void handleMouse(NSView *view, NSEvent *event, int typ, CGFloat dx, CGFlo
}
// Origin is in the lower left corner. Convert to upper left.
CGFloat height = view.bounds.size.height;
gio_onMouse((__bridge CFTypeRef)view, (__bridge CFTypeRef)event, typ, [NSEvent pressedMouseButtons], p.x, height - p.y, dx, dy, [event timestamp], [event modifierFlags]);
gio_onMouse((__bridge CFTypeRef)view, (__bridge CFTypeRef)event, typ, event.buttonNumber, p.x, height - p.y, dx, dy, [event timestamp], [event modifierFlags]);
}
@interface GioView : NSView <CALayerDelegate,NSTextInputClient>