Commit 784f47a2 authored by David Fuhrmann's avatar David Fuhrmann

macosx: only hide dock and menu bar when necessary

Please note: For whatever reason, Cocoa only allows to hide the menu bar
when we also hide the dock. On the other hand, the dock can be hidden while
the menu bar stays visible.

close #4681
parent 00c4f687
......@@ -578,8 +578,12 @@
CGDisplayFade(token, 0.5, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
}
if ([screen mainScreen])
[NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
if ([screen hasMenuBar])
presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
if ([screen hasMenuBar] || [screen hasDock])
presentationOpts |= NSApplicationPresentationAutoHideDock;
[NSApp setPresentationOptions:presentationOpts];
[[o_video_view superview] replaceSubview:o_video_view with:o_temp_view];
[o_temp_view setFrame:[o_video_view frame]];
......@@ -629,8 +633,12 @@
[o_fullscreen_anim2 release];
}
if ([screen mainScreen])
[NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
if ([screen hasMenuBar])
presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
if ([screen hasMenuBar] || [screen hasDock])
presentationOpts |= NSApplicationPresentationAutoHideDock;
[NSApp setPresentationOptions:presentationOpts];
dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
......
......@@ -58,9 +58,9 @@
@interface NSScreen (VLCAdditions)
@property (readonly) BOOL mainScreen;
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID;
- (BOOL)hasMenuBar;
- (BOOL)hasDock;
- (BOOL)isScreen: (NSScreen*)screen;
- (CGDirectDisplayID)displayID;
- (void)blackoutOtherScreens;
......
......@@ -183,11 +183,26 @@ static NSMutableArray *blackoutWindows = NULL;
return nil;
}
- (BOOL)mainScreen
- (BOOL)hasMenuBar
{
return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
}
- (BOOL)hasDock
{
NSRect screen_frame = [self frame];
NSRect screen_visible_frame = [self visibleFrame];
CGFloat f_menu_bar_thickness = [self hasMenuBar] ? [[NSStatusBar systemStatusBar] thickness] : 0.0;
BOOL b_found_dock = NO;
if (screen_visible_frame.size.width < screen_frame.size.width)
b_found_dock = YES;
else if (screen_visible_frame.size.height + f_menu_bar_thickness < screen_frame.size.height)
b_found_dock = YES;
return b_found_dock;
}
- (BOOL)isScreen: (NSScreen*)screen
{
return ([self displayID] == [screen displayID]);
......@@ -231,8 +246,12 @@ static NSMutableArray *blackoutWindows = NULL;
[blackoutWindows addObject: blackoutWindow];
[blackoutWindow release];
if ( [screen mainScreen] )
[NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
NSApplicationPresentationOptions presentationOpts = [NSApp presentationOptions];
if ([screen hasMenuBar])
presentationOpts |= NSApplicationPresentationAutoHideMenuBar;
if ([screen hasMenuBar] || [screen hasDock])
presentationOpts |= NSApplicationPresentationAutoHideDock;
[NSApp setPresentationOptions:presentationOpts];
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment