Commit 94f061cd authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

Close the embedded window only when playlist stop. Have the window to animate...

Close the embedded window only when playlist stop. Have the window to animate smoothly when size changes. Make the fullscreen mode behaves well when input changes and ends.
parent b33ad0d9
...@@ -48,17 +48,25 @@ ...@@ -48,17 +48,25 @@
NSViewAnimation * o_fullscreen_anim1; NSViewAnimation * o_fullscreen_anim1;
NSViewAnimation * o_fullscreen_anim2; NSViewAnimation * o_fullscreen_anim2;
NSView * o_temp_view; NSView * o_temp_view;
/* set to yes if we are fullscreen and all animations are over */
BOOL b_fullscreen;
} }
- (void)setTime:(NSString *)o_arg_ime position:(float)f_position; - (void)setTime:(NSString *)o_arg_ime position:(float)f_position;
- (void)playStatusUpdated:(int)i_status; - (void)playStatusUpdated:(int)i_status;
- (void)setSeekable:(BOOL)b_seekable; - (void)setSeekable:(BOOL)b_seekable;
- (NSView *)mainView;
- (BOOL)isFullscreen;
- (void)enterFullscreen; - (void)enterFullscreen;
- (void)leaveFullscreen; - (void)leaveFullscreen;
/* private */ /* private */
- (void)hasEndedFullscreen; - (void)hasEndedFullscreen;
- (void)hasBecomeFullscreen; - (void)hasBecomeFullscreen;
- (void)setFrameOnMainThread:(NSData*)packedargs;
@end @end
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,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;
} }
- (void)setTime:(NSString *)o_arg_time position:(float)f_position - (void)setTime:(NSString *)o_arg_time position:(float)f_position
...@@ -126,9 +127,23 @@ ...@@ -126,9 +127,23 @@
return YES; return YES;
} }
- (NSView *)mainView
{
if (o_fullscreen_window)
return o_temp_view;
else
return o_view;
}
/***************************************************************************** /*****************************************************************************
* Fullscreen support * Fullscreen support
*/ */
- (BOOL)isFullscreen
{
return b_fullscreen;
}
- (void)enterFullscreen - (void)enterFullscreen
{ {
NSMutableDictionary *dict1, *dict2; NSMutableDictionary *dict1, *dict2;
...@@ -209,6 +224,10 @@ ...@@ -209,6 +224,10 @@
return; return;
} }
/* We are in fullscreen (and no animation is running) */
if (b_fullscreen)
return;
if (o_fullscreen_anim1) if (o_fullscreen_anim1)
{ {
[o_fullscreen_anim1 stopAnimation]; [o_fullscreen_anim1 stopAnimation];
...@@ -267,6 +286,7 @@ ...@@ -267,6 +286,7 @@
[[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]]; [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: (int)[[o_fullscreen_window screen] displayID]];
[[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil]; [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
b_fullscreen = YES;
} }
- (void)leaveFullscreen - (void)leaveFullscreen
...@@ -274,6 +294,7 @@ ...@@ -274,6 +294,7 @@
NSMutableDictionary *dict1, *dict2; NSMutableDictionary *dict1, *dict2;
NSRect frame; NSRect frame;
b_fullscreen = NO;
[o_btn_fullscreen setState: NO]; [o_btn_fullscreen setState: NO];
/* We always try to do so */ /* We always try to do so */
...@@ -283,7 +304,7 @@ ...@@ -283,7 +304,7 @@
if (!o_fullscreen_window) if (!o_fullscreen_window)
return; return;
if (MACOS_VERSION < 10.4f) if (![self isVisible] || MACOS_VERSION < 10.4f)
{ {
/* We don't animate if we are not visible or if we are running on /* We don't animate if we are not visible or if we are running on
* Mac OS X <10.4 which doesn't support NSAnimation, instead we * Mac OS X <10.4 which doesn't support NSAnimation, instead we
...@@ -296,7 +317,6 @@ ...@@ -296,7 +317,6 @@
[[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil]; [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar); SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
[self makeKeyAndOrderFront:self];
[self hasEndedFullscreen]; [self hasEndedFullscreen];
CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO ); CGDisplayFade( token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
...@@ -361,6 +381,7 @@ ...@@ -361,6 +381,7 @@
[[self contentView] replaceSubview:o_temp_view with:o_view]; [[self contentView] replaceSubview:o_temp_view with:o_view];
[o_view release]; [o_view release];
[o_view setFrame:[o_temp_view frame]]; [o_view setFrame:[o_temp_view frame]];
if ([self isVisible])
[self makeKeyAndOrderFront:self]; [self makeKeyAndOrderFront:self];
[o_fullscreen_window orderOut: self]; [o_fullscreen_window orderOut: self];
EnableScreenUpdates(); EnableScreenUpdates();
...@@ -391,4 +412,34 @@ ...@@ -391,4 +412,34 @@
} }
} }
- (void)orderOut: (id)sender
{
[super orderOut: sender];
/* Make sure we leave fullscreen */
[self leaveFullscreen];
}
/* Make sure setFrame gets executed on main thread especially if we are animating.
* (Thus we won't block the video output thread) */
- (void)setFrame:(NSRect)frame display:(BOOL)display animate:(BOOL)animate
{
struct { NSRect frame; BOOL display; BOOL animate;} args;
NSData *packedargs;
args.frame = frame;
args.display = display;
args.animate = animate;
packedargs = [NSData dataWithBytes:&args length:sizeof(args)];
[self performSelectorOnMainThread:@selector(setFrameOnMainThread:)
withObject: packedargs waitUntilDone: YES];
}
- (void)setFrameOnMainThread:(NSData*)packedargs
{
struct args { NSRect frame; BOOL display; BOOL animate; } * args = (struct args*)[packedargs bytes];
[super setFrame: args->frame display: args->display animate:args->animate];
}
@end @end
...@@ -245,10 +245,21 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -245,10 +245,21 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
[o_view setFrameSize: [self frame].size]; [o_view setFrameSize: [self frame].size];
} }
- (void)drawRect:(NSRect)rect
{
/* When there is no subview we draw a black background */
[self lockFocus];
[[NSColor blackColor] set];
NSRectFill(rect);
[self unlockFocus];
}
- (void)closeVout - (void)closeVout
{ {
[[[[VLCMain sharedInstance] getControls] getFSPanel] fadeOut]; [[[[VLCMain sharedInstance] getControls] getFSPanel] fadeOut];
/* Make sure we don't see a white flash */
[[self window] disableScreenUpdatesUntilFlush];
[o_view removeFromSuperview]; [o_view removeFromSuperview];
o_view = nil; o_view = nil;
p_vout = NULL; p_vout = NULL;
...@@ -334,6 +345,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -334,6 +345,7 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
if ( !p_vout->b_fullscreen ) if ( !p_vout->b_fullscreen )
{ {
NSView *mainView;
NSRect new_frame; NSRect new_frame;
topleftbase.x = 0; topleftbase.x = 0;
topleftbase.y = [o_window frame].size.height; topleftbase.y = [o_window frame].size.height;
...@@ -355,11 +367,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -355,11 +367,18 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
newsize.height = (int) ( i_corrected_height * factor ); newsize.height = (int) ( i_corrected_height * factor );
} }
/* In fullscreen mode we need to use a view that is different from
* ourselves, with the VLCEmbeddedWindow */
if([o_window isKindOfClass:[VLCEmbeddedWindow class]])
mainView = [o_window mainView];
else
mainView = self;
/* Calculate the window's new size */ /* Calculate the window's new size */
new_frame.size.width = [o_window frame].size.width - new_frame.size.width = [o_window frame].size.width -
[self frame].size.width + newsize.width; [mainView frame].size.width + newsize.width;
new_frame.size.height = [o_window frame].size.height - new_frame.size.height = [o_window frame].size.height -
[self frame].size.height + newsize.height; [mainView frame].size.height + newsize.height;
new_frame.origin.x = topleftscreen.x; new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height; new_frame.origin.y = topleftscreen.y - new_frame.size.height;
...@@ -894,19 +913,34 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable, ...@@ -894,19 +913,34 @@ int DeviceCallback( vlc_object_t *p_this, const char *psz_variable,
{ {
BOOL b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame]; BOOL b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame];
/* o_window needs to point to our o_embeddedwindow, super might have set it
* to the fullscreen window that o_embeddedwindow setups during fullscreen */
o_window = o_embeddedwindow;
if( b_return ) if( b_return )
{ {
[o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )]; [o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
[self updateTitle]; [self updateTitle];
[self scaleWindowWithFactor: 1.0 animate: NO];
if(!([o_window isFullscreen]))
[o_window makeKeyAndOrderFront: self]; [o_window makeKeyAndOrderFront: self];
NSLog(@"We are %s animating (%s)", [o_window isVisible] && (![o_window isFullscreen]) ? "" :"not", [o_window isFullscreen] ? "fullscreen" : "");
[self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
} }
return b_return; return b_return;
} }
- (void)closeVout - (void)closeVout
{ {
[o_window orderOut: self]; playlist_t * p_playlist = pl_Yield( VLCIntf );
if(!playlist_IsPlaying( p_playlist ))
[o_window performSelectorOnMainThread: @selector(orderOut:) withObject: self waitUntilDone: YES];
vlc_object_release( p_playlist );
[super closeVout]; [super closeVout];
} }
......
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