[vlc-devel] [PATCH 3/5] macosx: make fullscreen animation compatible with non-embedded window

David Fuhrmann david.fuhrmann at googlemail.com
Wed Feb 15 15:14:32 CET 2012


makes sure that the non-embedded window fade out properly,
also leaves the main windows visible, the user wants to probably see it when it is on another display
---
 modules/gui/macosx/MainWindow.m |   52 ++++++++++++++++++++++++--------------
 1 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/modules/gui/macosx/MainWindow.m b/modules/gui/macosx/MainWindow.m
index d8b8771..666049e 100644
--- a/modules/gui/macosx/MainWindow.m
+++ b/modules/gui/macosx/MainWindow.m
@@ -1335,6 +1335,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
     NSRect rect;
     vout_thread_t *p_vout = getVout();
     BOOL blackout_other_displays = config_GetInt( VLCIntf, "macosx-black" );
+    id o_videoWindow = b_nonembedded ? o_nonembedded_window : self;
 
     if( p_vout )
         screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)config_GetInt( VLCIntf, "macosx-vdev" )];
@@ -1344,7 +1345,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
     if (!screen)
     {
         msg_Dbg( VLCIntf, "chosen screen isn't present, using current screen for fullscreen mode" );
-        screen = [[o_video_view window] screen];
+        screen = [o_videoWindow screen];
     }
     if (!screen)
     {
@@ -1365,8 +1366,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
         [screen blackoutOtherScreens];
 
     /* Make sure we don't see the window flashes in float-on-top mode */
-    i_originalLevel = [self level];
-    [self setLevel:NSNormalWindowLevel];
+    i_originalLevel = [o_videoWindow level];
+    [o_videoWindow setLevel:NSNormalWindowLevel];
 
     /* Only create the o_fullscreen_window if we are not in the middle of the zooming animation */
     if (!o_fullscreen_window)
@@ -1374,14 +1375,14 @@ static VLCMainWindow *_o_sharedInstance = nil;
         /* We can't change the styleMask of an already created NSWindow, so we create another window, and do eye catching stuff */
 
         rect = [[o_video_view superview] convertRect: [o_video_view frame] toView: nil]; /* Convert to Window base coord */
-        rect.origin.x += [[o_video_view window] frame].origin.x;
-        rect.origin.y += [[o_video_view window] frame].origin.y;
+        rect.origin.x += [o_videoWindow frame].origin.x;
+        rect.origin.y += [o_videoWindow frame].origin.y;
         o_fullscreen_window = [[VLCWindow alloc] initWithContentRect:rect styleMask: NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:YES];
         [o_fullscreen_window setFullscreen: YES];
         [o_fullscreen_window setBackgroundColor: [NSColor blackColor]];
         [o_fullscreen_window setCanBecomeKeyWindow: YES];
 
-        if (![self isVisible] || [self alphaValue] == 0.0)
+        if (![o_videoWindow isVisible] || [o_videoWindow alphaValue] == 0.0)
         {
             /* We don't animate if we are not visible, instead we
              * simply fade the display */
@@ -1436,7 +1437,11 @@ static VLCMainWindow *_o_sharedInstance = nil;
     if (b_fullscreen)
     {
         /* Make sure we are hidden */
-        [super orderOut: self];
+        if( b_nonembedded )
+            [o_nonembedded_window orderOut: self];
+        else
+            [super orderOut: self];
+        
         [self unlockFullscreenAnimation];
         return;
     }
@@ -1463,7 +1468,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
     dict1 = [[NSMutableDictionary alloc] initWithCapacity:2];
     dict2 = [[NSMutableDictionary alloc] initWithCapacity:3];
 
-    [dict1 setObject:self forKey:NSViewAnimationTargetKey];
+    [dict1 setObject:o_videoWindow forKey:NSViewAnimationTargetKey];
     [dict1 setObject:NSViewAnimationFadeOutEffect forKey:NSViewAnimationEffectKey];
 
     [dict2 setObject:o_fullscreen_window forKey:NSViewAnimationTargetKey];
@@ -1505,9 +1510,12 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [o_fspanel setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
     [o_fspanel setActive: nil];
 
-    if([self isVisible])
+    if( !b_nonembedded && [self isVisible] )
         [super orderOut: self];
 
+    if( b_nonembedded && [o_nonembedded_window isVisible] )
+        [o_nonembedded_window orderOut: self];
+
     [o_fspanel setActive: nil];
 
     b_fullscreen = YES;
@@ -1585,8 +1593,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
         return;
     }
 
-    [self setAlphaValue: 0.0];
-    [self orderFront: self];
+    id o_videoWindow = b_nonembedded ? o_nonembedded_window : self;
+
+    [o_videoWindow setAlphaValue: 0.0];
+    [o_videoWindow orderFront: self];
     [[o_video_view window] orderFront: self];
 
     [o_fspanel setNonActive: nil];
@@ -1607,12 +1617,11 @@ static VLCMainWindow *_o_sharedInstance = nil;
     }
 
     frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
-    id targetWindow = b_nonembedded ? o_nonembedded_window : self;
-    frame.origin.x += [targetWindow frame].origin.x;
-    frame.origin.y += [targetWindow frame].origin.y;
+    frame.origin.x += [o_videoWindow frame].origin.x;
+    frame.origin.y += [o_videoWindow frame].origin.y;
 
     dict2 = [[NSMutableDictionary alloc] initWithCapacity:2];
-    [dict2 setObject:self forKey:NSViewAnimationTargetKey];
+    [dict2 setObject:o_videoWindow forKey:NSViewAnimationTargetKey];
     [dict2 setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
 
     o_fullscreen_anim2 = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObjects:dict2, nil]];
@@ -1655,15 +1664,20 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [[o_temp_view superview] replaceSubview:o_temp_view with:o_video_view];
     [o_video_view release];
     [o_video_view setFrame:[o_temp_view frame]];
-    [self makeFirstResponder: o_video_view];
-    if ([self isVisible])
-        [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
+    [[o_video_view window] makeFirstResponder: o_video_view];
+    if ([[o_video_view window] isVisible] )
+    {
+        if( !b_nonembedded )
+            [super makeKeyAndOrderFront:self]; /* our version contains a workaround */
+        else
+            [[o_video_view window] makeKeyAndOrderFront: self];
+    }
     [o_fullscreen_window orderOut: self];
     NSEnableScreenUpdates();
 
     [o_fullscreen_window release];
     o_fullscreen_window = nil;
-    [self setLevel:i_originalLevel];
+    [[o_video_view window] setLevel:i_originalLevel];
 
     [self unlockFullscreenAnimation];
 }
-- 
1.7.5.4




More information about the vlc-devel mailing list