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

📄 xcommon.c

📁 uclinux 下的vlc播放器源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    xwindow_attributes.background_pixel = BlackPixel(p_vout->p_sys->p_display,                                                     p_vout->p_sys->i_screen);    xwindow_attributes.event_mask = ExposureMask | StructureNotifyMask;    if( !p_vout->b_fullscreen )    {        p_win->owner_window =            (Window)vout_RequestWindow( p_vout, &p_win->i_x, &p_win->i_y,                                        &p_win->i_width, &p_win->i_height );        xsize_hints.base_width  = xsize_hints.width = p_win->i_width;        xsize_hints.base_height = xsize_hints.height = p_win->i_height;        xsize_hints.flags       = PSize | PMinSize;        if( p_win->i_x >=0 || p_win->i_y >= 0 )        {            xsize_hints.x = p_win->i_x;            xsize_hints.y = p_win->i_y;            xsize_hints.flags |= PPosition;        }    }    else    {        /* Fullscreen window size and position */        p_win->owner_window = 0;        p_win->i_x = p_win->i_y = 0;        p_win->i_width =            DisplayWidth( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );        p_win->i_height =            DisplayHeight( p_vout->p_sys->p_display, p_vout->p_sys->i_screen );    }    if( !p_win->owner_window )    {        /* Create the window and set hints - the window must receive         * ConfigureNotify events, and until it is displayed, Expose and         * MapNotify events. */        p_win->base_window =            XCreateWindow( p_vout->p_sys->p_display,                           DefaultRootWindow( p_vout->p_sys->p_display ),                           p_win->i_x, p_win->i_y,                           p_win->i_width, p_win->i_height,                           0,                           0, InputOutput, 0,                           CWBackingStore | CWBackPixel | CWEventMask,                           &xwindow_attributes );        if( !p_vout->b_fullscreen )        {            /* Set window manager hints and properties: size hints, command,             * window's name, and accepted protocols */            XSetWMNormalHints( p_vout->p_sys->p_display,                               p_win->base_window, &xsize_hints );            XSetCommand( p_vout->p_sys->p_display, p_win->base_window,                         p_vout->p_vlc->ppsz_argv, p_vout->p_vlc->i_argc );            if( !var_GetBool( p_vout, "video-deco") )            {                Atom prop;                mwmhints_t mwmhints;                mwmhints.flags = MWM_HINTS_DECORATIONS;                mwmhints.decorations = False;                prop = XInternAtom( p_vout->p_sys->p_display, "_MOTIF_WM_HINTS",                                    False );                XChangeProperty( p_vout->p_sys->p_display,                                 p_win->base_window,                                 prop, prop, 32, PropModeReplace,                                 (unsigned char *)&mwmhints,                                 PROP_MWM_HINTS_ELEMENTS );            }            else            {                 var_Get( p_vout, "video-title", &val );                 if( !val.psz_string || !*val.psz_string )                 {                    XStoreName( p_vout->p_sys->p_display, p_win->base_window,#ifdef MODULE_NAME_IS_x11                                VOUT_TITLE " (X11 output)"#elif defined(MODULE_NAME_IS_glx)                                VOUT_TITLE " (GLX output)"#else                                VOUT_TITLE " (XVideo output)"#endif                      );                }                else                {                    XStoreName( p_vout->p_sys->p_display,                               p_win->base_window, val.psz_string );                }                if( val.psz_string ) free( val.psz_string );            }        }    }    else    {        Window dummy1;        int dummy2, dummy3;        unsigned int dummy4, dummy5;        /* Select events we are interested in. */        XSelectInput( p_vout->p_sys->p_display, p_win->owner_window,                      StructureNotifyMask );        /* Get the parent window's geometry information */        XGetGeometry( p_vout->p_sys->p_display, p_win->owner_window,                      &dummy1, &dummy2, &dummy3,                      &p_win->i_width,                      &p_win->i_height,                      &dummy4, &dummy5 );        /* We are already configured */        b_configure_notify = VLC_TRUE;        /* From man XSelectInput: only one client at a time can select a         * ButtonPress event, so we need to open a new window anyway. */        p_win->base_window =            XCreateWindow( p_vout->p_sys->p_display,                           p_win->owner_window,                           0, 0,                           p_win->i_width, p_win->i_height,                           0,                           0, CopyFromParent, 0,                           CWBackingStore | CWBackPixel | CWEventMask,                           &xwindow_attributes );    }    if( (p_win->wm_protocols == None)        /* use WM_DELETE_WINDOW */        || (p_win->wm_delete_window == None)        || !XSetWMProtocols( p_vout->p_sys->p_display, p_win->base_window,                             &p_win->wm_delete_window, 1 ) )    {        /* WM_DELETE_WINDOW is not supported by window manager */        msg_Warn( p_vout, "missing or bad window manager" );    }    /* Creation of a graphic context that doesn't generate a GraphicsExpose     * event when using functions like XCopyArea */    xgcvalues.graphics_exposures = False;    p_win->gc = XCreateGC( p_vout->p_sys->p_display,                           p_win->base_window,                           GCGraphicsExposures, &xgcvalues );    /* Send orders to server, and wait until window is displayed - three     * events must be received: a MapNotify event, an Expose event allowing     * drawing in the window, and a ConfigureNotify to get the window     * dimensions. Once those events have been received, only     * ConfigureNotify events need to be received. */    XMapWindow( p_vout->p_sys->p_display, p_win->base_window );    do    {        XWindowEvent( p_vout->p_sys->p_display, p_win->base_window,                      SubstructureNotifyMask | StructureNotifyMask |                      ExposureMask, &xevent);        if( (xevent.type == Expose)            && (xevent.xexpose.window == p_win->base_window) )        {            b_expose = VLC_TRUE;            /* ConfigureNotify isn't sent if there isn't a window manager.             * Expose should be the last event to be received so it should             * be fine to assume we won't receive it anymore. */            b_configure_notify = VLC_TRUE;        }        else if( (xevent.type == MapNotify)                 && (xevent.xmap.window == p_win->base_window) )        {            b_map_notify = VLC_TRUE;        }        else if( (xevent.type == ConfigureNotify)                 && (xevent.xconfigure.window == p_win->base_window) )        {            b_configure_notify = VLC_TRUE;            p_win->i_width = xevent.xconfigure.width;            p_win->i_height = xevent.xconfigure.height;        }    } while( !( b_expose && b_configure_notify && b_map_notify ) );    XSelectInput( p_vout->p_sys->p_display, p_win->base_window,                  StructureNotifyMask | KeyPressMask |                  ButtonPressMask | ButtonReleaseMask |                  PointerMotionMask );#ifdef MODULE_NAME_IS_x11    if( XDefaultDepth(p_vout->p_sys->p_display, p_vout->p_sys->i_screen) == 8 )    {        /* Allocate a new palette */        p_vout->p_sys->colormap =            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 ),                             AllocAll );        xwindow_attributes.colormap = p_vout->p_sys->colormap;        XChangeWindowAttributes( p_vout->p_sys->p_display, p_win->base_window,                                 CWColormap, &xwindow_attributes );    }#endif    /* Create video output sub-window. */    p_win->video_window =  XCreateSimpleWindow(                                      p_vout->p_sys->p_display,                                      p_win->base_window, 0, 0,                                      p_win->i_width, p_win->i_height,                                      0,                                      BlackPixel( p_vout->p_sys->p_display,                                                  p_vout->p_sys->i_screen ),                                      WhitePixel( p_vout->p_sys->p_display,                                                  p_vout->p_sys->i_screen ) );    XSetWindowBackground( p_vout->p_sys->p_display, p_win->video_window,                          BlackPixel( p_vout->p_sys->p_display,                                      p_vout->p_sys->i_screen ) );    XMapWindow( p_vout->p_sys->p_display, p_win->video_window );    XSelectInput( p_vout->p_sys->p_display, p_win->video_window,                  ExposureMask );    /* make sure the video window will be centered in the next ManageVideo() */    p_vout->i_changes |= VOUT_SIZE_CHANGE;    /* If the cursor was formerly blank than blank it again */    if( !p_vout->p_sys->b_mouse_pointer_visible )    {        ToggleCursor( p_vout );        ToggleCursor( p_vout );    }    /* Do NOT use XFlush here ! */    XSync( p_vout->p_sys->p_display, False );    /* At this stage, the window is open, displayed, and ready to     * receive data */    p_vout->p_sys->p_win = p_win;    return VLC_SUCCESS;}/***************************************************************************** * DestroyWindow: destroy the window ***************************************************************************** * *****************************************************************************/static void DestroyWindow( vout_thread_t *p_vout, x11_window_t *p_win ){    /* Do NOT use XFlush here ! */    XSync( p_vout->p_sys->p_display, False );    if( p_win->video_window != None )        XDestroyWindow( p_vout->p_sys->p_display, p_win->video_window );    XFreeGC( p_vout->p_sys->p_display, p_win->gc );    XUnmapWindow( p_vout->p_sys->p_display, p_win->base_window );    XDestroyWindow( p_vout->p_sys->p_display, p_win->base_window );    if( p_win->owner_window )        vout_ReleaseWindow( p_vout, (void *)p_win->owner_window );}/***************************************************************************** * NewPicture: allocate a picture ***************************************************************************** * Returns 0 on success, -1 otherwise *****************************************************************************/static int NewPicture( vout_thread_t *p_vout, picture_t *p_pic ){#ifndef MODULE_NAME_IS_glx#ifdef MODULE_NAME_IS_xvideo    int i_plane;#endif    /* We know the chroma, allocate a buffer which will be used     * directly by the decoder */    p_pic->p_sys = malloc( sizeof( picture_sys_t ) );    if( p_pic->p_sys == NULL )    {        return -1;    }    /* Fill in picture_t fields */    vout_InitPicture( VLC_OBJECT(p_vout), p_pic, p_vout->output.i_chroma,                      p_vout->output.i_width, p_vout->output.i_height,                      p_vout->output.i_aspect );#ifdef HAVE_SYS_SHM_H    if( p_vout->p_sys->b_shm )    {        /* Create image using XShm extension */        p_pic->p_sys->p_image =            CreateShmImage( p_vout, p_vout->p_sys->p_display,#   ifdef MODULE_NAME_IS_xvideo                            p_vout->p_sys->i_xvport,                             VLC2X11_FOURCC(p_vout->output.i_chroma),#   else                            p_vout->p_sys->p_visual,                            p_vout->p_sys->i_screen_depth,#   endif                            &p_pic->p_sys->shminfo,                            p_vout->output.i_width, p_vout->output.i_height );    }    if( !p_vout->p_sys->b_shm || !p_pic->p_sys->p_image )#endif /* HAVE_SYS_SHM_H */    {        /* Create image without XShm extension */        p_pic->p_sys->p_image =            CreateImage( p_vout, p_vout->p_sys->p_display,#ifdef MODULE_NAME_IS_xvideo                         p_vout->p_sys->i_xvport,                          VLC2X11_FOURCC(p_vout->output.i_chroma),                         p_pic->format.i_bits_per_pixel,#else                         p_vout->p_sys->p_visual,                         p_vout->p_sys->i_screen_depth,                         p_vout->p_sys->i_bytes_per_pixel,#endif                         p_vout->output.i_width, p_vout->output.i_height );#ifdef HAVE_SYS_SHM_H        if( p_pic->p_sys->p_image && p_vout->p_sys->b_shm )        {            msg_Warn( p_vout, "couldn't create SHM image, disabling SHM" );            p_vout->p_sys->b_shm = VLC_FALSE;        }#endif /* HAVE_SYS_SHM_H */    }    if( p_pic->p_sys->p_image == NULL )    {        free( p_pic->p_sys );        return -1;    }    switch( p_vout->output.i_chroma )    {#ifdef MODULE_NAME_IS_xvideo        case VLC_FOURCC('I','4','2','0'):

⌨️ 快捷键说明

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