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

📄 xcommon.c

📁 VLC媒体播放程序
💻 C
📖 第 1 页 / 共 5 页
字号:
    else    {        msg_Dbg( p_vout, "leaving fullscreen mode" );        DestroyWindow( p_vout, &p_vout->p_sys->fullscreen_window );        p_vout->p_sys->p_win = &p_vout->p_sys->original_window;        XMapWindow( p_vout->p_sys->p_display,                    p_vout->p_sys->p_win->base_window);    }    /* Unfortunately, using XSync() here is not enough to ensure the     * window has already been mapped because the XMapWindow() request     * has not necessarily been sent directly to our window (remember,     * the call is first redirected to the window manager) */    do    {        XWindowEvent( p_vout->p_sys->p_display,                      p_vout->p_sys->p_win->base_window,                      StructureNotifyMask, &xevent );    } while( xevent.type != MapNotify );    /* Be careful, this can generate a BadMatch error if the window is not     * already mapped by the server (see above) */    XSetInputFocus(p_vout->p_sys->p_display,                   p_vout->p_sys->p_win->base_window,                   RevertToParent,                   CurrentTime);    /* signal that the size needs to be updated */    p_vout->i_changes |= VOUT_SIZE_CHANGE;}/***************************************************************************** * EnableXScreenSaver: enable screen saver ***************************************************************************** * This function enables the screen saver on a display after it has been * disabled by XDisableScreenSaver. * FIXME: what happens if multiple vlc sessions are running at the same *        time ??? *****************************************************************************/static void EnableXScreenSaver( vout_thread_t *p_vout ){#ifdef DPMSINFO_IN_DPMS_H    int dummy;#endif    if( p_vout->p_sys->i_ss_timeout )    {        XSetScreenSaver( p_vout->p_sys->p_display, p_vout->p_sys->i_ss_timeout,                         p_vout->p_sys->i_ss_interval,                         p_vout->p_sys->i_ss_blanking,                         p_vout->p_sys->i_ss_exposure );    }    /* Restore DPMS settings */#ifdef DPMSINFO_IN_DPMS_H    if( DPMSQueryExtension( p_vout->p_sys->p_display, &dummy, &dummy ) )    {        if( p_vout->p_sys->b_ss_dpms )        {            DPMSEnable( p_vout->p_sys->p_display );        }    }#endif}/***************************************************************************** * DisableXScreenSaver: disable screen saver ***************************************************************************** * See XEnableXScreenSaver *****************************************************************************/static void DisableXScreenSaver( vout_thread_t *p_vout ){#ifdef DPMSINFO_IN_DPMS_H    int dummy;#endif    /* Save screen saver informations */    XGetScreenSaver( p_vout->p_sys->p_display, &p_vout->p_sys->i_ss_timeout,                     &p_vout->p_sys->i_ss_interval,                     &p_vout->p_sys->i_ss_blanking,                     &p_vout->p_sys->i_ss_exposure );    /* Disable screen saver */    if( p_vout->p_sys->i_ss_timeout )    {        XSetScreenSaver( p_vout->p_sys->p_display, 0,                         p_vout->p_sys->i_ss_interval,                         p_vout->p_sys->i_ss_blanking,                         p_vout->p_sys->i_ss_exposure );    }    /* Disable DPMS */#ifdef DPMSINFO_IN_DPMS_H    if( DPMSQueryExtension( p_vout->p_sys->p_display, &dummy, &dummy ) )    {        CARD16 unused;        /* Save DPMS current state */        DPMSInfo( p_vout->p_sys->p_display, &unused,                  &p_vout->p_sys->b_ss_dpms );        DPMSDisable( p_vout->p_sys->p_display );   }#endif}/***************************************************************************** * CreateCursor: create a blank mouse pointer *****************************************************************************/static void CreateCursor( vout_thread_t *p_vout ){    XColor cursor_color;    p_vout->p_sys->cursor_pixmap =        XCreatePixmap( p_vout->p_sys->p_display,                       DefaultRootWindow( p_vout->p_sys->p_display ),                       1, 1, 1 );    XParseColor( p_vout->p_sys->p_display,                 XCreateColormap( p_vout->p_sys->p_display,                                  DefaultRootWindow(                                                    p_vout->p_sys->p_display ),                                  DefaultVisual(                                                p_vout->p_sys->p_display,                                                p_vout->p_sys->i_screen ),                                  AllocNone ),                 "black", &cursor_color );    p_vout->p_sys->blank_cursor =        XCreatePixmapCursor( p_vout->p_sys->p_display,                             p_vout->p_sys->cursor_pixmap,                             p_vout->p_sys->cursor_pixmap,                             &cursor_color, &cursor_color, 1, 1 );}/***************************************************************************** * DestroyCursor: destroy the blank mouse pointer *****************************************************************************/static void DestroyCursor( vout_thread_t *p_vout ){    XFreePixmap( p_vout->p_sys->p_display, p_vout->p_sys->cursor_pixmap );}/***************************************************************************** * ToggleCursor: hide or show the mouse pointer ***************************************************************************** * This function hides the X pointer if it is visible by setting the pointer * sprite to a blank one. To show it again, we disable the sprite. *****************************************************************************/static void ToggleCursor( vout_thread_t *p_vout ){    if( p_vout->p_sys->b_mouse_pointer_visible )    {        XDefineCursor( p_vout->p_sys->p_display,                       p_vout->p_sys->p_win->base_window,                       p_vout->p_sys->blank_cursor );        p_vout->p_sys->b_mouse_pointer_visible = 0;    }    else    {        XUndefineCursor( p_vout->p_sys->p_display,                         p_vout->p_sys->p_win->base_window );        p_vout->p_sys->b_mouse_pointer_visible = 1;    }}#ifdef MODULE_NAME_IS_xvideo/***************************************************************************** * XVideoGetPort: get YUV12 port *****************************************************************************/static int XVideoGetPort( vout_thread_t *p_vout,                          vlc_fourcc_t i_chroma, vlc_fourcc_t *pi_newchroma ){    XvAdaptorInfo *p_adaptor;    unsigned int i;    int i_adaptor, i_num_adaptors, i_requested_adaptor;    int i_selected_port;    switch( XvQueryExtension( p_vout->p_sys->p_display, &i, &i, &i, &i, &i ) )    {        case Success:            break;        case XvBadExtension:            msg_Warn( p_vout, "XvBadExtension" );            return -1;        case XvBadAlloc:            msg_Warn( p_vout, "XvBadAlloc" );            return -1;        default:            msg_Warn( p_vout, "XvQueryExtension failed" );            return -1;    }    switch( XvQueryAdaptors( p_vout->p_sys->p_display,                             DefaultRootWindow( p_vout->p_sys->p_display ),                             &i_num_adaptors, &p_adaptor ) )    {        case Success:            break;        case XvBadExtension:            msg_Warn( p_vout, "XvBadExtension for XvQueryAdaptors" );            return -1;        case XvBadAlloc:            msg_Warn( p_vout, "XvBadAlloc for XvQueryAdaptors" );            return -1;        default:            msg_Warn( p_vout, "XvQueryAdaptors failed" );            return -1;    }    i_selected_port = -1;    i_requested_adaptor = config_GetInt( p_vout, "xvideo-adaptor" );    for( i_adaptor = 0; i_adaptor < i_num_adaptors; ++i_adaptor )    {        XvImageFormatValues *p_formats;        int i_format, i_num_formats;        int i_port;        /* If we requested an adaptor and it's not this one, we aren't         * interested */        if( i_requested_adaptor != -1 && i_adaptor != i_requested_adaptor )        {            continue;        }        /* If the adaptor doesn't have the required properties, skip it */        if( !( p_adaptor[ i_adaptor ].type & XvInputMask ) ||            !( p_adaptor[ i_adaptor ].type & XvImageMask ) )        {            continue;        }        /* Check that adaptor supports our requested format... */        p_formats = XvListImageFormats( p_vout->p_sys->p_display,                                        p_adaptor[i_adaptor].base_id,                                        &i_num_formats );        for( i_format = 0;             i_format < i_num_formats && ( i_selected_port == -1 );             i_format++ )        {            /* Code removed, we can get this through xvinfo anyway */#if 0            XvEncodingInfo  *p_enc;            int             i_enc, i_num_encodings;            XvAttribute     *p_attr;            int             i_attr, i_num_attributes;#endif            /* If this is not the format we want, or at least a             * similar one, forget it */            if( !vout_ChromaCmp( p_formats[ i_format ].id, i_chroma ) )            {                continue;            }            /* Look for the first available port supporting this format */            for( i_port = p_adaptor[i_adaptor].base_id;                 ( i_port < (int)(p_adaptor[i_adaptor].base_id                                   + p_adaptor[i_adaptor].num_ports) )                   && ( i_selected_port == -1 );                 i_port++ )            {                if( XvGrabPort( p_vout->p_sys->p_display, i_port, CurrentTime )                     == Success )                {                    i_selected_port = i_port;                    *pi_newchroma = p_formats[ i_format ].id;                }            }            /* If no free port was found, forget it */            if( i_selected_port == -1 )            {                continue;            }            /* If we found a port, print information about it */            msg_Dbg( p_vout, "adaptor %i, port %i, format 0x%x (%4.4s) %s",                     i_adaptor, i_selected_port, p_formats[ i_format ].id,                     (char *)&p_formats[ i_format ].id,                     ( p_formats[ i_format ].format == XvPacked ) ?                         "packed" : "planar" );#if 0            msg_Dbg( p_vout, " encoding list:" );            if( XvQueryEncodings( p_vout->p_sys->p_display, i_selected_port,                                  &i_num_encodings, &p_enc )                 != Success )            {                msg_Dbg( p_vout, "  XvQueryEncodings failed" );                continue;            }            for( i_enc = 0; i_enc < i_num_encodings; i_enc++ )            {                msg_Dbg( p_vout, "  id=%ld, name=%s, size=%ldx%ld,"                                      " numerator=%d, denominator=%d",                             p_enc[i_enc].encoding_id, p_enc[i_enc].name,                             p_enc[i_enc].width, p_enc[i_enc].height,                             p_enc[i_enc].rate.numerator,                             p_enc[i_enc].rate.denominator );            }            if( p_enc != NULL )            {                XvFreeEncodingInfo( p_enc );            }            msg_Dbg( p_vout, " attribute list:" );            p_attr = XvQueryPortAttributes( p_vout->p_sys->p_display,                                            i_selected_port,                                            &i_num_attributes );            for( i_attr = 0; i_attr < i_num_attributes; i_attr++ )            {                msg_Dbg( p_vout, "  name=%s, flags=[%s%s ], min=%i, max=%i",                      p_attr[i_attr].name,                      (p_attr[i_attr].flags & XvGettable) ? " get" : "",                      (p_attr[i_attr].flags & XvSettable) ? " set" : "",                      p_attr[i_attr].min_value, p_attr[i_attr].max_value );            }            if( p_attr != NULL )            {                XFree( p_attr );            }#endif        }        if( p_formats != NULL )        {            XFree( p_formats );        }    }    if( i_num_adaptors > 0 )    {        XvFreeAdaptorInfo( p

⌨️ 快捷键说明

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