Commit bf9fed9b authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Mac OS X gui: Protect the fullscreen animation by a lock.

parent 980b1a6a
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
NSView * o_temp_view; NSView * o_temp_view;
/* set to yes if we are fullscreen and all animations are over */ /* set to yes if we are fullscreen and all animations are over */
BOOL b_fullscreen; BOOL b_fullscreen;
NSLock * o_animation_lock;
} }
- (void)setTime:(NSString *)o_arg_ime position:(float)f_position; - (void)setTime:(NSString *)o_arg_ime position:(float)f_position;
...@@ -60,6 +61,9 @@ ...@@ -60,6 +61,9 @@
- (BOOL)isFullscreen; - (BOOL)isFullscreen;
- (void)lockFullscreenAnimation;
- (void)unlockFullscreenAnimation;
- (void)enterFullscreen; - (void)enterFullscreen;
- (void)leaveFullscreen; - (void)leaveFullscreen;
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
/* Not fullscreen when we wake up */ /* Not fullscreen when we wake up */
[o_btn_fullscreen setState: NO]; [o_btn_fullscreen setState: NO];
b_fullscreen = NO; b_fullscreen = NO;
o_animation_lock = [[NSLock alloc] init];
} }
- (void)setTime:(NSString *)o_arg_time position:(float)f_position - (void)setTime:(NSString *)o_arg_time position:(float)f_position
...@@ -144,6 +145,16 @@ ...@@ -144,6 +145,16 @@
return b_fullscreen; return b_fullscreen;
} }
- (void)lockFullscreenAnimation
{
[o_animation_lock lock];
}
- (void)unlockFullscreenAnimation
{
[o_animation_lock unlock];
}
- (void)enterFullscreen - (void)enterFullscreen
{ {
NSMutableDictionary *dict1, *dict2; NSMutableDictionary *dict1, *dict2;
...@@ -157,6 +168,8 @@ ...@@ -157,6 +168,8 @@
vlc_object_release( p_vout ); vlc_object_release( p_vout );
[self lockFullscreenAnimation];
if (!screen) if (!screen)
screen = [self screen]; screen = [self screen];
...@@ -204,7 +217,10 @@ ...@@ -204,7 +217,10 @@
CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO ); CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
CGReleaseDisplayFadeReservation( token); CGReleaseDisplayFadeReservation( token);
/* Will release the lock */
[self hasBecomeFullscreen]; [self hasBecomeFullscreen];
return; return;
} }
...@@ -221,12 +237,16 @@ ...@@ -221,12 +237,16 @@
{ {
/* We were already fullscreen nothing to do when NSAnimation /* We were already fullscreen nothing to do when NSAnimation
* is not supported */ * is not supported */
[self unlockFullscreenAnimation];
return; return;
} }
/* We are in fullscreen (and no animation is running) */ /* We are in fullscreen (and no animation is running) */
if (b_fullscreen) if (b_fullscreen)
{
[self unlockFullscreenAnimation];
return; return;
}
if (o_fullscreen_anim1) if (o_fullscreen_anim1)
{ {
...@@ -273,6 +293,7 @@ ...@@ -273,6 +293,7 @@
[o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0]; [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
[o_fullscreen_anim1 startAnimation]; [o_fullscreen_anim1 startAnimation];
/* fullscreenAnimation will be unlocked when animation ends */
} }
- (void)hasBecomeFullscreen - (void)hasBecomeFullscreen
...@@ -287,6 +308,7 @@ ...@@ -287,6 +308,7 @@
[[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil]; [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
b_fullscreen = YES; b_fullscreen = YES;
[self unlockFullscreenAnimation];
} }
- (void)leaveFullscreen - (void)leaveFullscreen
...@@ -294,6 +316,8 @@ ...@@ -294,6 +316,8 @@
NSMutableDictionary *dict1, *dict2; NSMutableDictionary *dict1, *dict2;
NSRect frame; NSRect frame;
[self lockFullscreenAnimation];
b_fullscreen = NO; b_fullscreen = NO;
[o_btn_fullscreen setState: NO]; [o_btn_fullscreen setState: NO];
...@@ -302,7 +326,10 @@ ...@@ -302,7 +326,10 @@
/* Don't do anything if o_fullscreen_window is already closed */ /* Don't do anything if o_fullscreen_window is already closed */
if (!o_fullscreen_window) if (!o_fullscreen_window)
{
[self lockFullscreenAnimation];
return; return;
}
if (![self isVisible] || MACOS_VERSION < 10.4f) if (![self isVisible] || MACOS_VERSION < 10.4f)
{ {
...@@ -317,6 +344,7 @@ ...@@ -317,6 +344,7 @@
[[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil]; [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar); SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
/* Will release the lock */
[self hasEndedFullscreen]; [self hasEndedFullscreen];
CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO ); CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
...@@ -369,6 +397,7 @@ ...@@ -369,6 +397,7 @@
[o_fullscreen_anim1 setFrameRate: 30]; [o_fullscreen_anim1 setFrameRate: 30];
[o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0]; [o_fullscreen_anim2 startWhenAnimation: o_fullscreen_anim1 reachesProgress: 1.0];
[o_fullscreen_anim1 startAnimation]; [o_fullscreen_anim1 startAnimation];
/* fullscreenAnimation will be unlocked when animation ends */
} }
- (void)hasEndedFullscreen - (void)hasEndedFullscreen
...@@ -388,6 +417,7 @@ ...@@ -388,6 +417,7 @@
[o_fullscreen_window release]; [o_fullscreen_window release];
o_fullscreen_window = nil; o_fullscreen_window = nil;
[self unlockFullscreenAnimation];
} }
- (void)animationDidEnd:(NSAnimation*)animation - (void)animationDidEnd:(NSAnimation*)animation
......
...@@ -929,6 +929,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -929,6 +929,8 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
[o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )]; [o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
[self updateTitle]; [self updateTitle];
[o_window lockFullscreenAnimation];
/* Make the window the front and key window before animating */ /* Make the window the front and key window before animating */
if ([o_window isVisible] && (![o_window isFullscreen])) if ([o_window isVisible] && (![o_window isFullscreen]))
[o_window makeKeyAndOrderFront: self]; [o_window makeKeyAndOrderFront: self];
...@@ -938,6 +940,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -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 */ /* Make sure our window is visible, if we are not in fullscreen */
if (![o_window isFullscreen]) if (![o_window isFullscreen])
[o_window makeKeyAndOrderFront: self]; [o_window makeKeyAndOrderFront: self];
[o_window unlockFullscreenAnimation];
} }
return b_return; return b_return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment