]> git.sesse.net Git - vlc/commitdiff
macosx: only hide dock and menu bar when necessary
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sun, 18 Nov 2012 10:59:58 +0000 (11:59 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sun, 18 Nov 2012 12:21:39 +0000 (13:21 +0100)
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

modules/gui/macosx/Windows.m
modules/gui/macosx/misc.h
modules/gui/macosx/misc.m

index 6973b1d8c0fb4e814cef33de0ef67c7cd33105f7..67ab5d063319f6b25dfdfd454c8de86fcb47b42d 100644 (file)
                 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]];
         [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];
index 3520d3cde93dc2d7067e2948ba3f4dbec868bce9..9d9767c7deec3efbbe7919b0398192dc4960ba6a 100644 (file)
@@ -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;
index 6c03a3b8869350059875c75893537d807b9da6db..ab6cbb54022adc1a8d7f205df9a74efa75cf01aa 100644 (file)
@@ -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];
     }
 }