]> git.sesse.net Git - vlc/commitdiff
macosx: reactivate fast path for exiting fullscreen window when video finished
authorDavid Fuhrmann <david.fuhrmann@googlemail.com>
Wed, 19 Mar 2014 08:48:07 +0000 (09:48 +0100)
committerDavid Fuhrmann <david.fuhrmann@googlemail.com>
Thu, 20 Mar 2014 19:29:10 +0000 (20:29 +0100)
This also removes old workarounds which are not needed anymore.

close #10826

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

index f2def5beec524cf1b61c687d26a2b3baef7b59de..de86df76f43d4a291a435a43a18706fdb9434bd5 100644 (file)
         return;
     }
 
-    if ([o_window fullscreen] && ![[VLCMainWindow sharedInstance] nativeFullscreenMode])
-        [o_window leaveFullscreen];
+    // prevent visible extra window if in fullscreen
+    NSDisableScreenUpdates();
+    if (![[VLCMainWindow sharedInstance] nativeFullscreenMode] &&
+            ([o_window fullscreen] || [o_window inFullscreenTransition]))
+        [o_window leaveFullscreenWithAnimation: NO];
 
     [[o_window videoView] releaseVoutThread];
 
     if ([o_window class] != [VLCMainWindow class]) {
         [o_window close];
     }
+    NSEnableScreenUpdates();
 
     [o_window retain];
     [o_vout_dict removeObjectForKey:o_key];
                 vlc_object_release(p_input);
         } else {
             // leaving fullscreen is always allowed
-            [o_current_window leaveFullscreen];
+            [o_current_window leaveFullscreenWithAnimation:YES];
         }
     }
 }
index 2c4273f5ab71ec06c20cf0ea64c9816b2a68378a..ce3f71427b51a37bfdd60f1e71e0a844232323fb 100644 (file)
@@ -98,10 +98,8 @@ static const float f_min_video_height = 70.0;
     VLCWindow       * o_fullscreen_window;
     NSViewAnimation * o_fullscreen_anim1;
     NSViewAnimation * o_fullscreen_anim2;
-    NSViewAnimation * o_makekey_anim;
     NSView          * o_temp_view;
 
-    BOOL              b_window_is_invisible;
     NSInteger i_originalLevel;
 
     BOOL              b_video_view_was_hidden;
@@ -129,7 +127,7 @@ static const float f_min_video_height = 70.0;
 
 /* fullscreen handling */
 - (void)enterFullscreen;
-- (void)leaveFullscreen;
+- (void)leaveFullscreenWithAnimation:(BOOL)b_animation;
 
 /* lion fullscreen handling */
 - (void)windowWillEnterFullScreen:(NSNotification *)notification;
index 51c11350432e45dd9888c08b1d85b22226adfa3a..2e58b6f84090f27fa0a6bbb31104351f3e450511 100644 (file)
 @interface VLCVideoWindowCommon (Internal)
 - (void)customZoom:(id)sender;
 - (void)hasBecomeFullscreen;
-- (void)leaveFullscreenAndFadeOut:(BOOL)fadeout;
 - (void)hasEndedFullscreen;
 @end
 
     [self setFullscreen:YES];
 }
 
-- (void)leaveFullscreen
-{
-    [self leaveFullscreenAndFadeOut: NO];
-}
-
-- (void)leaveFullscreenAndFadeOut: (BOOL)fadeout
+- (void)leaveFullscreenWithAnimation:(BOOL)b_animation
 {
     NSMutableDictionary *dict1, *dict2;
     NSRect frame;
         return;
     }
 
-    if (fadeout) {
+    [[[VLCMainWindow sharedInstance] fsPanel] setNonActive: nil];
+    [[o_fullscreen_window screen] setNonFullscreenPresentationOptions];
+
+    if (o_fullscreen_anim1) {
+        [o_fullscreen_anim1 stopAnimation];
+        [o_fullscreen_anim1 release];
+        o_fullscreen_anim1 = nil;
+    }
+    if (o_fullscreen_anim2) {
+        [o_fullscreen_anim2 stopAnimation];
+        [o_fullscreen_anim2 release];
+        o_fullscreen_anim2 = nil;
+    }
+
+    if (!b_animation) {
         /* We don't animate if we are not visible, instead we
          * simply fade the display */
         CGDisplayFadeReservationToken token;
             CGDisplayFade(token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES);
         }
 
-        [[[VLCMainWindow sharedInstance] fsPanel] setNonActive: nil];
-        [[o_fullscreen_window screen] setNonFullscreenPresentationOptions];
+        [self setAlphaValue:1.0];
+        [self orderFront: self];
 
         /* Will release the lock */
         [self hasEndedFullscreen];
 
-        /* Our window is hidden, and might be faded. We need to workaround that, so note it
-         * here */
-        b_window_is_invisible = YES;
-
         if (blackout_other_displays) {
             CGDisplayFade(token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO);
             CGReleaseDisplayFadeReservation(token);
     [self orderFront: self];
     [[o_video_view window] orderFront: self];
 
-    [[[VLCMainWindow sharedInstance] fsPanel] setNonActive: nil];
-    [[o_fullscreen_window screen] setNonFullscreenPresentationOptions];
-
-    if (o_fullscreen_anim1) {
-        [o_fullscreen_anim1 stopAnimation];
-        [o_fullscreen_anim1 release];
-    }
-    if (o_fullscreen_anim2) {
-        [o_fullscreen_anim2 stopAnimation];
-        [o_fullscreen_anim2 release];
-    }
-
     frame = [[o_temp_view superview] convertRect: [o_temp_view frame] toView: nil]; /* Convert to Window base coord */
     frame.origin.x += [self frame].origin.x;
     frame.origin.y += [self frame].origin.y;
 
     [o_video_view setHidden: b_video_view_was_hidden];
 
-    [super makeKeyAndOrderFront:self]; /* our version (in main window) contains a workaround */
+    [self makeKeyAndOrderFront:self];
 
     [o_fullscreen_window orderOut: self];
     NSEnableScreenUpdates();
     [self setLevel:i_originalLevel];
 
     [self setAlphaValue: config_GetFloat(VLCIntf, "macosx-opaqueness")];
-
-    // if we quit fullscreen because there is no video anymore, make sure non-embedded window is not visible
-    if (![[VLCMain sharedInstance] activeVideoPlayback] && [self class] != [VLCMainWindow class])
-        [self orderOut: self];
 }
 
 - (void)animationDidEnd:(NSAnimation*)animation
 {
     NSArray *viewAnimations;
-    if (o_makekey_anim == animation) {
-        [o_makekey_anim release];
-        return;
-    }
     if ([animation currentValue] < 1.0)
         return;
 
         [self hasBecomeFullscreen];
 }
 
-- (void)orderOut:(id)sender
-{
-    [super orderOut:sender];
-
-    /*
-     * TODO reimplement leaveFullscreenAndFadeOut:YES, or remove code
-     * and the hack below
-    
-    if (![NSStringFromClass([self class]) isEqualToString:@"VLCMainWindow"]) {
-        [self leaveFullscreenAndFadeOut:YES];
-    }
-     */
-}
-
-- (void)makeKeyAndOrderFront: (id)sender
-{
-    /* Hack
-     * when we exit fullscreen and fade out, we may endup in
-     * having a window that is faded. We can't have it fade in unless we
-     * animate again. */
-
-    if (!b_window_is_invisible) {
-        /* Make sure we don't do it too much */
-        [super makeKeyAndOrderFront: sender];
-        return;
-    }
-
-    [super setAlphaValue:0.0f];
-    [super makeKeyAndOrderFront: sender];
-
-    NSMutableDictionary * dict = [[NSMutableDictionary alloc] initWithCapacity:2];
-    [dict setObject:self forKey:NSViewAnimationTargetKey];
-    [dict setObject:NSViewAnimationFadeInEffect forKey:NSViewAnimationEffectKey];
-
-    o_makekey_anim = [[NSViewAnimation alloc] initWithViewAnimations:[NSArray arrayWithObject:dict]];
-    [dict release];
-
-    [o_makekey_anim setAnimationBlockingMode: NSAnimationNonblocking];
-    [o_makekey_anim setDuration: 0.1];
-    [o_makekey_anim setFrameRate: 30];
-    [o_makekey_anim setDelegate: self];
-
-    [o_makekey_anim startAnimation];
-    b_window_is_invisible = NO;
-
-    /* fullscreenAnimation will be unlocked when animation ends */
-}
-
-
 #pragma mark -
 #pragma mark Accessibility stuff