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

Mac OS X gui: Use a recursive lock to be able to trigger enter/leaveFullscreen...

Mac OS X gui: Use a recursive lock to be able to trigger enter/leaveFullscreen in the middle of an enter/leaveFullscreen operation.
parent e90520eb
...@@ -50,7 +50,8 @@ ...@@ -50,7 +50,8 @@
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; BOOL b_animation_lock_alreadylocked;
NSRecursiveLock * o_animation_lock;
} }
- (void)setTime:(NSString *)o_arg_ime position:(float)f_position; - (void)setTime:(NSString *)o_arg_ime position:(float)f_position;
......
...@@ -67,7 +67,11 @@ ...@@ -67,7 +67,11 @@
/* 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]; /* Use a recursive lock to be able to trigger enter/leavefullscreen
* in middle of an animation, providing that the enter/leave functions
* are called from the same thread */
o_animation_lock = [[NSRecursiveLock alloc] init];
b_animation_lock_alreadylocked = NO;
} }
- (void)setTime:(NSString *)o_arg_time position:(float)f_position - (void)setTime:(NSString *)o_arg_time position:(float)f_position
...@@ -170,6 +174,13 @@ ...@@ -170,6 +174,13 @@
[self lockFullscreenAnimation]; [self lockFullscreenAnimation];
/* This is a recursive lock. If we are already in the middle of an animation we
* unlock it. We don't add an extra locking here, because enter/leavefullscreen
* are executed always in the same thread */
if (b_animation_lock_alreadylocked)
[self unlockFullscreenAnimation];
b_animation_lock_alreadylocked = YES;
if (!screen) if (!screen)
screen = [self screen]; screen = [self screen];
...@@ -238,6 +249,7 @@ ...@@ -238,6 +249,7 @@
/* 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]; [self unlockFullscreenAnimation];
b_animation_lock_alreadylocked = NO;
return; return;
} }
...@@ -245,6 +257,7 @@ ...@@ -245,6 +257,7 @@
if (b_fullscreen) if (b_fullscreen)
{ {
[self unlockFullscreenAnimation]; [self unlockFullscreenAnimation];
b_animation_lock_alreadylocked = NO;
return; return;
} }
...@@ -318,6 +331,13 @@ ...@@ -318,6 +331,13 @@
[self lockFullscreenAnimation]; [self lockFullscreenAnimation];
/* This is a recursive lock. If we are already in the middle of an animation we
* unlock it. We don't add an extra locking here, because enter/leavefullscreen
* are executed always in the same thread */
if (b_animation_lock_alreadylocked)
[self unlockFullscreenAnimation];
b_animation_lock_alreadylocked = YES;
b_fullscreen = NO; b_fullscreen = NO;
[o_btn_fullscreen setState: NO]; [o_btn_fullscreen setState: NO];
...@@ -327,7 +347,8 @@ ...@@ -327,7 +347,8 @@
/* 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]; [self unlockFullscreenAnimation];
b_animation_lock_alreadylocked = NO;
return; return;
} }
...@@ -418,6 +439,7 @@ ...@@ -418,6 +439,7 @@
[o_fullscreen_window release]; [o_fullscreen_window release];
o_fullscreen_window = nil; o_fullscreen_window = nil;
[self unlockFullscreenAnimation]; [self unlockFullscreenAnimation];
b_animation_lock_alreadylocked = NO;
} }
- (void)animationDidEnd:(NSAnimation*)animation - (void)animationDidEnd:(NSAnimation*)animation
......
...@@ -926,10 +926,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -926,10 +926,11 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if( b_return ) if( b_return )
{ {
[o_window lockFullscreenAnimation];
[o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )]; [o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
[self updateTitle];
[o_window lockFullscreenAnimation]; [self updateTitle];
/* 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]))
......
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