var_Create( p_vout->p_libvlc, "video-device", VLC_VAR_INTEGER );
var_Set( p_vout->p_libvlc, "video-device", new_val );
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
var_Set( p_vout, "intf-change", val );
return VLC_SUCCESS;
}
var_Create( p_real_vout, "video-device", VLC_VAR_INTEGER |
VLC_VAR_HASCHOICE );
- text.psz_string = _("Video Device");
+ text.psz_string = _("Fullscreen Video Device");
var_Change( p_real_vout, "video-device", VLC_VAR_SETTEXT, &text, NULL );
NSEnumerator * o_enumerator = [o_screens objectEnumerator];
var_AddCallback( p_real_vout, "video-device", DeviceCallback,
NULL );
- val2.b_bool = VLC_TRUE;
+ val2.b_bool = true;
var_Set( p_real_vout, "intf-change", val2 );
}
NSString * o_title = nil;
NSMutableString * o_mrl = nil;
input_thread_t * p_input;
+ char * psz_title;
- if( p_vout == NULL )
- {
- return;
- }
+ if( !p_vout ) return;
p_input = vlc_object_find( p_vout, VLC_OBJECT_INPUT, FIND_PARENT );
- if( p_input == NULL )
- {
- return;
- }
+ if( !p_input ) return;
+
+ input_item_t * p_item = input_GetItem( p_input );
- char *psz_nowPlaying = input_item_GetNowPlaying ( input_GetItem( p_input ) );
- char *psz_name = input_item_GetName( input_GetItem( p_input ) );
- char *psz_uri = input_item_GetURI( input_GetItem( p_input ) );
- if( psz_nowPlaying != NULL )
- o_title = [NSString stringWithUTF8String: psz_nowPlaying];
- else if( psz_name != NULL )
- o_title = [NSString stringWithUTF8String: psz_name];
+ psz_title = input_item_GetNowPlaying ( p_item );
+ if( !psz_title )
+ psz_title = input_item_GetName( p_item );
- if( psz_uri != NULL )
+ if( psz_title )
+ o_title = [NSString stringWithUTF8String: psz_title];
+
+ char *psz_uri = input_item_GetURI( p_item );
+ if( psz_uri )
o_mrl = [NSMutableString stringWithUTF8String: psz_uri];
- FREENULL( psz_nowPlaying );
- FREENULL( psz_name );
- FREENULL( psz_uri );
+ free( psz_title );
+ free( psz_uri );
- if( o_title == nil )
+ if( !o_title )
o_title = o_mrl;
if( o_mrl != nil )
}
}
-- (void)scaleWindowWithFactor: (float)factor animate: (BOOL)animate
+- (NSSize)voutSizeForFactor: (float)factor
{
- NSSize newsize;
int i_corrected_height, i_corrected_width;
- NSPoint topleftbase;
- NSPoint topleftscreen;
+ NSSize newsize;
+ if( p_vout->render.i_height * p_vout->render.i_aspect >
+ p_vout->render.i_width * VOUT_ASPECT_FACTOR )
+ {
+ i_corrected_width = p_vout->render.i_height * p_vout->render.i_aspect /
+ VOUT_ASPECT_FACTOR;
+ newsize.width = (int) ( i_corrected_width * factor );
+ newsize.height = (int) ( p_vout->render.i_height * factor );
+ }
+ else
+ {
+ i_corrected_height = p_vout->render.i_width * VOUT_ASPECT_FACTOR /
+ p_vout->render.i_aspect;
+ newsize.width = (int) ( p_vout->render.i_width * factor );
+ newsize.height = (int) ( i_corrected_height * factor );
+ }
+
+ return newsize;
+}
+
+- (void)scaleWindowWithFactor: (float)factor animate: (BOOL)animate
+{
if ( !p_vout->b_fullscreen )
{
+ NSSize newsize;
+ NSPoint topleftbase;
+ NSPoint topleftscreen;
NSView *mainView;
NSRect new_frame;
topleftbase.x = 0;
topleftbase.y = [o_window frame].size.height;
topleftscreen = [o_window convertBaseToScreen: topleftbase];
- if( p_vout->render.i_height * p_vout->render.i_aspect >
- p_vout->render.i_width * VOUT_ASPECT_FACTOR )
- {
- i_corrected_width = p_vout->render.i_height * p_vout->render.i_aspect /
- VOUT_ASPECT_FACTOR;
- newsize.width = (int) ( i_corrected_width * factor );
- newsize.height = (int) ( p_vout->render.i_height * factor );
- }
- else
- {
- i_corrected_height = p_vout->render.i_width * VOUT_ASPECT_FACTOR /
- p_vout->render.i_aspect;
- newsize.width = (int) ( p_vout->render.i_width * factor );
- newsize.height = (int) ( i_corrected_height * factor );
- }
+ newsize = [self voutSizeForFactor:factor];
/* In fullscreen mode we need to use a view that is different from
* ourselves, with the VLCEmbeddedWindow */
new_frame.origin.x = topleftscreen.x;
new_frame.origin.y = topleftscreen.y - new_frame.size.height;
- [o_window setFrame: new_frame display: animate animate: animate];
-
+ [o_window setFrame:new_frame display:animate animate:animate];
p_vout->i_changes |= VOUT_SIZE_CHANGE;
}
}
if( !p_real_vout ) return;
if( var_Get( p_real_vout, "video-on-top", &val )>=0 && val.b_bool)
{
- val.b_bool = VLC_FALSE;
+ val.b_bool = false;
}
else
{
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
}
var_Set( p_real_vout, "video-on-top", val );
}
- (void)mouseDown:(NSEvent *)o_event
{
vlc_value_t val;
-
if( p_vout )
{
if( ( [o_event type] == NSLeftMouseDown ) &&
if( p_vout && [o_event type] == NSLeftMouseUp )
{
vlc_value_t b_val;
- b_val.b_bool = VLC_TRUE;
+ b_val.b_bool = true;
var_Set( p_vout, "mouse-clicked", b_val );
var_Get( p_vout, "mouse-button-down", &val );
}
var_Set( p_vout, "mouse-y", val );
- val.b_bool = VLC_TRUE;
+ val.b_bool = true;
var_Set( p_vout, "mouse-moved", val );
}
if( [self isFullscreen] )
- (void)enterFullscreen
{
- [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
- [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
+ /* Save the settings for next playing item */
+ playlist_t * p_playlist = pl_Yield( p_real_vout );
+ var_SetBool( p_playlist, "fullscreen", true );
+ pl_Release( p_real_vout );
}
- (void)leaveFullscreen
{
- [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES];
- [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
+ /* Save the settings for next playing item */
+ playlist_t * p_playlist = pl_Yield( p_real_vout );
+ var_SetBool( p_playlist, "fullscreen", false );
+ pl_Release( p_real_vout );
}
@end
return self;
}
+- (BOOL)mouseDownCanMoveWindow
+{
+ return YES;
+}
+
- (bool)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
frame: (NSRect *) s_arg_frame
{
i_time_mouse_last_moved = mdate();
o_window = [[VLCVoutWindow alloc] initWithVout: p_arg_vout view: self
frame: s_arg_frame];
+
[self updateTitle];
- [view setFrame: [self frame]];
-
- if( var_GetBool( p_real_vout, "video-on-top" ) )
- {
- [o_window setLevel: NSStatusWindowLevel];
- }
-
+ if([self isFullscreen])
+ [o_window performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: YES];
+ else
+ [view setFrame: [self frame]];
- [o_window setAcceptsMouseMovedEvents: TRUE];
return b_return;
}
- (void)closeVout
{
- [o_window closeWindow];
- [o_window setAcceptsMouseMovedEvents: NO];
+ [o_window performSelectorOnMainThread: @selector(close) withObject: NULL waitUntilDone: YES];
i_time_mouse_last_moved = 0;
[super closeVout];
}
}
}
+
+- (void)enterFullscreen
+{
+ [super enterFullscreen];
+ [o_window performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: NO];
+
+}
+
+- (void)leaveFullscreen
+{
+ [super leaveFullscreen];
+ [o_window performSelectorOnMainThread: @selector(leaveFullscreen) withObject: NULL waitUntilDone: NO];
+}
+
@end
/*****************************************************************************
@implementation VLCEmbeddedVoutView
+- (void)awakeFromNib
+{
+ o_embeddedwindow = [self window];
+}
+
+- (BOOL)mouseDownCanMoveWindow
+{
+ return YES;
+}
+
- (id)initWithFrame: (NSRect)frameRect
{
- [super initWithFrame: frameRect];
- b_used = NO;
- [[[VLCMain sharedInstance] getEmbeddedList] addEmbeddedVout: self];
+ if(self = [super initWithFrame: frameRect])
+ {
+ b_used = NO;
+ [[[VLCMain sharedInstance] getEmbeddedList] addEmbeddedVout: self];
+ o_embeddedwindow = nil; /* Filled later on in -awakeFromNib */
+ }
return self;
}
- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
- frame: (NSRect *)s_arg_frame showWindow: (BOOL)b_show_window
+ frame: (NSRect *)s_arg_frame
{
BOOL b_return;
+
+ [NSObject cancelPreviousPerformRequestsWithTarget:o_window];
+
b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame];
if( b_return )
{
o_window = [self window];
- if (b_show_window)
- [o_window makeKeyAndOrderFront: self];
+
[o_window setAcceptsMouseMovedEvents: TRUE];
if( var_GetBool( p_real_vout, "video-on-top" ) )
[view setFrameSize: [self frame].size];
}
- return b_return;
-}
-
-- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
- frame: (NSRect *) s_arg_frame
-
-{
- return [self setVout: p_arg_vout subView: view frame:s_arg_frame showWindow: YES];
-}
-
-- (void)setUsed: (BOOL)b_new_used
-{
- b_used = b_new_used;
-}
-
-- (BOOL)isUsed
-{
- return b_used;
-}
-
-- (void)closeVout
-{
- [super closeVout];
- [o_window setAcceptsMouseMovedEvents: NO];
- [[[VLCMain sharedInstance] getEmbeddedList] releaseEmbeddedVout: self];
-}
-
-
-@end
-
-@implementation VLCDetachedEmbeddedVoutView
-- (void)awakeFromNib
-{
- o_embeddedwindow = [self window];
-}
-
-- (BOOL)setVout: (vout_thread_t *) p_arg_vout subView: (NSView *) view
- frame: (NSRect *) s_arg_frame
-{
- BOOL b_return = [super setVout: p_arg_vout subView: view frame: s_arg_frame showWindow: NO];
/* o_window needs to point to our o_embeddedwindow, super might have set it
* to the fullscreen window that o_embeddedwindow setups during fullscreen */
[self updateTitle];
+ [NSObject cancelPreviousPerformRequestsWithTarget:o_window];
+
/* Make the window the front and key window before animating */
if ([o_window isVisible] && (![o_window isFullscreen]))
[o_window makeKeyAndOrderFront: self];
[self scaleWindowWithFactor: 1.0 animate: [o_window isVisible] && (![o_window isFullscreen])];
- [o_window setAspectRatio:NSMakeSize([o_window frame].size.width, [o_window frame].size.height)];
+ [o_embeddedwindow setVideoRatio:[self voutSizeForFactor:1.0]];
/* Make sure our window is visible, if we are not in fullscreen */
if (![o_window isFullscreen])
[o_window unlockFullscreenAnimation];
}
+
return b_return;
}
-- (void)closeVout
+- (void)setUsed: (BOOL)b_new_used
{
- playlist_t * p_playlist = pl_Yield( VLCIntf );
+ b_used = b_new_used;
+}
- if(!playlist_IsPlaying( p_playlist ))
- [o_window performSelectorOnMainThread: @selector(orderOut:) withObject: self waitUntilDone: YES];
-
- vlc_object_release( p_playlist );
+- (BOOL)isUsed
+{
+ return b_used;
+}
+- (void)closeVout
+{
[super closeVout];
+
+ /* Don't close the window yet, wait a bit to see if a new input is poping up */
+ /* FIXME: Probably fade the window In and Out */
+ /* FIXME: fix core */
+ [o_embeddedwindow performSelector:@selector(orderOut:) withObject:nil afterDelay:3.];
+
+ [o_window setAcceptsMouseMovedEvents: NO];
+ [[[VLCMain sharedInstance] getEmbeddedList] releaseEmbeddedVout: self];
}
- (void)enterFullscreen
{
+ /* Save settings */
+ [super enterFullscreen];
+
/* We are in a VLCEmbeddedWindow */
[o_embeddedwindow performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: YES];
}
- (void)leaveFullscreen
{
+ /* Save settings */
+ [super leaveFullscreen];
+
/* We are in a VLCEmbeddedWindow */
[o_embeddedwindow performSelectorOnMainThread: @selector(leaveFullscreen) withObject: NULL waitUntilDone: YES];
}
p_vout = vout;
o_view = view;
s_frame = frame;
-
- [self performSelectorOnMainThread: @selector(initReal:)
+ b_init_ok = NO;
+ [self performSelectorOnMainThread: @selector(initMainThread:)
withObject: NULL waitUntilDone: YES];
- if( !b_init_ok )
- {
- return NULL;
- }
-
- return self;
+ return b_init_ok ? self : nil;
}
-- (id)initReal: (id) sender
+- (id)initMainThread: (id) sender
{
- NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
- NSArray *o_screens = [NSScreen screens];
- NSScreen *o_screen;
- vlc_bool_t b_menubar_screen = VLC_FALSE;
- int i_device;
-
- b_init_ok = VLC_FALSE;
-
- p_real_vout = [VLCVoutView getRealVout: p_vout];
- i_device = var_GetInteger( p_real_vout->p_libvlc, "video-device" );
- b_black = NO;
- b_embedded = var_GetBool( p_vout, "embedded-video" );
-
- /* Find out on which screen to open the window */
- o_screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
-
- if( !o_screen )
- o_screen = [NSScreen mainScreen];
-
- if( [o_screen isMainScreen] )
- b_menubar_screen = VLC_TRUE;
+ NSRect rect;
+ rect.size.height = p_vout->i_window_height;
+ rect.size.width = p_vout->i_window_width;
+ rect.origin.x = rect.origin.y = 70.;
- if( p_vout->b_fullscreen )
+ if( self = [super initWithContentRect:rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO])
{
- CGDisplayFadeReservationToken token;
- NSRect screen_rect = [o_screen frame];
- screen_rect.origin.x = screen_rect.origin.y = 0;
-
- b_black = var_GetBool( p_vout, "macosx-black" );
-
- /* move the FSPanel to front in case that it is currently shown
- * this won't and is not supposed to work when it's fading right now */
- if( [[[[VLCMain sharedInstance] getControls] getFSPanel] isDisplayed] )
- [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
-
- /* tell the fspanel to move itself to front next time it's triggered */
- [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
-
- /* Creates a window with size: screen_rect on o_screen */
- [self initWithContentRect: screen_rect
- styleMask: NSBorderlessWindowMask
- backing: NSBackingStoreBuffered
- defer: YES screen: o_screen];
-
- if( b_menubar_screen )
+ [self setBackgroundColor:[NSColor blackColor]];
+ [self setHasShadow:YES];
+ [self setMovableByWindowBackground: YES];
+ [self center];
+ [self makeKeyAndOrderFront: self];
+ [self setReleasedWhenClosed: YES];
+
+ /* We'll catch mouse events */
+ [self makeFirstResponder: o_view];
+ [self setCanBecomeKeyWindow: YES];
+
+ if( var_GetBool( p_vout, "macosx-background" ) )
{
- SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
- }
- if( b_black == VLC_TRUE )
- {
- CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
- CGDisplayFade( token, 0.6 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
+ int i_device = var_GetInteger( p_vout->p_libvlc, "video-device" );
- [o_screen blackoutOtherScreens];
+ /* Find out on which screen to open the window */
+ NSScreen * screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
+ if( !screen ) screen = [NSScreen mainScreen];
- CGDisplayFade( token, 0.3 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
- CGReleaseDisplayFadeReservation( token);
- }
- }
- else if( var_GetBool( p_vout, "macosx-background" ) )
- {
- NSRect screen_rect = [o_screen frame];
- screen_rect.origin.x = screen_rect.origin.y = 0;
+ NSRect screen_rect = [screen frame];
+ screen_rect.origin.x = screen_rect.origin.y = 0;
- /* Creates a window with size: screen_rect on o_screen */
- [self initWithContentRect: screen_rect
- styleMask: NSBorderlessWindowMask
- backing: NSBackingStoreBuffered
- defer: YES screen: o_screen];
+ /* Creates a window with size: screen_rect on o_screen */
+ [self setFrame: screen_rect display: NO];
- [self setLevel: CGWindowLevelForKey(kCGDesktopWindowLevelKey)];
- }
- else
- {
- unsigned int i_stylemask = NSTitledWindowMask |
- NSMiniaturizableWindowMask |
- NSClosableWindowMask |
- NSResizableWindowMask;
-
- NSRect s_rect;
- if( !s_frame )
- {
- s_rect.size.width = p_vout->i_window_width;
- s_rect.size.height = p_vout->i_window_height;
+ [self setLevel: CGWindowLevelForKey(kCGDesktopWindowLevelKey)];
+ [self setMovableByWindowBackground: NO];
}
- else
+ if( var_GetBool( p_vout, "video-on-top" ) )
{
- s_rect = *s_frame;
+ [self setLevel: NSStatusWindowLevel];
}
- [self initWithContentRect: s_rect
- styleMask: i_stylemask
- backing: NSBackingStoreBuffered
- defer: YES screen: o_screen];
-
[self setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )];
- if( !s_frame )
- {
- [self center];
- }
- }
-
- [self makeKeyAndOrderFront: nil];
- [self setReleasedWhenClosed: YES];
-
- /* We'll catch mouse events */
- [self makeFirstResponder: o_view];
-
- /* Add the view. It's automatically resized to fit the window */
- [self setContentView: o_view];
+ /* Add the view. It's automatically resized to fit the window */
+ [self setContentView: o_view];
- [o_pool release];
-
- b_init_ok = VLC_TRUE;
+ b_init_ok = YES;
+ }
return self;
}
-- (void)close
+- (void)enterFullscreen
{
- [o_view closeVout];
-}
+ if( fullscreen ) return;
-- (void)closeWindow
-{
- /* XXX waitUntilDone = NO to avoid a possible deadlock when hitting
- Command-Q */
- [self performSelectorOnMainThread: @selector(closeReal:)
- withObject: NULL waitUntilDone: NO];
-}
+ NSScreen *screen;
+ int i_device;
+ BOOL b_black = NO;
-- (id)closeReal:(id)sender
-{
- if( b_black == VLC_TRUE )
+ i_device = var_GetInteger( p_vout->p_libvlc, "video-device" );
+ b_black = var_GetBool( p_vout, "macosx-black" );
+
+ /* Find out on which screen to open the window */
+ screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
+ if( !screen ) screen = [self screen];
+
+ if( b_black && [[NSScreen screens] count] > 1)
{
CGDisplayFadeReservationToken token;
CGAcquireDisplayFadeReservation(kCGMaxDisplayReservationInterval, &token);
- CGDisplayFade( token, 0.3 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
-
- [self disableScreenUpdatesUntilFlush];
- [self orderOut: self];
+ CGDisplayFade( token, 0.2 , kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0, 0, 0, YES );
+
+ [screen blackoutOtherScreens];
- CGDisplayFade( token, 0.6 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, YES );
+ CGDisplayFade( token, 0.1 , kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0, 0, 0, NO );
CGReleaseDisplayFadeReservation( token);
- CGDisplayRestoreColorSyncSettings();
}
- [NSScreen unblackoutScreens];
- SetSystemUIMode( kUIModeNormal, 0);
- [super close];
- /* this does only work in embedded mode */
- if( b_embedded == VLC_TRUE )
- [[[[VLCMain sharedInstance] getControls] getFSPanel] orderOut: self];
+ [self setMovableByWindowBackground: NO];
- return NULL;
-}
+ /* tell the fspanel to move itself to front next time it's triggered */
+ [[[[VLCMain sharedInstance] getControls] getFSPanel] setVoutWasUpdated: i_device];
+ [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil];
-- (id)getVoutView
-{
- return o_view;
-}
+ if( [screen isMainScreen] )
+ SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar);
-- (BOOL)canBecomeKeyWindow
-{
- return YES;
+ initialFrame = [self frame];
+ [self setFrame:[screen frame] display:YES animate:YES];
+ fullscreen = YES;
}
-/* Sometimes crashes VLC....
-- (BOOL)performKeyEquivalent:(NSEvent *)o_event
-{
- return [[VLCMain sharedInstance] hasDefinedShortcutKey:o_event];
-}*/
-
-/* This is actually the same as VLCControls::stop. */
-
-- (BOOL)windowShouldClose:(id)sender
+- (void)leaveFullscreen
{
- playlist_t * p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- if( p_playlist == NULL )
- {
- return NO;
- }
+ if( !fullscreen ) return;
+ fullscreen = NO;
- playlist_Stop( p_playlist );
- vlc_object_release( p_playlist );
+ [NSScreen unblackoutScreens];
- /* The window will be closed by the intf later. */
- return NO;
+ [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil];
+ SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar);
+ [self setFrame:initialFrame display:YES animate:YES];
+ [self setMovableByWindowBackground: YES];
}
+- (id)getVoutView // FIXME Naming scheme!
+{
+ return o_view;
+}
@end
+