summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-30 22:40:04 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2013-05-30 23:03:21 +0200
commitbf21ed010211e3b3bd2585adabf2dd2c867e0754 (patch)
treec6705094acdb9d868e48d981163c7f746fb140dd /video
parent68c3e2aabbff7cb057dc31834d40f9a90fed4b31 (diff)
downloadmpv-bf21ed010211e3b3bd2585adabf2dd2c867e0754.tar.bz2
mpv-bf21ed010211e3b3bd2585adabf2dd2c867e0754.tar.xz
cocoa_common: fix mouse hiding outside of player view
This bug was the result of crappy position detection in the previous code combined with the commits moving autohide delay out of the cocoa backend and into the core. The hit detection was improved and now takes also account of interactions with the Dock and Menubar. Moreover VOCTRL_SET_CURSOR_VISIBILITY now has an effect only if the mouse position matches with this improved hit detection. This means that both interaction with the Dock and Menubar are considered as well as moving the mouse inside another screen.
Diffstat (limited to 'video')
-rw-r--r--video/out/cocoa_common.m30
1 files changed, 21 insertions, 9 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index ace63679b2..6a0836ad1e 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -69,6 +69,7 @@ static bool RightAltPressed(NSEvent *event)
@interface GLMPlayerOpenGLView : NSView
@property(nonatomic, assign) struct vo *videoOutput;
+- (BOOL)containsCurrentMouseLocation;
- (void)mouseEvent:(NSEvent *)theEvent;
@end
@@ -572,6 +573,8 @@ void vo_cocoa_fullscreen(struct vo *vo)
int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
{
+ struct vo_cocoa_state *s = vo->cocoa;
+
switch (request) {
case VOCTRL_CHECK_EVENTS:
*events |= vo_cocoa_check_events(vo);
@@ -588,7 +591,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg)
return VO_TRUE;
case VOCTRL_SET_CURSOR_VISIBILITY: {
bool visible = *(bool *)arg;
- if (vo->opts->fs)
+ if (vo->opts->fs && [s->view containsCurrentMouseLocation])
vo_cocoa_set_cursor_visibility(visible);
return VO_TRUE;
}
@@ -668,7 +671,7 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
NSFullScreenModeAllScreens :
@NO,
NSFullScreenModeApplicationPresentationOptions :
- @(NSApplicationPresentationHideDock |
+ @(NSApplicationPresentationAutoHideDock |
NSApplicationPresentationAutoHideMenuBar)
};
@@ -849,15 +852,24 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
}
}
-- (void)signalMouseMovement:(NSEvent *)theEvent
+- (NSPoint) mouseLocation
{
- NSPoint loc = [self convertPoint:[theEvent locationInWindow] fromView:nil];
- NSRect bounds = [self bounds];
+ NSPoint mLoc = [NSEvent mouseLocation];
+ NSPoint wLoc = [self.window convertScreenToBase:mLoc];
+ return [self convertPoint:wLoc fromView:nil];
+}
- int x = loc.x;
- int y = - loc.y + bounds.size.height; // convert to x11-like coord system
- if (CGRectContainsPoint(bounds, NSMakePoint(x, y))) {
- vo_mouse_movement(self.videoOutput, x, y);
+- (BOOL)containsCurrentMouseLocation
+{
+ return CGRectContainsPoint([self bounds], [self mouseLocation]);
+}
+
+- (void)signalMouseMovement:(NSEvent *)event
+{
+ if ([self containsCurrentMouseLocation]) {
+ NSPoint loc = [self mouseLocation];
+ loc.y = - loc.y + [self bounds].size.height;
+ vo_mouse_movement(self.videoOutput, loc.x, loc.y);
}
}