⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intf_gnome.c

📁 vlc stand 0.1.99 ist sehr einfach
💻 C
📖 第 1 页 / 共 2 页
字号:
static void GnomeManageWindow( intf_thread_t *p_intf ){    XEvent      xevent;                                         /* X11 event */    boolean_t   b_resized;                        /* window has been resized */    char        i_key;                                    /* ISO Latin-1 key */    /* Handle X11 events: ConfigureNotify events are parsed to know if the     * output window's size changed, MapNotify and UnmapNotify to know if the     * window is mapped (and if the display is useful), and ClientMessages     * to intercept window destruction requests */    b_resized = 0;    while( XCheckWindowEvent( p_intf->p_sys->p_display, p_intf->p_sys->window,                              StructureNotifyMask | KeyPressMask |                              ButtonPressMask, &xevent ) == True )    {        /* ConfigureNotify event: prepare  */        if( (xevent.type == ConfigureNotify)            && ((xevent.xconfigure.width != p_intf->p_sys->i_width)                || (xevent.xconfigure.height != p_intf->p_sys->i_height)) )        {            /* Update dimensions */            b_resized = 1;            p_intf->p_sys->i_width = xevent.xconfigure.width;            p_intf->p_sys->i_height = xevent.xconfigure.height;        }        /* MapNotify event: change window status and disable screen saver */        else if( xevent.type == MapNotify)        {            if( (p_intf->p_vout != NULL) && !p_intf->p_vout->b_active )            {                GnomeDisableScreenSaver( p_intf );                p_intf->p_vout->b_active = 1;            }        }        /* UnmapNotify event: change window status and enable screen saver */        else if( xevent.type == UnmapNotify )        {            if( (p_intf->p_vout != NULL) && p_intf->p_vout->b_active )            {                GnomeEnableScreenSaver( p_intf );                p_intf->p_vout->b_active = 0;            }        }        /* Keyboard event */        else if( xevent.type == KeyPress )        {            if( XLookupString( &xevent.xkey, &i_key, 1, NULL, NULL ) )            {                if( intf_ProcessKey( p_intf, i_key ) )                {                    intf_DbgMsg( "unhandled key '%c' (%i)\n", (char) i_key, i_key );                }            }        }        /* Mouse click */        else if( xevent.type == ButtonPress )        {            switch( ((XButtonEvent *)&xevent)->button )            {                case Button1:                    /* in this part we will eventually manage                     * clicks for DVD navigation for instance */                    break;                case Button2:                    GnomeTogglePointer( p_intf );                    break;                case Button3:                    /* toggle the menu display */                    vlc_mutex_lock( &p_intf->p_sys->p_gnome->change_lock );                    p_intf->p_sys->p_gnome->b_popup_changed = 1;                    vlc_mutex_unlock( &p_intf->p_sys->p_gnome->change_lock );                    break;            }        }        /* 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 */        else if( (xevent.type == ClientMessage)                 && (xevent.xclient.message_type == p_intf->p_sys->wm_protocols)                 && (xevent.xclient.data.l[0] == p_intf->p_sys->wm_delete_window ) )        {            /* FIXME: this never happens :( how to receive wm messages ?? */            intf_DbgMsg("ClientMessage received\n");        }#ifdef DEBUG        /* Other event */        else        {            intf_DbgMsg("%p -> unhandled event type %d received\n", p_intf, xevent.type );        }#endif    }    /*     * Handle vout or interface windows resizing     */    if( p_intf->p_vout != NULL )    {        if( b_resized )        {            /* If interface window has been resized, change vout size */            intf_DbgMsg("resizing output window\n");            vlc_mutex_lock( &p_intf->p_vout->change_lock );            p_intf->p_vout->i_width =  p_intf->p_sys->i_width;            p_intf->p_vout->i_height = p_intf->p_sys->i_height;            p_intf->p_vout->i_changes |= VOUT_SIZE_CHANGE;            vlc_mutex_unlock( &p_intf->p_vout->change_lock );        }        else if( (p_intf->p_vout->i_width  != p_intf->p_sys->i_width) ||                 (p_intf->p_vout->i_height != p_intf->p_sys->i_height) )        {           /* If video output size has changed, change interface window size */            intf_DbgMsg( "resizing interface window\n" );            p_intf->p_sys->i_width =    p_intf->p_vout->i_width;            p_intf->p_sys->i_height =   p_intf->p_vout->i_height;            XResizeWindow( p_intf->p_sys->p_display, p_intf->p_sys->window,                           p_intf->p_sys->i_width, p_intf->p_sys->i_height );        }    }}/***************************************************************************** * GnomeEnableScreenSaver: enable screen saver ***************************************************************************** * This function enable the screen saver on a display after it had been * disabled by XDisableScreenSaver. Both functions use a counter mechanism to * know wether the screen saver can be activated or not: if n successive calls * are made to XDisableScreenSaver, n successive calls to XEnableScreenSaver * will be required before the screen saver could effectively be activated. *****************************************************************************/void GnomeEnableScreenSaver( intf_thread_t *p_intf ){    if( p_intf->p_sys->i_ss_count++ == 0 )    {        intf_Msg( "Enabling screen saver\n" );        XSetScreenSaver( p_intf->p_sys->p_display, p_intf->p_sys->i_ss_timeout,                         p_intf->p_sys->i_ss_interval, p_intf->p_sys->i_ss_blanking,                         p_intf->p_sys->i_ss_exposure );    }}/***************************************************************************** * GnomeDisableScreenSaver: disable screen saver ***************************************************************************** * See XEnableScreenSaver *****************************************************************************/void GnomeDisableScreenSaver( intf_thread_t *p_intf ){    if( --p_intf->p_sys->i_ss_count == 0 )    {        /* Save screen saver informations */        XGetScreenSaver( p_intf->p_sys->p_display, &p_intf->p_sys->i_ss_timeout,                         &p_intf->p_sys->i_ss_interval, &p_intf->p_sys->i_ss_blanking,                         &p_intf->p_sys->i_ss_exposure );        /* Disable screen saver */        intf_Msg("Disabling screen saver\n");        XSetScreenSaver( p_intf->p_sys->p_display, 0,                         p_intf->p_sys->i_ss_interval, p_intf->p_sys->i_ss_blanking,                         p_intf->p_sys->i_ss_exposure );    }}/***************************************************************************** * GnomeTogglePointer: hide or show the mouse pointer ***************************************************************************** * This function hides the X pointer if it is visible by putting it at * coordinates (32,32) and setting the pointer sprite to a blank one. To * show it again, we disable the sprite and restore the original coordinates. *****************************************************************************/void GnomeTogglePointer( intf_thread_t *p_intf ){    static Cursor cursor;    static boolean_t b_cursor = 0;    if( p_intf->p_sys->b_mouse )    {        p_intf->p_sys->b_mouse = 0;        if( !b_cursor )        {            XColor color;            Pixmap blank = XCreatePixmap( p_intf->p_sys->p_display,                               DefaultRootWindow(p_intf->p_sys->p_display),                               1, 1, 1 );            XParseColor( p_intf->p_sys->p_display,                         XCreateColormap( p_intf->p_sys->p_display,                                          DefaultRootWindow(                                                  p_intf->p_sys->p_display ),                                          DefaultVisual(                                                  p_intf->p_sys->p_display,                                                  p_intf->p_sys->i_screen ),                                          AllocNone ),                         "black", &color );            cursor = XCreatePixmapCursor( p_intf->p_sys->p_display,                           blank, blank, &color, &color, 1, 1 );            b_cursor = 1;        }        XDefineCursor( p_intf->p_sys->p_display,                       p_intf->p_sys->window, cursor );    }    else    {        p_intf->p_sys->b_mouse = 1;        XUndefineCursor( p_intf->p_sys->p_display, p_intf->p_sys->window );    }}/***************************************************************************** * GnomeManageInterface: manage messages from the Gnome interface ***************************************************************************** * In this function, called approx. 10 times a second, we check what the * Gnome interface wanted to tell us. *****************************************************************************/static void GnomeManageInterface( intf_thread_t *p_intf ){    gnome_thread_t *p_gnome = p_intf->p_sys->p_gnome;    /* lock the change structure */    vlc_mutex_lock( &p_gnome->change_lock );    /* you killed my father, prepare to die */    if( p_gnome->b_die )    {        p_intf->b_die = 1;    }    if( p_gnome->b_activity_changed )    {        vlc_mutex_lock( &p_intf->p_vout->picture_lock );        p_intf->p_vout->b_active = p_gnome->b_activity;        /* having to access p_main sucks */        p_main->p_aout->b_active = p_gnome->b_activity;        vlc_mutex_unlock( &p_intf->p_vout->picture_lock );        p_gnome->b_activity_changed = 0;    }    /* unlock the change structure */    vlc_mutex_unlock( &p_gnome->change_lock );}/***************************************************************************** * GnomeManageMain: manage main thread messages ***************************************************************************** * In this function, called approx. 10 times a second, we check what the * main program wanted to tell us. *****************************************************************************/static gint GnomeManageMain( gpointer p_data ){    gnome_thread_t *p_gnome = (void *)p_data;    /* lock the change structure */    vlc_mutex_lock( &p_gnome->change_lock );    if( p_gnome->b_die )    {        /* unlock the change structure */        vlc_mutex_unlock( &p_gnome->change_lock );        /* prepare to die, young man */        gtk_main_quit();        return( FALSE );    }    /* if the "display popup" flag has changed */    if( p_gnome->b_popup_changed )    {        gnome_popup_menu_do_popup( p_gnome->p_popup,                                   NULL, NULL, NULL, NULL );        p_gnome->b_popup_changed = 0;    }    /* unlock the change structure */    vlc_mutex_unlock( &p_gnome->change_lock );    return( TRUE );}/***************************************************************************** * GnomeThread: special Gnome thread ***************************************************************************** * this part of the interface is in a separate thread so that we can call * gtk_main() from within it without annoying the rest of the program. * XXX: the approach may look kludgy, and probably is, but I could not find * a better way to dynamically load a Gnome interface at runtime. *****************************************************************************/void GnomeThread( gnome_thread_t *p_gnome ){    /* gnome_init needs to know the command line. We don't care, so we     * give it an empty one */    char *p_args[] = { };    /* Sleep to avoid using all CPU - since some interfaces needs to access     * keyboard events, a 100ms delay is a good compromise */    gtk_timeout_add( INTF_IDLE_SLEEP / 1000, GnomeManageMain, p_gnome );     gnome_init( "vlc", VERSION, 1, p_args );    /* create some useful widgets that will certainly be used */    p_gnome->p_window = create_intf_window();    p_gnome->p_popup = create_intf_popup( );    /* we don't create these ones yet because we perhaps won't need them */    p_gnome->p_about = NULL;    p_gnome->p_playlist = NULL;    /* store p_sys to keep an eye on it */    gtk_object_set_data( GTK_OBJECT(p_gnome->p_window), "p_gnome", p_gnome );    gtk_object_set_data( GTK_OBJECT(p_gnome->p_popup), "p_gnome", p_gnome );    /* show the control window */    //gtk_widget_show( p_gnome->p_window );    /* enter gnome mode */    gtk_main();}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -