summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkemi <der.richter@gmx.de>2017-02-19 03:25:32 +0100
committerAkemi <der.richter@gmx.de>2017-02-19 17:54:06 +0100
commit4f74b935468fd8b39d4cf974892fa242bb059248 (patch)
treef0135410d194443bd4fef30354145302674f8919
parentd45074455a6141f3bfa9f5551d508c3a7fdc1a3f (diff)
downloadmpv-4f74b935468fd8b39d4cf974892fa242bb059248.tar.bz2
mpv-4f74b935468fd8b39d4cf974892fa242bb059248.tar.xz
cocoa: fix cursor hiding at the top of the screen in fullscreen
even before the recent refactor the cursor was hidden when moving it to the top of the screen in fullscreen and placing it on top of the now visible menu bar. we need to know when the menu bar is hidden so we don’t create a ‘dead zone’ at the top of the screen where the cursor can’t be hidden. to determine when the menu bar is visible, and with that the title bar, we get the height of the menu bar. the height is always 0 when hidden. furthermore there is no way to get the title bar directly and with that its height. so we calculate the frame rect of a NSWindowStyleMaskTitled window from a CGRectZero content frame. the resulting height is the height of a title bar. with that we can exclude the top area for the cursor hiding and can be certain when the menu bar is not hidden.
-rw-r--r--video/out/cocoa/events_view.m12
1 files changed, 12 insertions, 0 deletions
diff --git a/video/out/cocoa/events_view.m b/video/out/cocoa/events_view.m
index eda4781418..8be74d5e15 100644
--- a/video/out/cocoa/events_view.m
+++ b/video/out/cocoa/events_view.m
@@ -86,7 +86,19 @@
- (BOOL)containsMouseLocation
{
+ CGFloat topMargin = 0.0;
+ CGFloat menuBarHeight = [[NSApp mainMenu] menuBarHeight];
+
+ // menuBarHeight is 0 when menu bar is hidden in fullscreen
+ // 1pt to compensate of the black line beneath the menu bar
+ if ([self.adapter isInFullScreenMode] && menuBarHeight > 0) {
+ NSRect tr = [NSWindow frameRectForContentRect:CGRectZero
+ styleMask:NSWindowStyleMaskTitled];
+ topMargin = tr.size.height + 1 + menuBarHeight;
+ }
+
NSRect vF = [[self.window screen] frame];
+ vF.size.height -= topMargin;
NSRect vFW = [self.window convertRectFromScreen:vF];
NSRect vFV = [self convertRect:vFW fromView:nil];
NSPoint pt = [self convertPoint:[self mouseLocation] fromView:nil];