]> git.sesse.net Git - vlc/commitdiff
macosx: add lion fullscreen support for detached windows
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Fri, 8 Feb 2013 17:48:44 +0000 (18:48 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sat, 9 Feb 2013 17:44:38 +0000 (18:44 +0100)
modules/gui/macosx/ControlsBar.m
modules/gui/macosx/MainWindow.h
modules/gui/macosx/MainWindow.m
modules/gui/macosx/MainWindowTitle.m
modules/gui/macosx/VLCVoutWindowController.h
modules/gui/macosx/VLCVoutWindowController.m
modules/gui/macosx/Windows.h
modules/gui/macosx/Windows.m
modules/gui/macosx/intf.m

index 7bb9da369629cdbc7f98d280ed76d03004077faa..481e08d635b4e25b6a2e22167d9b1992c41b8737 100644 (file)
     if ([[o_bottombar_view window] styleMask] & NSResizableWindowMask)
         [o_resize_view removeFromSuperviewWithoutNeedingDisplay];
 
+    
+    // remove fullscreen button for lion fullscreen
+    if (b_nativeFullscreenMode) {
+        float f_width = [o_fullscreen_btn frame].size.width;
+
+        NSRect frame = [o_time_fld frame];
+        frame.origin.x += f_width;
+        [o_time_fld setFrame: frame];
+
+        frame = [o_progress_view frame];
+        frame.size.width = f_width + frame.size.width;
+        [o_progress_view setFrame: frame];
+
+        [o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
+    }
+
 }
 
 #pragma mark -
 {
     [super awakeFromNib];
 
+
     [o_stop_btn setToolTip: _NS("Stop")];
     [[o_stop_btn cell] accessibilitySetOverrideValue:_NS("Click to stop playback.") forAttribute:NSAccessibilityDescriptionAttribute];
     [[o_stop_btn cell] accessibilitySetOverrideValue:[o_stop_btn toolTip] forAttribute:NSAccessibilityTitleAttribute];
     [o_volume_sld setEnabled: b_mute];
     [o_volume_up_btn setEnabled: b_mute];
 
+
     // remove fullscreen button for lion fullscreen
     if (b_nativeFullscreenMode) {
         NSRect frame;
-        float f_width = [o_fullscreen_btn frame].size.width;
 
+        // == [o_fullscreen_btn frame].size.width;
+        // button is already removed!
+        float f_width = 29.;
 #define moveItem(item) \
 frame = [item frame]; \
 frame.origin.x = f_width + frame.origin.x; \
@@ -499,15 +519,11 @@ frame.origin.x = f_width + frame.origin.x; \
         moveItem(o_volume_sld);
         moveItem(o_volume_track_view);
         moveItem(o_volume_down_btn);
-        moveItem(o_time_fld);
 #undef moveItem
 
-        frame = [o_progress_view frame];
-        frame.size.width = f_width + frame.size.width;
-        [o_progress_view setFrame: frame];
-
-        [o_fullscreen_btn removeFromSuperviewWithoutNeedingDisplay];
+        // time field and progress bar are moved in super method!
     }
+    
 
     b_show_jump_buttons = config_GetInt(VLCIntf, "macosx-show-playback-buttons");
     if (b_show_jump_buttons)
@@ -518,6 +534,7 @@ frame.origin.x = f_width + frame.origin.x; \
         [self removePlaymodeButtons:YES];
 
     [[VLCMain sharedInstance] playbackModeUpdated];
+
 }
 
 #pragma mark -
index a5192c93fdeb8ee422711f7348542229fef51dbb..a2f59c26ea5d4d1f5ce905728d42b4944483ae7d 100644 (file)
 - (void)hideMouseCursor:(NSTimer *)timer;
 - (void)recreateHideMouseTimer;
 
-/* lion's native fullscreen handling */
-- (void)windowWillEnterFullScreen:(NSNotification *)notification;
-- (void)windowDidEnterFullScreen:(NSNotification *)notification;
-- (void)windowWillExitFullScreen:(NSNotification *)notification;
-
 @end
 
 @interface VLCDetachedVideoWindow : VLCVideoWindowCommon
index f0c69cd35747e928523392db195e22b109304a82..49c284487af74aca5930dbcf04d2b99bf4188c3a 100644 (file)
@@ -148,6 +148,9 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (void)awakeFromNib
 {
+    // sets lion fullscreen behaviour
+    [super awakeFromNib];
+
     BOOL b_splitviewShouldBeHidden = NO;
 
     /* setup the styled interface */
@@ -200,12 +203,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [o_dropzone_view setFrame: [o_playlist_table frame]];
     [o_left_split_view setFrame: [o_sidebar_view frame]];
 
-    if (b_nativeFullscreenMode) {
-        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
-    } else {
-        [o_titlebar_view setFullscreenButtonHidden: YES];
-    }
-
     if (!OSX_SNOW_LEOPARD) {
         /* the default small size of the search field is slightly different on Lion, let's work-around that */
         NSRect frame;
@@ -790,7 +787,23 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [NSCursor setHiddenUntilMouseMoves: YES];
 }
 
+#pragma mark -
+#pragma mark Lion native fullscreen handling
+- (void)windowWillEnterFullScreen:(NSNotification *)notification
+{
+    [super windowWillEnterFullScreen:notification];
 
+    // update split view frame after removing title bar
+    [o_split_view setFrame: [o_video_view frame]];
+}
+
+- (void)windowWillExitFullScreen:(NSNotification *)notification
+{
+    [super windowWillExitFullScreen: notification];
+
+    // update split view frame after readding title bar
+    [o_split_view setFrame: [o_video_view frame]];
+}
 #pragma mark -
 #pragma mark Fullscreen support
 
@@ -834,109 +847,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
     /* fullscreenAnimation will be unlocked when animation ends */
 }
 
-#pragma mark -
-#pragma mark Lion native fullscreen handling
-- (void)windowWillEnterFullScreen:(NSNotification *)notification
-{
-    // workaround, see #6668
-    [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
-
-    var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
-
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        var_SetBool(p_vout, "fullscreen", true);
-        vlc_object_release(p_vout);
-    }
-
-    [o_video_view setFrame: [[self contentView] frame]];
-    b_fullscreen = YES;
-
-    [self recreateHideMouseTimer];
-    i_originalLevel = [self level];
-    [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
-    [self setLevel:NSNormalWindowLevel];
-
-    if (b_dark_interface) {
-        [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
-
-        NSRect winrect;
-        CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
-        winrect = [self frame];
-
-        winrect.size.height = winrect.size.height - f_titleBarHeight;
-        [self setFrame: winrect display:NO animate:NO];
-        winrect = [o_split_view frame];
-        winrect.size.height = winrect.size.height + f_titleBarHeight;
-        [o_split_view setFrame: winrect];
-    }
-
-    if ([[VLCMain sharedInstance] activeVideoPlayback])
-        [[o_controls_bar bottomBarView] setHidden: YES];
-
-    [self setMovableByWindowBackground: NO];
-}
-
-- (void)windowDidEnterFullScreen:(NSNotification *)notification
-{
-    // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
-    // But this creates some problems when leaving fs over remote intfs, so activate app here.
-    [NSApp activateIgnoringOtherApps:YES];
-
-    [o_fspanel setVoutWasUpdated: self];
-    [o_fspanel setActive: nil];
-
-    NSArray *subviews = [[self videoView] subviews];
-    NSUInteger count = [subviews count];
-
-    for (NSUInteger x = 0; x < count; x++) {
-        if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
-            [[subviews objectAtIndex:x] reshape];
-    }
-
-}
-
-- (void)windowWillExitFullScreen:(NSNotification *)notification
-{
-    var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
-
-    vout_thread_t *p_vout = getVout();
-    if (p_vout) {
-        var_SetBool(p_vout, "fullscreen", false);
-        vlc_object_release(p_vout);
-    }
-
-    [o_video_view setFrame: [o_split_view frame]];
-    [NSCursor setHiddenUntilMouseMoves: NO];
-    [o_fspanel setNonActive: nil];
-    [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: i_originalLevel];
-    [self setLevel:i_originalLevel];
-
-    b_fullscreen = NO;
-
-    if (b_dark_interface) {
-        NSRect winrect;
-        CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
-        winrect = [self frame];
-
-        [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
-                                              winrect.size.width, f_titleBarHeight)];
-        [[self contentView] addSubview: o_titlebar_view];
-
-        winrect.size.height = winrect.size.height + f_titleBarHeight;
-        [self setFrame: winrect display:NO animate:NO];
-        winrect = [o_split_view frame];
-        winrect.size.height = winrect.size.height - f_titleBarHeight;
-        [o_split_view setFrame: winrect];
-        [o_video_view setFrame: winrect];
-    }
-
-    if ([[VLCMain sharedInstance] activeVideoPlayback])
-        [[o_controls_bar bottomBarView] setHidden: NO];
-
-    [self setMovableByWindowBackground: YES];
-}
-
 #pragma mark -
 #pragma mark split view delegate
 - (CGFloat)splitView:(NSSplitView *)splitView constrainMaxCoordinate:(CGFloat)proposedMax ofSubviewAt:(NSInteger)dividerIndex
@@ -1349,6 +1259,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (void)awakeFromNib
 {
+    // sets lion fullscreen behaviour
+    [super awakeFromNib];
     [self setAcceptsMouseMovedEvents: YES];
 
     if (b_dark_interface) {
@@ -1366,8 +1278,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
         [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight, winrect.size.width, f_titleBarHeight)];
         [[self contentView] addSubview: o_titlebar_view positioned: NSWindowAbove relativeTo: nil];
 
-        // native fs not supported with detached view yet
-        [o_titlebar_view setFullscreenButtonHidden: YES];
     } else {
         [self setBackgroundColor: [NSColor blackColor]];
     }
index fdb1551580810756937f2f369ee5f82f4d8ad0fd..2d923a854cf52a0b63ab388bc82b398904b5d896 100644 (file)
     else if (sender == o_green_btn)
         [[self window] performZoom: sender];
     else if (sender == o_fullscreen_btn) {
-        // set fs directly to true, as the vars can be already true in some configs
-        vout_thread_t *p_vout = getVout();
-        if (p_vout) {
-            var_SetBool(p_vout, "fullscreen", true);
-            vlc_object_release(p_vout);
-        } else { // e.g. lion fullscreen toggle
-            [[VLCMain sharedInstance] setFullscreen:true forWindow:nil];
-        }
+        // same action as native fs button
+        [[self window] toggleFullScreen:self];
 
     } else
         msg_Err(VLCIntf, "unknown button action sender");
index 3480914b25196071046497cb0002eb8a9186f624..bd149db3def3c3ef99d84b42585b087c9bd3cc75 100644 (file)
@@ -47,6 +47,7 @@
 - (void)removeVoutforDisplay:(NSValue *)o_key;
 
 - (void)updateWindowsControlsBarWithSelector:(SEL)aSel;
+- (VLCVideoWindowCommon *)getWindow:(vout_window_t *)p_wnd;
 - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater;
 
 - (void)updateWindow:(vout_window_t *)p_wnd withSelector:(SEL)aSel;
index a3df4f02fe29d536e4b8384696b079e78a002228..a23628f2b105ccd2685f68dc3f7fb36e8cebf397 100644 (file)
         [[VLCMainWindow sharedInstance] setNonembedded:YES];
         b_nonembedded = YES;
     } else {
-        if ((var_InheritBool(VLCIntf, "embedded-video") && !b_multiple_vout_windows) || b_nativeFullscreenMode) {
+        if ((var_InheritBool(VLCIntf, "embedded-video") && !b_multiple_vout_windows)) {
             // setup embedded video
             o_vout_view = [[[VLCMainWindow sharedInstance] videoView] retain];
             o_new_video_window = [[VLCMainWindow sharedInstance] retain];
     [o_window performSelector:aSel];
 }
 
+- (VLCVideoWindowCommon *)getWindow:(vout_window_t *)p_wnd
+{
+    VLCVideoWindowCommon *o_window = [o_vout_dict objectForKey:[NSValue valueWithPointer:p_wnd]];
+    assert(o_window);
+    return o_window;
+
+}
+
 - (void)updateWindowsUsingBlock:(void (^)(VLCVideoWindowCommon *o_window))windowUpdater
 {
     [o_vout_dict enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
index 47faa847d1c62111887d19aad2fb36d691850d78..460b38fa39a0e26ecd2e33e5fd50b2ae4daaefb5 100644 (file)
@@ -114,4 +114,9 @@ static const float f_min_video_height = 70.0;
 - (void)enterFullscreen;
 - (void)leaveFullscreen;
 
+/* lion fullscreen handling */
+- (void)windowWillEnterFullScreen:(NSNotification *)notification;
+- (void)windowDidEnterFullScreen:(NSNotification *)notification;
+- (void)windowWillExitFullScreen:(NSNotification *)notification;
+
 @end
index 957265bdc5cab12f5e2803a6c0d6382020e9ea1b..0a6d64e281200afbad243b52fb296b2b6b2b0424 100644 (file)
     [super dealloc];
 }
 
+- (void)awakeFromNib
+{
+    BOOL b_nativeFullscreenMode = NO;
+#ifdef MAC_OS_X_VERSION_10_7
+    if (!OSX_SNOW_LEOPARD)
+        b_nativeFullscreenMode = var_InheritBool(VLCIntf, "macosx-nativefullscreenmode");
+#endif
+
+    if (b_nativeFullscreenMode) {
+        [self setCollectionBehavior: NSWindowCollectionBehaviorFullScreenPrimary];
+    } else {
+        [o_titlebar_view setFullscreenButtonHidden: YES];
+    }
+
+    [super awakeFromNib];
+}
+
 - (void)setTitle:(NSString *)title
 {
     if (!title || [title length] < 1)
     return proposedFrameSize;
 }
 
+
+#pragma mark -
+#pragma mark Lion native fullscreen handling
+- (void)windowWillEnterFullScreen:(NSNotification *)notification
+{
+    // workaround, see #6668
+    [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
+
+    var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
+
+    vout_thread_t *p_vout = getVoutForActiveWindow();
+    if (p_vout) {
+        var_SetBool(p_vout, "fullscreen", true);
+        vlc_object_release(p_vout);
+    }
+
+    [o_video_view setFrame: [[self contentView] frame]];
+    [[VLCMainWindow sharedInstance] setFullscreen: YES];
+
+    [[VLCMainWindow sharedInstance] recreateHideMouseTimer];
+    i_originalLevel = [self level];
+    [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: NSNormalWindowLevel];
+    [self setLevel:NSNormalWindowLevel];
+
+    if (b_dark_interface) {
+        [o_titlebar_view removeFromSuperviewWithoutNeedingDisplay];
+
+        NSRect winrect;
+        CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
+        winrect = [self frame];
+
+        winrect.size.height = winrect.size.height - f_titleBarHeight;
+        [self setFrame: winrect display:NO animate:NO];
+    }
+
+    if ([[VLCMain sharedInstance] activeVideoPlayback])
+        [[o_controls_bar bottomBarView] setHidden: YES];
+
+    [self setMovableByWindowBackground: NO];
+}
+
+- (void)windowDidEnterFullScreen:(NSNotification *)notification
+{
+    // Indeed, we somehow can have an "inactive" fullscreen (but a visible window!).
+    // But this creates some problems when leaving fs over remote intfs, so activate app here.
+    [NSApp activateIgnoringOtherApps:YES];
+
+    
+    [[[VLCMainWindow sharedInstance] fsPanel] setVoutWasUpdated: self];
+    [[[VLCMainWindow sharedInstance] fsPanel] setActive: nil];
+
+    NSArray *subviews = [[self videoView] subviews];
+    NSUInteger count = [subviews count];
+
+    for (NSUInteger x = 0; x < count; x++) {
+        if ([[subviews objectAtIndex:x] respondsToSelector:@selector(reshape)])
+            [[subviews objectAtIndex:x] reshape];
+    }
+
+}
+
+- (void)windowWillExitFullScreen:(NSNotification *)notification
+{
+    var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
+
+    vout_thread_t *p_vout = getVoutForActiveWindow();
+    if (p_vout) {
+        var_SetBool(p_vout, "fullscreen", false);
+        vlc_object_release(p_vout);
+    }
+
+    [NSCursor setHiddenUntilMouseMoves: NO];
+    [[[VLCMainWindow sharedInstance] fsPanel] setNonActive: nil];
+    [[[VLCMain sharedInstance] voutController] updateWindowLevelForHelperWindows: i_originalLevel];
+    [self setLevel:i_originalLevel];
+
+    [[VLCMainWindow sharedInstance] setFullscreen: NO];
+
+    if (b_dark_interface) {
+        NSRect winrect;
+        CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
+        winrect = [self frame];
+
+        [o_titlebar_view setFrame: NSMakeRect(0, winrect.size.height - f_titleBarHeight,
+                                              winrect.size.width, f_titleBarHeight)];
+        [[self contentView] addSubview: o_titlebar_view];
+
+        winrect.size.height = winrect.size.height + f_titleBarHeight;
+        [self setFrame: winrect display:NO animate:NO];
+        winrect = [o_video_view frame];
+        winrect.size.height -= f_titleBarHeight;
+        [o_video_view setFrame: winrect];
+    }
+
+    NSRect videoViewFrame = [o_video_view frame];
+    videoViewFrame.origin.y = [[o_controls_bar bottomBarView] frame].size.height;
+    videoViewFrame.size.height -= [[o_controls_bar bottomBarView] frame].size.height;
+    [o_video_view setFrame: videoViewFrame];
+    [[o_controls_bar bottomBarView] setHidden: NO];
+    
+    [self setMovableByWindowBackground: YES];
+}
+
 #pragma mark -
 #pragma mark Fullscreen Logic
 
index 4607a16eae42216fa89ad198eac1d79a33ebc6df..a017ba7a8488b1cbfff2788ea9ab529efe24e030 100644 (file)
@@ -1266,8 +1266,13 @@ static VLCMain *_o_sharedMainInstance = nil;
     if (b_nativeFullscreenMode) {
         // this is called twice in certain situations, so only toogle if we really need to
         if ((b_fullscreen && !([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen)) ||
-            (!b_fullscreen &&  ([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen)))
-            [o_mainwindow toggleFullScreen: self];
+            (!b_fullscreen &&  ([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen))) {
+            if(p_wnd) {
+                VLCVideoWindowCommon *window = [o_vout_controller getWindow: p_wnd];
+                [window toggleFullScreen:self];
+            } else
+                [o_mainwindow toggleFullScreen: self]; // TODO
+        }
 
         if (b_fullscreen)
             [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];