]> git.sesse.net Git - vlc/commitdiff
macosx: only show fspanel when needed, additional fixed for lion fullscreen behavior
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sat, 9 Feb 2013 09:18:14 +0000 (10:18 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Sat, 9 Feb 2013 17:44:39 +0000 (18:44 +0100)
modules/gui/macosx/MainWindow.h
modules/gui/macosx/MainWindow.m
modules/gui/macosx/VLCVoutWindowController.m
modules/gui/macosx/VideoView.m
modules/gui/macosx/Windows.h
modules/gui/macosx/Windows.m
modules/gui/macosx/fspanel.m
modules/gui/macosx/intf.m

index a2f59c26ea5d4d1f5ce905728d42b4944483ae7d..2f818c265297015fdcc911d680444ec92d7338b9 100644 (file)
@@ -92,9 +92,6 @@
 
     BOOL b_podcastView_displayed;
 
-    /* set to yes if we are fullscreen and all animations are over */
-    BOOL b_fullscreen;
-
     NSTimer *t_hide_mouse_timer;
 
     VLCColorView * o_color_backdrop;
     NSRect frameBeforePlayback;
 }
 + (VLCMainWindow *)sharedInstance;
-@property (readwrite) BOOL fullscreen;
 @property (readonly) BOOL nativeFullscreenMode;
 @property (readwrite) BOOL nonembedded;
 
index 49c284487af74aca5930dbcf04d2b99bf4188c3a..81711ea9473757b1d70f9492e00f475c500784ac 100644 (file)
@@ -56,7 +56,6 @@
 
 @implementation VLCMainWindow
 
-@synthesize fullscreen=b_fullscreen;
 @synthesize nativeFullscreenMode=b_nativeFullscreenMode;
 @synthesize nonembedded=b_nonembedded;
 @synthesize fsPanel=o_fspanel;
@@ -809,8 +808,18 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (void)showFullscreenController
 {
-     if (b_fullscreen && [[VLCMain sharedInstance] activeVideoPlayback])
-        [o_fspanel fadeIn];
+
+    id currentWindow = [NSApp keyWindow];
+    if ([currentWindow respondsToSelector:@selector(hasActiveVideo)] && [currentWindow hasActiveVideo]) {
+        if ([currentWindow respondsToSelector:@selector(fullscreen)] && [currentWindow fullscreen]) {
+
+            if ([[VLCMain sharedInstance] activeVideoPlayback])
+                [o_fspanel fadeIn];
+        }
+
+    }
+    
+    
 }
 
 - (void)makeKeyAndOrderFront: (id)sender
index 9cb0cdd9979822ceaa333f88c1756f36aa6bd590..4430c7b48b4cd4c5cbae7a96122d0b90e0e0ba69 100644 (file)
         return;
     }
 
-    if ([[VLCMainWindow sharedInstance] fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode])
+    if ([o_window fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode])
         [o_window leaveFullscreen];
 
-    if ([[VLCMainWindow sharedInstance] fullscreen] && [[VLCMainWindow sharedInstance] nativeFullscreenMode])
+    if (![NSStringFromClass([o_window class]) isEqualToString:@"VLCMainWindow"] &&
+            [o_window fullscreen] &&
+            [[VLCMainWindow sharedInstance] nativeFullscreenMode])
         [o_window toggleFullScreen: self];
 
 
index cd88942d5f47d1a5c05ae25589062607147898f6..7239cc9be45c051d25cb52a73362597ebfc4b617 100644 (file)
     // This is the result of [NSEvent standardMagnificationThreshold].
     // Unfortunately, this is a private API, currently.
     CGFloat f_threshold = 0.3;
-    BOOL b_fullscreen = [[VLCMainWindow sharedInstance] fullscreen];
+    BOOL b_fullscreen = [(VLCVideoWindowCommon *)[self window] fullscreen];
 
     if ((f_cumulated_magnification > f_threshold && !b_fullscreen) || (f_cumulated_magnification < -f_threshold && b_fullscreen)) {
         f_cumulated_magnification = 0.0;
index f15ff80c44fd8aea22747a92918779bd74d217bd..e15eadba37a33df5009d4530d4233d06815945b4 100644 (file)
     BOOL b_canBecomeMainWindow;
     BOOL b_isset_canBecomeMainWindow;
     NSViewAnimation *o_current_animation;
+
+    BOOL              b_has_active_video;
+
+    /* 
+     * normal fullscreen: YES when all animations are over
+     * lion fullscreen:   toggled when fs animation starts
+     * for fullscreen window: always YES
+     */
+    BOOL              b_fullscreen;
 }
 @property (readwrite) BOOL canBecomeKeyWindow;
 @property (readwrite) BOOL canBecomeMainWindow;
 
+@property (nonatomic, readwrite) BOOL hasActiveVideo;
+@property (nonatomic, readwrite) BOOL fullscreen;
+
 /* animate mode is only supported in >=10.4 */
 - (void)orderFront: (id)sender animate: (BOOL)animate;
 
@@ -95,12 +107,11 @@ static const float f_min_video_height = 70.0;
     NSRecursiveLock * o_animation_lock;
     NSInteger i_originalLevel;
 
-    BOOL              b_has_active_video;
+    NSTimer *t_hide_mouse_timer;
 }
 
 @property (nonatomic, assign) VLCVoutView* videoView;
 @property (readonly) VLCControlsBarCommon* controlsBar;
-@property (nonatomic, readwrite) BOOL hasActiveVideo;
 
 - (void)setWindowLevel:(NSInteger)i_state;
 
index a44120264d85ef93721ba72a06e5bb6c543b1ee6..d7e1066bb877fdebc24511519bd1334366b76ced 100644 (file)
  *****************************************************************************/
 
 @implementation VLCWindow
+
+@synthesize hasActiveVideo=b_has_active_video;
+@synthesize fullscreen=b_fullscreen;
+
 - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask
                   backing:(NSBackingStoreType)backingType defer:(BOOL)flag
 {
 
 @synthesize videoView=o_video_view;
 @synthesize controlsBar=o_controls_bar;
-@synthesize hasActiveVideo=b_has_active_video;
 
 #pragma mark -
 #pragma mark Init
 
 - (void)resizeWindow
 {
-    if ([[VLCMainWindow sharedInstance] fullscreen])
+    if ([self fullscreen])
         return;
 
     NSRect window_rect = [self getWindowRectForProposedVideoViewSize:nativeVideoSize];
         return proposedFrameSize;
 
     // needed when entering lion fullscreen mode
-    if ([[VLCMainWindow sharedInstance] fullscreen])
+    if ([self fullscreen])
         return proposedFrameSize;
 
     if ([[VLCCoreInteraction sharedInstance] aspectRatioIsLocked]) {
 
 #pragma mark -
 #pragma mark Lion native fullscreen handling
+
+- (void)becomeKeyWindow
+{
+    [super becomeKeyWindow];
+
+    // change fspanel state for the case when multiple windows are in fullscreen
+    if ([self hasActiveVideo] && [self fullscreen])
+        [[[VLCMainWindow sharedInstance] fsPanel] setActive:nil];
+    else
+        [[[VLCMainWindow sharedInstance] fsPanel] setNonActive:nil];
+}
+
 - (void)windowWillEnterFullScreen:(NSNotification *)notification
 {
     // workaround, see #6668
     [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen | NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
 
+    [self setFullscreen: YES];
+
     var_SetBool(pl_Get(VLCIntf), "fullscreen", true);
 
     if ([self hasActiveVideo]) {
     }
 
     [o_video_view setFrame: [[self contentView] frame]];
-    [[VLCMainWindow sharedInstance] setFullscreen: YES];
 
     [[VLCMainWindow sharedInstance] recreateHideMouseTimer];
     i_originalLevel = [self level];
 
 - (void)windowWillExitFullScreen:(NSNotification *)notification
 {
+    [self setFullscreen: NO];
+
     var_SetBool(pl_Get(VLCIntf), "fullscreen", false);
 
     if ([self hasActiveVideo]) {
 
     [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;
         [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
         [o_fullscreen_window setCanBecomeKeyWindow: YES];
         [o_fullscreen_window setCanBecomeMainWindow: YES];
+        [o_fullscreen_window setHasActiveVideo: YES];
+        [o_fullscreen_window setFullscreen: YES];
 
         if (![self isVisible] || [self alphaValue] == 0.0) {
             /* We don't animate if we are not visible, instead we
     }
 
     /* We are in fullscreen (and no animation is running) */
-    if ([[VLCMainWindow sharedInstance] fullscreen]) {
+    if ([self fullscreen]) {
         /* Make sure we are hidden */
         [self orderOut: self];
 
     if ([self isVisible])
         [self orderOut: self];
 
-    [[VLCMainWindow sharedInstance] setFullscreen:YES];
+    [self setFullscreen:YES];
     [self unlockFullscreenAnimation];
 }
 
 
 - (void)hasEndedFullscreen
 {
-    [[VLCMainWindow sharedInstance] setFullscreen:NO];
+    [self setFullscreen:NO];
 
     /* This function is private and should be only triggered at the end of the fullscreen change animation */
     /* Make sure we don't see the o_video_view disappearing of the screen during this operation */
index bc69fac4b791fa2746e86b316868df2101d6b3e0..f033384de31bb3807a7303191403b39f35eb97e7 100644 (file)
 {
     b_nonActive = NO;
 
-    id currentWindow = [NSApp keyWindow];
-    if ([currentWindow respondsToSelector:@selector(hasActiveVideo)]) {
-        if ([currentWindow hasActiveVideo]) {
-            [[VLCMain sharedInstance] showFullscreenController];
-        }
-    }
+    [[VLCMain sharedInstance] showFullscreenController];
 }
 
 /* This routine is called repeatedly to fade in the window */
index a017ba7a8488b1cbfff2788ea9ab529efe24e030..bd4226d0c6943ab58f347ffb6fad34971f340ffc 100644 (file)
@@ -1264,14 +1264,18 @@ static VLCMain *_o_sharedMainInstance = nil;
         var_SetBool(p_playlist, "fullscreen", b_fullscreen);
 
     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))) {
-            if(p_wnd) {
-                VLCVideoWindowCommon *window = [o_vout_controller getWindow: p_wnd];
-                [window toggleFullScreen:self];
-            } else
-                [o_mainwindow toggleFullScreen: self]; // TODO
+        VLCVideoWindowCommon *o_active_window = nil;
+        if(p_wnd)
+            o_active_window = [o_vout_controller getWindow: p_wnd];
+        else
+            o_active_window = o_mainwindow;
+
+        // fullscreen might be triggered twice (vout event)
+        // so ignore duplicate events here
+        if((b_fullscreen && ![o_active_window fullscreen]) ||
+            (!b_fullscreen && [o_active_window fullscreen])) {
+
+            [o_active_window toggleFullScreen:self];
         }
 
         if (b_fullscreen)