]> git.sesse.net Git - vlc/commitdiff
Mac OS X gui: Protect the fullscreen animation by a lock.
authorPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 3 Mar 2007 11:07:39 +0000 (11:07 +0000)
committerPierre d'Herbemont <pdherbemont@videolan.org>
Sat, 3 Mar 2007 11:07:39 +0000 (11:07 +0000)
modules/gui/macosx/embeddedwindow.h
modules/gui/macosx/embeddedwindow.m
modules/gui/macosx/vout.m

index 0c242683b93b87ef8e56c9c9268e1d13291d40c6..0a114c910bcfe598e87ea2ea487baf614f4c76e8 100644 (file)
@@ -50,6 +50,7 @@
     NSView          * o_temp_view;
     /* set to yes if we are fullscreen and all animations are over */
     BOOL              b_fullscreen;
+    NSLock          * o_animation_lock;
 }
 
 - (void)setTime:(NSString *)o_arg_ime position:(float)f_position;
@@ -60,6 +61,9 @@
 
 - (BOOL)isFullscreen;
 
+- (void)lockFullscreenAnimation;
+- (void)unlockFullscreenAnimation;
+
 - (void)enterFullscreen;
 - (void)leaveFullscreen;
 
index 02c848814f1d321522f0810f58a7589e9183a56f..232ce2aec30c2ec99645fb51634488b5ed9770bd 100644 (file)
@@ -67,6 +67,7 @@
     /* Not fullscreen when we wake up */
     [o_btn_fullscreen setState: NO];
     b_fullscreen = NO;
+    o_animation_lock = [[NSLock alloc] init];
 }
 
 - (void)setTime:(NSString *)o_arg_time position:(float)f_position
     return b_fullscreen;
 }
 
+- (void)lockFullscreenAnimation
+{
+    [o_animation_lock lock];
+}
+
+- (void)unlockFullscreenAnimation
+{
+    [o_animation_lock unlock];
+}
+
 - (void)enterFullscreen
 {
     NSMutableDictionary *dict1, *dict2;
     screen = [NSScreen screenWithDisplayID:(CGDirectDisplayID)var_GetInteger( p_vout, "video-device" )];
 
     vlc_object_release( p_vout );
+    
+    [self lockFullscreenAnimation];
 
     if (!screen)
         screen = [self screen];
 
             CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
             CGReleaseDisplayFadeReservation( token);
+
+            /* Will release the lock */
             [self hasBecomeFullscreen];
+
             return;
         }
         
     {
         /* We were already fullscreen nothing to do when NSAnimation
          * is not supported */
+        [self unlockFullscreenAnimation];
         return;
     }
 
     /* We are in fullscreen (and no animation is running) */
     if (b_fullscreen)
+    {
+        [self unlockFullscreenAnimation];
         return;
+    }
 
     if (o_fullscreen_anim1)
     {
     [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
 
     [o_fullscreen_anim1 startAnimation];
+    /* fullscreenAnimation will be unlocked when animation ends */
 }
 
 - (void)hasBecomeFullscreen
     
     [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
     b_fullscreen = YES;
+    [self unlockFullscreenAnimation];
 }
 
 - (void)leaveFullscreen
 {
     NSMutableDictionary *dict1, *dict2;
     NSRect frame;
-    
+
+    [self lockFullscreenAnimation];
+
     b_fullscreen = NO;
     [o_btn_fullscreen setState: NO];
 
 
     /* Don't do anything if o_fullscreen_window is already closed */
     if (!o_fullscreen_window)
+    {
+        [self lockFullscreenAnimation];
         return;
+    }
 
     if (![self isVisible] || MACOS_VERSION < 10.4f)
     {
         [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
         SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
 
+        /* Will release the lock */
         [self hasEndedFullscreen];
 
         CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
     [o_fullscreen_anim1 setFrameRate: 30];
     [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
     [o_fullscreen_anim1 startAnimation];
+    /* fullscreenAnimation will be unlocked when animation ends */
 }
 
 - (void)hasEndedFullscreen
 
     [o_fullscreen_window release];
     o_fullscreen_window = nil;
+    [self unlockFullscreenAnimation];
 }
 
 - (void)animationDidEnd:(NSAnimation*)animation
index 94d0437b9c02ebccd01a3b5e0276580a76760365..0b1a347ad4dfde49f638351d666abd7c5dee82c7 100644 (file)
@@ -929,6 +929,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         [o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
         [self updateTitle];
 
+        [o_window lockFullscreenAnimation];
+
         /* Make the window the front and key window before animating */
         if ([o_window isVisible] && (![o_window isFullscreen]))
             [o_window makeKeyAndOrderFront: self];
@@ -938,6 +940,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
         /* Make sure our window is visible, if we are not in fullscreen */
         if (![o_window isFullscreen])
             [o_window makeKeyAndOrderFront: self];
+        [o_window unlockFullscreenAnimation];
 
     }
     return b_return;