diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-06-01 22:52:21 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-06-01 22:52:21 +0200 |
commit | 57571b5da3dde82816f5ed7f4371dd7670e55565 (patch) | |
tree | 3c3b05bde4a51cbc2966d8b770ee20e6ce48da0a /video | |
parent | f4dcb93be1ff35ebbaa03baf8e37976d2a622eb1 (diff) | |
download | mpv-57571b5da3dde82816f5ed7f4371dd7670e55565.tar.bz2 mpv-57571b5da3dde82816f5ed7f4371dd7670e55565.tar.xz |
cocoa_common: autohide dock/menubar on fs only if on same screen
Autohide the menubar and/or dock only if they are present in the screen the
player is going to go fullscreen into. I thought the GUI would handle this for
me when I switched 0057aa476 but lack of hardware to test made me embarass
myself yet again.
I reimplemented this feature with nicer code and behaviour. The code checks
separately wether to hide menubar and dock separatly, while the old code used
a single check possibly hiding stuff without need.
Added the key checks as a some category additions to NSScreen for readability.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/cocoa_common.m | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index d74f508523..28dbf58923 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -74,6 +74,11 @@ static bool RightAltPressed(NSEvent *event) @property(nonatomic, assign, getter=hasMouseDown) BOOL mouseDown; @end +@interface NSScreen (mpvadditions) +- (BOOL)hasDock; +- (BOOL)hasMenubar; +@end + struct vo_cocoa_input_queue { NSMutableArray *fifo; }; @@ -686,14 +691,19 @@ int vo_cocoa_cgl_color_size(struct vo *vo) struct vo_cocoa_state *s = self.videoOutput->cocoa; if (willBeFullscreen) { + NSApplicationPresentationOptions popts = + NSApplicationPresentationDefault; + + if ([s->fs_screen hasMenubar]) + popts |= NSApplicationPresentationAutoHideMenuBar; + + if ([s->fs_screen hasDock]) + popts |= NSApplicationPresentationAutoHideDock; + NSDictionary *fsopts = @{ - NSFullScreenModeWindowLevel : - @(NSFloatingWindowLevel), - NSFullScreenModeAllScreens : - @NO, - NSFullScreenModeApplicationPresentationOptions : - @(NSApplicationPresentationAutoHideDock | - NSApplicationPresentationAutoHideMenuBar) + NSFullScreenModeWindowLevel : @(NSFloatingWindowLevel), + NSFullScreenModeAllScreens : @NO, + NSFullScreenModeApplicationPresentationOptions : @(popts) }; [s->view enterFullScreenMode:s->fs_screen withOptions:fsopts]; @@ -999,3 +1009,23 @@ int vo_cocoa_cgl_color_size(struct vo *vo) } } @end + +@implementation NSScreen (mpvadditions) +- (BOOL)hasDock +{ + NSRect vF = [self visibleFrame]; + NSRect f = [self frame]; + return + // The visible frame's width is smaller: dock is on left or right end + // of this method's receiver. + vF.size.width < f.size.width || + // The visible frame's veritical origin is bigger is smaller: dock is + // on the bottom of this method's receiver. + vF.origin.y > f.origin.y; + +} +- (BOOL)hasMenubar +{ + return [self isEqual: [NSScreen screens][0]]; +} +@end |