📄 xcommon.c
字号:
var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 2; var_Set( p_vout, "mouse-button-down", val ); break; case Button3: var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 4; var_Set( p_vout, "mouse-button-down", val ); break; case Button4: var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 8; var_Set( p_vout, "mouse-button-down", val ); break; case Button5: var_Get( p_vout, "mouse-button-down", &val ); val.i_int |= 16; var_Set( p_vout, "mouse-button-down", val ); break; } } /* Mouse release */ else if( xevent.type == ButtonRelease ) { switch( ((XButtonEvent *)&xevent)->button ) { case Button1: var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~1; var_Set( p_vout, "mouse-button-down", val ); val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-clicked", val ); break; case Button2: { playlist_t *p_playlist; var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~2; var_Set( p_vout, "mouse-button-down", val ); p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist != NULL ) { vlc_value_t val; var_Get( p_playlist, "intf-show", &val ); val.b_bool = !val.b_bool; var_Set( p_playlist, "intf-show", val ); vlc_object_release( p_playlist ); } } break; case Button3: { intf_thread_t *p_intf; playlist_t *p_playlist; var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~4; var_Set( p_vout, "mouse-button-down", val ); p_intf = vlc_object_find( p_vout, VLC_OBJECT_INTF, FIND_ANYWHERE ); if( p_intf ) { p_intf->b_menu_change = 1; vlc_object_release( p_intf ); } p_playlist = vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist != NULL ) { vlc_value_t val; val.b_bool = VLC_TRUE; var_Set( p_playlist, "intf-popupmenu", val ); vlc_object_release( p_playlist ); } } break; case Button4: var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~8; var_Set( p_vout, "mouse-button-down", val ); break; case Button5: var_Get( p_vout, "mouse-button-down", &val ); val.i_int &= ~16; var_Set( p_vout, "mouse-button-down", val ); break; } } /* Mouse move */ else if( xevent.type == MotionNotify ) { unsigned int i_width, i_height, i_x, i_y; vlc_value_t val; /* somewhat different use for vout_PlacePicture: * here the values are needed to give to mouse coordinates * in the original picture space */ vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width, p_vout->p_sys->p_win->i_height, &i_x, &i_y, &i_width, &i_height ); val.i_int = ( xevent.xmotion.x - i_x ) * p_vout->fmt_in.i_visible_width / i_width + p_vout->fmt_in.i_x_offset; var_Set( p_vout, "mouse-x", val ); val.i_int = ( xevent.xmotion.y - i_y ) * p_vout->fmt_in.i_visible_height / i_height + p_vout->fmt_in.i_y_offset; var_Set( p_vout, "mouse-y", val ); val.b_bool = VLC_TRUE; var_Set( p_vout, "mouse-moved", val ); p_vout->p_sys->i_time_mouse_last_moved = mdate(); if( ! p_vout->p_sys->b_mouse_pointer_visible ) { ToggleCursor( p_vout ); } } else if( xevent.type == ReparentNotify /* XXX: why do we get this? */ || xevent.type == MapNotify || xevent.type == UnmapNotify ) { /* Ignore these events */ } else /* Other events */ { msg_Warn( p_vout, "unhandled event %d received", xevent.type ); } } /* Handle events for video output sub-window */ while( XCheckWindowEvent( p_vout->p_sys->p_display, p_vout->p_sys->p_win->video_window, ExposureMask, &xevent ) == True ) { /* Window exposed (only handled if stream playback is paused) */ if( xevent.type == Expose ) { if( ((XExposeEvent *)&xevent)->count == 0 ) { /* (if this is the last a collection of expose events...) */#if 0 if( p_vout->p_vlc->p_input_bank->pp_input[0] != NULL ) { if( PAUSE_S == p_vout->p_vlc->p_input_bank->pp_input[0] ->stream.control.i_status ) { /* XVideoDisplay( p_vout )*/; } }#endif } } } /* ClientMessage event - only WM_PROTOCOLS with WM_DELETE_WINDOW data * are handled - according to the man pages, the format is always 32 * in this case */ while( XCheckTypedEvent( p_vout->p_sys->p_display, ClientMessage, &xevent ) ) { if( (xevent.xclient.message_type == p_vout->p_sys->p_win->wm_protocols) && ((Atom)xevent.xclient.data.l[0] == p_vout->p_sys->p_win->wm_delete_window ) ) { /* the user wants to close the window */ playlist_t * p_playlist = (playlist_t *)vlc_object_find( p_vout, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist != NULL ) { playlist_Stop( p_playlist ); vlc_object_release( p_playlist ); } } } /* * Fullscreen Change */ if ( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE ) { vlc_value_t val; /* Update the object variable and trigger callback */ val.b_bool = !p_vout->b_fullscreen; /* * FIXME FIXME FIXME FIXME: EXPLICIT HACK. * On the one hand, we cannot hold the lock while triggering a * callback, as it causes a deadlock with video-on-top handling. * On the other hand, we have to lock while triggering the * callback to: * 1/ make sure video-on-top remains in sync with fullscreen * (i.e. unlocking creates a race condition if fullscreen is * switched on and off VERY FAST). * 2/ avoid possible corruption bugs if another thread gets the * mutex and modifies our data in-between. * * This is obviously contradictory. Correct solutions may include: * - putting the fullscreen NAND video-on-top logic out of libvlc, * back into the video output plugins (ugly code duplication...), * - serializing fullscreen and video-on-top handling properly * instead of doing it via the fullscreen callback. That's got to * be the correct one. */#ifdef MODULE_NAME_IS_xvmc xvmc_context_reader_unlock( &p_vout->p_sys->xvmc_lock );#endif vlc_mutex_unlock( &p_vout->p_sys->lock ); var_Set( p_vout, "fullscreen", val ); vlc_mutex_lock( &p_vout->p_sys->lock );#ifdef MODULE_NAME_IS_xvmc xvmc_context_reader_lock( &p_vout->p_sys->xvmc_lock );#endif ToggleFullScreen( p_vout ); p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; } if( p_vout->i_changes & VOUT_CROP_CHANGE || p_vout->i_changes & VOUT_ASPECT_CHANGE ) { p_vout->i_changes &= ~VOUT_CROP_CHANGE; p_vout->i_changes &= ~VOUT_ASPECT_CHANGE; p_vout->fmt_out.i_x_offset = p_vout->fmt_in.i_x_offset; p_vout->fmt_out.i_y_offset = p_vout->fmt_in.i_y_offset; p_vout->fmt_out.i_visible_width = p_vout->fmt_in.i_visible_width; p_vout->fmt_out.i_visible_height = p_vout->fmt_in.i_visible_height; p_vout->fmt_out.i_aspect = p_vout->fmt_in.i_aspect; p_vout->fmt_out.i_sar_num = p_vout->fmt_in.i_sar_num; p_vout->fmt_out.i_sar_den = p_vout->fmt_in.i_sar_den; p_vout->output.i_aspect = p_vout->fmt_in.i_aspect; p_vout->i_changes |= VOUT_SIZE_CHANGE; } /* * Size change * * (Needs to be placed after VOUT_FULLSREEN_CHANGE because we can activate * the size flag inside the fullscreen routine) */ if( p_vout->i_changes & VOUT_SIZE_CHANGE ) { unsigned int i_width, i_height, i_x, i_y; p_vout->i_changes &= ~VOUT_SIZE_CHANGE;#ifdef MODULE_NAME_IS_x11 /* We need to signal the vout thread about the size change because it * is doing the rescaling */ p_vout->i_changes |= VOUT_SIZE_CHANGE;#endif vout_PlacePicture( p_vout, p_vout->p_sys->p_win->i_width, p_vout->p_sys->p_win->i_height, &i_x, &i_y, &i_width, &i_height ); XMoveResizeWindow( p_vout->p_sys->p_display, p_vout->p_sys->p_win->video_window, i_x, i_y, i_width, i_height ); } /* Autohide Cursour */ if( mdate() - p_vout->p_sys->i_time_mouse_last_moved > 2000000 ) { /* Hide the mouse automatically */ if( p_vout->p_sys->b_mouse_pointer_visible ) { ToggleCursor( p_vout ); } } vlc_mutex_unlock( &p_vout->p_sys->lock ); return 0;}/***************************************************************************** * EndVideo: terminate X11 video thread output method ***************************************************************************** * Destroy the X11 XImages created by Init. It is called at the end of * the thread, but also each time the window is resized. *****************************************************************************/static void EndVideo( vout_thread_t *p_vout ){ int i_index; /* Free the direct buffers we allocated */ for( i_index = I_OUTPUTPICTURES ; i_index ; ) { i_index--; FreePicture( p_vout, PP_OUTPUTPICTURE[ i_index ] ); }}/* following functions are local *//***************************************************************************** * CreateWindow: open and set-up X11 main window *****************************************************************************/static int CreateWindow( vout_thread_t *p_vout, x11_window_t *p_win ){ XSizeHints xsize_hints; XSetWindowAttributes xwindow_attributes; XGCValues xgcvalues; XEvent xevent; vlc_bool_t b_expose = VLC_FALSE; vlc_bool_t b_configure_notify = VLC_FALSE; vlc_bool_t b_map_notify = VLC_FALSE; vlc_value_t val; /* Prepare window manager hints and properties */ p_win->wm_protocols = XInternAtom( p_vout->p_sys->p_display, "WM_PROTOCOLS", True ); p_win->wm_delete_window = XInternAtom( p_vout->p_sys->p_display, "WM_DELETE_WINDOW", True ); /* Never have a 0-pixel-wide window */ xsize_hints.min_width = 2; xsize_hints.min_height = 1; /* Prepare window attributes */ xwindow_attributes.backing_store = Always; /* save the hidden part */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -