📄 vout.m
字号:
* ourselves, with the VLCEmbeddedWindow */ if([o_window isKindOfClass:[VLCEmbeddedWindow class]]) mainView = [o_window mainView]; else mainView = self; /* Calculate the window's new size */ new_frame.size.width = [o_window frame].size.width - [mainView frame].size.width + newsize.width; new_frame.size.height = [o_window frame].size.height - [mainView frame].size.height + newsize.height; 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]; p_vout->i_changes |= VOUT_SIZE_CHANGE; }}- (void)toggleFloatOnTop{ vlc_value_t val; if( !p_real_vout ) return; if( var_Get( p_real_vout, "video-on-top", &val )>=0 && val.b_bool) { val.b_bool = false; } else { val.b_bool = true; } var_Set( p_real_vout, "video-on-top", val );}- (void)toggleFullscreen{ vlc_value_t val; if( !p_real_vout ) return; var_Get( p_real_vout, "fullscreen", &val ); val.b_bool = !val.b_bool; var_Set( p_real_vout, "fullscreen", val );}- (BOOL)isFullscreen{ vlc_value_t val; if( !p_real_vout ) return NO; var_Get( p_real_vout, "fullscreen", &val ); return( val.b_bool );}- (void)snapshot{ vout_Control( p_real_vout, VOUT_SNAPSHOT );}- (void)manage{ /* Disable Screensaver, when we're playing something, but allow it on pause */ if( !VLCIntf || !VLCIntf->p_sys ) return; if( VLCIntf->p_sys->i_play_status == PLAYING_S ) UpdateSystemActivity( UsrActivity );}- (id)getWindow{ return o_window;}- (void)scrollWheel:(NSEvent *)theEvent{ VLCControls * o_controls = (VLCControls *)[[NSApp delegate] getControls]; [o_controls scrollWheel: theEvent];}- (void)keyDown:(NSEvent *)o_event{ unichar key = 0; vlc_value_t val; unsigned int i_pressed_modifiers = 0; val.i_int = 0; i_pressed_modifiers = [o_event modifierFlags]; if( i_pressed_modifiers & NSShiftKeyMask ) val.i_int |= KEY_MODIFIER_SHIFT; if( i_pressed_modifiers & NSControlKeyMask ) val.i_int |= KEY_MODIFIER_CTRL; if( i_pressed_modifiers & NSAlternateKeyMask ) val.i_int |= KEY_MODIFIER_ALT; if( i_pressed_modifiers & NSCommandKeyMask ) val.i_int |= KEY_MODIFIER_COMMAND; key = [[[o_event charactersIgnoringModifiers] lowercaseString] characterAtIndex: 0]; if( key ) { /* Escape should always get you out of fullscreen */ if( key == (unichar) 0x1b ) { if( p_real_vout && [self isFullscreen] ) { [self toggleFullscreen]; } } else if ( p_vout ) { if( key == ' ') val.i_int = config_GetInt( p_vout, "key-play-pause" ); else val.i_int |= (int)CocoaKeyToVLC( key ); var_Set( p_vout->p_libvlc, "key-pressed", val ); } else NSLog( @"Could not send keyevent to VLC core" ); } else [super keyDown: o_event];}- (void)mouseDown:(NSEvent *)o_event{ vlc_value_t val; if( p_vout ) { if( ( [o_event type] == NSLeftMouseDown ) && ( ! ( [o_event modifierFlags] & NSControlKeyMask ) ) ) { if( [o_event clickCount] <= 1 ) { /* single clicking */ var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 1; var_Set( p_vout, "mouse-button-down", val ); } else { /* multiple clicking */ [self toggleFullscreen]; } } else if( ( [o_event type] == NSRightMouseDown ) || ( ( [o_event type] == NSLeftMouseDown ) && ( [o_event modifierFlags] & NSControlKeyMask ) ) ) { msg_Dbg( p_vout, "received NSRightMouseDown (generic method) or Ctrl clic" ); [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]]; } } [super mouseDown: o_event];}- (void)otherMouseDown:(NSEvent *)o_event{ vlc_value_t val; if( p_vout && [o_event type] == NSOtherMouseDown ) { var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 2; var_Set( p_vout, "mouse-button-down", val ); } [super mouseDown: o_event];}- (void)rightMouseDown:(NSEvent *)o_event{ if( p_vout && [o_event type] == NSRightMouseDown ) { msg_Dbg( p_vout, "received NSRightMouseDown (specific method)" ); [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]]; } [super mouseDown: o_event];}- (void)mouseUp:(NSEvent *)o_event{ vlc_value_t val; if( p_vout && [o_event type] == NSLeftMouseUp ) { vlc_value_t b_val; b_val.b_bool = true; var_Set( p_vout, "mouse-clicked", b_val ); var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~1; var_Set( p_vout, "mouse-button-down", val ); } [super mouseUp: o_event];}- (void)otherMouseUp:(NSEvent *)o_event{ vlc_value_t val; if( p_vout && [o_event type] == NSOtherMouseUp ) { var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~2; var_Set( p_vout, "mouse-button-down", val ); } [super mouseUp: o_event];}- (void)rightMouseUp:(NSEvent *)o_event{ if( p_vout && [o_event type] == NSRightMouseUp ) { /* FIXME: this isn't the appropriate place, but we can't receive * NSRightMouseDown some how */ msg_Dbg( p_vout, "received NSRightMouseUp" ); [NSMenu popUpContextMenu: [[VLCMain sharedInstance] getVoutMenu] withEvent: o_event forView: [[[VLCMain sharedInstance] getControls] getVoutView]]; } [super mouseUp: o_event];}- (void)mouseDragged:(NSEvent *)o_event{ [self mouseMoved: o_event];}- (void)otherMouseDragged:(NSEvent *)o_event{ [self mouseMoved: o_event];}- (void)rightMouseDragged:(NSEvent *)o_event{ [self mouseMoved: o_event];}- (void)mouseMoved:(NSEvent *)o_event{ NSPoint ml; NSRect s_rect; BOOL b_inside; if( p_vout ) { s_rect = [o_view bounds]; ml = [o_view convertPoint: [o_event locationInWindow] fromView: nil]; b_inside = [o_view mouse: ml inRect: s_rect]; if( b_inside ) { vlc_value_t val; unsigned int i_width, i_height, i_x, i_y; vout_PlacePicture( p_vout, (unsigned int)s_rect.size.width, (unsigned int)s_rect.size.height, &i_x, &i_y, &i_width, &i_height ); val.i_int = ( ((int)ml.x) - i_x ) * p_vout->render.i_width / i_width; var_Set( p_vout, "mouse-x", val ); if( [[o_view className] isEqualToString: @"VLCGLView"] ) { val.i_int = ( ((int)(s_rect.size.height - ml.y)) - i_y ) * p_vout->render.i_height / i_height; } else { val.i_int = ( ((int)ml.y) - i_y ) * p_vout->render.i_height / i_height; } var_Set( p_vout, "mouse-y", val ); val.b_bool = true; var_Set( p_vout, "mouse-moved", val ); } if( [self isFullscreen] ) [[[[VLCMain sharedInstance] getControls] getFSPanel] fadeIn]; } [super mouseMoved: o_event];}- (BOOL)acceptsFirstResponder{ return YES;}- (BOOL)becomeFirstResponder{ return YES;}- (BOOL)resignFirstResponder{ /* We need to stay the first responder or we'll miss some events */ return NO;}/* Class methods used by the different vout modules */+ (vout_thread_t *)getRealVout: (vout_thread_t *)p_vout{ /* p_real_vout: the vout we have to use to check for video-on-top and a few other things. If we are the QuickTime output, it's us. It we are the OpenGL provider, it is our parent. */ if( p_vout->i_object_type == VLC_OBJECT_OPENGL ) { return (vout_thread_t *) p_vout->p_parent; } else { return p_vout; }}+ (id)getVoutView: (vout_thread_t *)p_vout subView: (NSView *)view frame: (NSRect *)s_frame{ vlc_value_t value_drawable; int i_timeout; id o_return = nil; var_Get( p_vout->p_libvlc, "drawable", &value_drawable ); var_Create( p_vout, "macosx-vdev", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-stretch", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-opaqueness", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-background", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "macosx-black", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_vout, "embedded-video", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); /* We only wait for NSApp to initialise if we're not embedded (as in the * case of the Mozilla plugin). We can tell whether we're embedded or not * by examining the "drawable" value: if it's zero, we're running in the * main Mac intf; if it's non-zero, we're embedded. */ if( value_drawable.i_int == 0 ) { /* Wait for a MacOS X interface to appear. Timeout is 2 seconds. */ for( i_timeout = 20 ; i_timeout-- ; ) { if( NSApp == NULL ) { msleep( INTF_IDLE_SLEEP ); } } if( NSApp == NULL ) { /* No MacOS X intf, unable to communicate with MT */ msg_Err( p_vout, "no MacOS X interface present" ); return nil; } else { if ( VLCIntf && !(p_vout->b_fullscreen) && !(var_GetBool( p_vout, "macosx-background" )) && var_GetBool( p_vout, "embedded-video") ) { o_return = [[[VLCMain sharedInstance] getEmbeddedList] getEmbeddedVout]; } } } /* No embedded vout is available */ if( o_return == nil ) { NSRect null_rect; bzero( &null_rect, sizeof( NSRect ) ); o_return = [[VLCDetachedVoutView alloc] initWithFrame: null_rect ]; } [o_return setVout: p_vout subView: view frame: s_frame]; return o_return;}- (void)enterFullscreen{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -