📄 vout.m
字号:
/* 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{ /* 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/***************************************************************************** * VLCDetachedVoutView implementation *****************************************************************************/@implementation VLCDetachedVoutView- (id)initWithFrame: (NSRect)frameRect{ [super initWithFrame: frameRect]; i_time_mouse_last_moved = 0; return self;}- (BOOL)mouseDownCanMoveWindow{ return YES;}- (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]; i_time_mouse_last_moved = mdate(); o_window = [[VLCVoutWindow alloc] initWithVout: p_arg_vout view: self frame: s_arg_frame]; [self updateTitle]; if([self isFullscreen]) [o_window performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: YES]; else [view setFrame: [self frame]]; return b_return;}- (void)closeVout{ [o_window performSelectorOnMainThread: @selector(close) withObject: NULL waitUntilDone: YES]; i_time_mouse_last_moved = 0; [super closeVout];}- (void)mouseMoved:(NSEvent *)o_event{ i_time_mouse_last_moved = mdate(); [super mouseMoved: o_event];}- (void)hideMouse:(BOOL)b_hide{ BOOL b_inside; NSPoint ml; NSView *o_contents = [o_window contentView]; ml = [o_window convertScreenToBase:[NSEvent mouseLocation]]; ml = [o_contents convertPoint:ml fromView:nil]; b_inside = [o_contents mouse: ml inRect: [o_contents bounds]]; if( b_hide && b_inside ) { [NSCursor setHiddenUntilMouseMoves: YES]; } else if( !b_hide ) { [NSCursor setHiddenUntilMouseMoves: NO]; }}- (void)manage{ /* Dooh, why do we spend processor time doing this kind of stuff? */ [super manage]; unsigned int i_mouse_hide_timeout = var_CreateGetInteger(p_vout, "mouse-hide-timeout") * 1000; if( i_mouse_hide_timeout < 100000 ) i_mouse_hide_timeout = 100000; if( p_vout->b_fullscreen ) { if( mdate() - i_time_mouse_last_moved > i_mouse_hide_timeout ) { i_time_mouse_last_moved = mdate(); [self hideMouse: YES]; } } else { [self hideMouse: NO]; }}- (void)enterFullscreen{ [o_window performSelectorOnMainThread: @selector(enterFullscreen) withObject: NULL waitUntilDone: NO]; [super enterFullscreen];}- (void)leaveFullscreen{ [o_window performSelectorOnMainThread: @selector(leaveFullscreen) withObject: NULL waitUntilDone: NO]; [super leaveFullscreen];}- (void)scaleWindowWithFactor: (float)factor animate: (BOOL)animate{ if( p_vout->b_fullscreen ) return; [o_window setMovableByWindowBackground: NO]; [super scaleWindowWithFactor: factor animate: animate]; [o_window setMovableByWindowBackground: YES];}@end/***************************************************************************** * VLCEmbeddedVoutView implementation *****************************************************************************/@implementation VLCEmbeddedVoutView- (void)awakeFromNib{ o_embeddedwindow = [self window];}- (BOOL)mouseDownCanMoveWindow{ return YES;}- (id)initWithFrame: (NSRect)frameRect{ 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{ 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]; [o_window setAcceptsMouseMovedEvents: TRUE]; if( var_CreateGetBool( p_real_vout, "video-on-top" ) ) { [o_window setLevel: NSStatusWindowLevel]; } [view setFrameSize: [self frame].size]; } /* 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 ) { [o_window lockFullscreenAnimation]; [o_window setAlphaValue: var_GetFloat( p_vout, "macosx-opaqueness" )]; [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_embeddedwindow setVideoRatio:[self voutSizeForFactor:1.0]]; /* 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;}- (void)setUsed: (BOOL)b_new_used{ b_used = b_new_used;}- (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.]; [[[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];}@end/***************************************************************************** * VLCVoutWindow implementation *****************************************************************************/@implementation VLCVoutWindow- (id) initWithVout: (vout_thread_t *) vout view: (VLCVoutView *) view frame: (NSRect *) frame{ p_vout = vout; o_view = view; s_frame = frame; b_init_ok = NO; [self performSelectorOnMainThread: @selector(initMainThread:) withObject: NULL waitUntilDone: YES]; return b_init_ok ? self : nil;}- (id)initMainThread: (id) sender{ 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( self = [super initWithContentRect:rect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO]) { [self setBackgroundColor:[NSColor blackColor]]; [self setHasShadow:YES]; [self setMovableByWindowBackground: YES]; [self center]; [self makeKeyAndOrderFront: self]; [self setReleasedWhenClosed: YES]; [self setFrameUsingName:@"VLCVoutWindowDetached"]; [self setFrameAutosaveName:@"VLCVoutWindowDetached"]; /* We'll catch mouse events */ [self makeFirstResponder: o_view]; [self setCanBecomeKeyWindow: YES]; [self setAcceptsMouseMovedEvents: YES]; [self setIgnoresMouseEvents: NO]; if( var_CreateGetBool( p_vout, "macosx-background" ) ) { int i_device = var_GetInteger( p_vout->p_libvlc, "video-device" ); /* Find out on which screen to open the window */ NSScreen * screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device]; if( !screen ) screen = [NSScreen mainScreen]; 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 setFrame: screen_rect display: NO]; [self setLevel: CGWindowLevelForKey(kCGDesktopWindowLevelKey)]; [self setMovableByWindowBackground: NO]; } if( var_CreateGetBool( p_vout, "video-on-top" ) ) { [self setLevel: NSStatusWindowLevel]; } [self setAlphaValue: var_CreateGetFloat( p_vout, "macosx-opaqueness" )]; /* Add the view. It's automatically resized to fit the window */ [self setContentView: o_view]; b_init_ok = YES; } return self;}- (void)enterFullscreen{ if( fullscreen ) return; NSScreen *screen; int i_device; BOOL b_black = NO; i_device = var_GetInteger( p_vout->p_libvlc, "video-device" ); b_black = var_CreateGetBool( 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 ) [screen blackoutOtherScreens]; [self setMovableByWindowBackground: NO]; if( [screen isMainScreen] ) SetSystemUIMode( kUIModeAllHidden, kUIOptionAutoShowMenuBar); initialFrame = [self frame]; [self setFrame:[screen frame] display:YES animate:YES]; [self setLevel:NSNormalWindowLevel]; /* 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]; fullscreen = YES;}- (void)leaveFullscreen{ if( !fullscreen ) return; fullscreen = NO; [NSScreen unblackoutScreens]; [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil]; SetSystemUIMode( kUIModeNormal, kUIOptionAutoShowMenuBar); [self setFrame:initialFrame display:YES animate:YES]; [self setMovableByWindowBackground: YES]; if( var_GetBool( p_vout, "video-on-top" ) ) [self setLevel: NSStatusWindowLevel];}- (id)getVoutView // FIXME Naming scheme!{ return o_view;}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -