[vlc-commits] [Git][videolan/vlc][master] 4 commits: macosx: Extract contents of mouseExited in VLCTrackingView to separate method
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Sun May 7 09:43:15 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
99d86383 by Claudio Cambra at 2023-05-07T09:28:11+00:00
macosx: Extract contents of mouseExited in VLCTrackingView to separate method
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
30005195 by Claudio Cambra at 2023-05-07T09:28:11+00:00
macosx: Extract contents of mouseEntered in VLCTrackingView to separate method
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
ea7774a2 by Claudio Cambra at 2023-05-07T09:28:11+00:00
macosx: Store whether cursor is inside VLCTrackingView or not
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
49ade81d by Claudio Cambra at 2023-05-07T09:28:11+00:00
macosx: Check if mouse is still within VLCTrackingArea once the tracking area is updated
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
1 changed file:
- modules/gui/macosx/views/VLCTrackingView.m
Changes:
=====================================
modules/gui/macosx/views/VLCTrackingView.m
=====================================
@@ -25,13 +25,16 @@
@interface VLCTrackingView ()
{
NSTrackingArea *_trackingArea;
+ BOOL _mouseIn;
}
@end
@implementation VLCTrackingView
-- (void)mouseExited:(NSEvent *)event
+- (void)handleMouseExit
{
+ _mouseIn = NO;
+
if (self.animatesTransition) {
[self.viewToHide setAlphaValue:1.0];
[self.viewToShow setAlphaValue:.0];
@@ -53,8 +56,10 @@
}
}
-- (void)mouseEntered:(NSEvent *)event
+- (void)handleMouseEnter
{
+ _mouseIn = YES;
+
if (self.animatesTransition) {
[self.viewToHide setAlphaValue:.0];
[self.viewToHide setHidden:NO];
@@ -75,6 +80,16 @@
}
}
+- (void)mouseExited:(NSEvent *)event
+{
+ [self handleMouseExit];
+}
+
+- (void)mouseEntered:(NSEvent *)event
+{
+ [self handleMouseEnter];
+}
+
- (void)updateTrackingAreas
{
[super updateTrackingAreas];
@@ -88,6 +103,18 @@
owner:self
userInfo:nil];
[self addTrackingArea:_trackingArea];
+
+ // Once tracking area updated, check if the cursor is still inside the tracking view.
+ // This prevents situations where the mouseEntered/mouseExited is not called because the view
+ // itself has moved but the cursor has not (e.g. when this view is inside a scrollview and the
+ // user scrolls)
+ const NSPoint mouseLocation = [self convertPoint:self.window.mouseLocationOutsideOfEventStream fromView:self.window.contentView];
+ const BOOL mouseInsideView = [self mouse:mouseLocation inRect:self.frame];
+ if (mouseInsideView && !_mouseIn) {
+ [self handleMouseEnter];
+ } else if (!mouseInsideView && _mouseIn) {
+ [self handleMouseExit];
+ }
}
@end
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c6d6da2dbe27e8a3666386772628f3afabfb5e9a...49ade81d6c71ae4dbea2e5067f2cde5fdeec787b
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/c6d6da2dbe27e8a3666386772628f3afabfb5e9a...49ade81d6c71ae4dbea2e5067f2cde5fdeec787b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list