mirror of
https://github.com/mpv-player/mpv
synced 2024-10-26 07:22:17 +02:00
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.
This commit is contained in:
parent
f4dcb93be1
commit
57571b5da3
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user