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

📄 intf_x11.c

📁 vlc stand 0.1.99 ist sehr einfach
💻 C
📖 第 1 页 / 共 2 页
字号:
        {            b_expose = 1;        }        else if( (xevent.type == MapNotify)                 && (xevent.xmap.window == p_intf->p_sys->window) )        {            b_map_notify = 1;        }        else if( (xevent.type == ConfigureNotify)                 && (xevent.xconfigure.window == p_intf->p_sys->window) )        {            b_configure_notify = 1;            p_intf->p_sys->i_width = xevent.xconfigure.width;            p_intf->p_sys->i_height = xevent.xconfigure.height;        }    } while( !( b_expose && b_configure_notify && b_map_notify ) );    XSelectInput( p_intf->p_sys->p_display, p_intf->p_sys->window,                  StructureNotifyMask | KeyPressMask | ButtonPressMask );    if( XDefaultDepth( p_intf->p_sys->p_display, p_intf->p_sys->i_screen ) == 8 )    {        /* Allocate a new palette */        p_intf->p_sys->colormap = 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 ),                                      AllocAll );        xwindow_attributes.colormap = p_intf->p_sys->colormap;        XChangeWindowAttributes( p_intf->p_sys->p_display, p_intf->p_sys->window,                                 CWColormap, &xwindow_attributes );    }    /* At this stage, the window is open, displayed, and ready to receive data */    return( 0 );}/***************************************************************************** * X11DestroyWindow: destroy X11 main window *****************************************************************************/static void X11DestroyWindow( intf_thread_t *p_intf ){    XUnmapWindow( p_intf->p_sys->p_display, p_intf->p_sys->window );    XFreeGC( p_intf->p_sys->p_display, p_intf->p_sys->gc );    XDestroyWindow( p_intf->p_sys->p_display, p_intf->p_sys->window );}/***************************************************************************** * X11ManageWindow: manage X11 main window *****************************************************************************/static void X11ManageWindow( 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 )            {                X11DisableScreenSaver( 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 )            {                X11EnableScreenSaver( p_intf );                p_intf->p_vout->b_active = 0;            }        }        /* DestroyNotify event: window has been destroyed */        else if( xevent.type == DestroyNotify )        {            intf_ErrMsg( "vout: window destroyed !\n");        }        /* 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:                    X11TogglePointer( p_intf );                    break;                case Button3:                    vlc_mutex_lock( &p_intf->p_vout->change_lock );                    p_intf->p_vout->b_interface = !p_intf->p_vout->b_interface;                    p_intf->p_vout->i_changes  |= VOUT_INTF_CHANGE;                    vlc_mutex_unlock( &p_intf->p_vout->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 );        }    }}/***************************************************************************** * X11EnableScreenSaver: 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 X11EnableScreenSaver( 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 );    }}/***************************************************************************** * X11DisableScreenSaver: disable screen saver ***************************************************************************** * See XEnableScreenSaver *****************************************************************************/void X11DisableScreenSaver( 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 );    }}/***************************************************************************** * X11TogglePointer: 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 X11TogglePointer( 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 );    }}

⌨️ 快捷键说明

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