Factor common code like -wid handling, vo_gc creation etc. out into

x11_common.c


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@27961 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2008-11-19 20:19:25 +00:00
parent 928e4433aa
commit c351d29392
9 changed files with 28 additions and 189 deletions

View File

@ -473,14 +473,6 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
if (!vo_w32_config(d_width, d_height, flags))
return -1;
#else
vo_mouse_autohide = 1;
if (WinID >= 0) {
vo_window = WinID ? (Window)WinID : mRootWin;
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
goto glconfig;
}
{
XVisualInfo *vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
if (vinfo == NULL)

View File

@ -521,14 +521,6 @@ static int choose_glx_visual(Display *dpy, int scr, XVisualInfo *res_vi)
static int config_glx(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) {
XVisualInfo *vinfo, vinfo_buf;
vo_mouse_autohide = 1;
if (WinID >= 0) {
vo_window = WinID ? (Window)WinID : mRootWin;
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
return 0;
}
vinfo = choose_glx_visual(mDisplay,mScreen,&vinfo_buf) < 0 ? NULL : &vinfo_buf;
if (vinfo == NULL) {
mp_msg(MSGT_VO, MSGL_FATAL, "[gl2] no GLX support present\n");

View File

@ -317,7 +317,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
int vm = 0;
#endif
vo_mouse_autohide = 1;
old_vo_dwidth = -1;
old_vo_dheight = -1;
@ -395,36 +394,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
}
#endif
if (WinID >= 0)
{
vo_window = WinID ? ((Window) WinID) : mRootWin;
if (WinID)
{
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask,
&xswa);
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask |
KeyPressMask |
PropertyChangeMask |
PointerMotionMask |
ButtonPressMask |
ButtonReleaseMask |
ExposureMask);
XMapWindow(mDisplay, vo_window);
depth = vo_x11_update_geometry();
} else
XSelectInput(mDisplay, vo_window, ExposureMask);
} else
{
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, vo_dwidth, vo_dheight,
flags, theCmap, "x11", title);
}
if (vo_gc != None)
XFreeGC(mDisplay, vo_gc);
vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
XSync(mDisplay, False);
if (WinID > 0)
depth = vo_x11_update_geometry();
#ifdef CONFIG_XF86VM
if (vm)

View File

@ -55,7 +55,6 @@ static const vo_info_t info = {
};
const LIBVO_EXTERN(xmga)
static XGCValues wGCV;
static uint32_t mDepth;
static XWindowAttributes attribs;
@ -142,7 +141,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
vo_dy += xinerama_y;
vo_dwidth = d_width;
vo_dheight = d_height;
vo_mouse_autohide = 1;
r = (vo_colorkey & 0x00ff0000) >> 16;
g = (vo_colorkey & 0x0000ff00) >> 8;
@ -189,44 +187,11 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
XCreateColormap(mDisplay, mRootWin, vinfo.visual, AllocNone);
xWAttribs.background_pixel = 0;
xWAttribs.border_pixel = 0;
xWAttribs.event_mask =
StructureNotifyMask | ExposureMask | KeyPressMask |
((WinID ==
0) ? 0 : (ButtonPressMask | ButtonReleaseMask |
PointerMotionMask | PropertyChangeMask));
xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
xswamask = CWBackPixel | CWBorderPixel | CWColormap;
if (WinID >= 0)
{
vo_window = WinID ? ((Window) WinID) : mRootWin;
if (WinID)
{
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask,
&xWAttribs);
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask |
KeyPressMask |
PropertyChangeMask |
PointerMotionMask |
ButtonPressMask |
ButtonReleaseMask |
ExposureMask);
XMapWindow(mDisplay, vo_window);
} else
XSelectInput(mDisplay, vo_window, ExposureMask);
} else
{
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height,
flags, xWAttribs.colormap, "xmga", title);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xWAttribs);
}
if (vo_gc != None)
XFreeGC(mDisplay, vo_gc);
vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &wGCV);
} // !GUI

View File

@ -51,7 +51,6 @@ LIBVO_EXTERN(xover)
/* X11 related variables */
/* Colorkey handling */
static XGCValues mGCV;
static int colorkey;
/* Image parameters */
@ -217,7 +216,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
image_height = height;
image_width = width;
image_format = format;
vo_mouse_autohide=1;
aspect_save_orig(width, height);
aspect_save_prescale(d_width, d_height);
@ -281,31 +279,13 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
xswa.border_pixel = 0;
xswa.colormap = XCreateColormap(mDisplay, RootWindow(mDisplay, mScreen),
vinfo.visual, AllocNone);
xswa.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask | PropertyChangeMask |
((WinID==0)?0:(ButtonPressMask | ButtonReleaseMask | PointerMotionMask));
xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
xswamask = CWBackPixel | CWBorderPixel | CWColormap;
if (WinID >= 0)
{
vo_window = WinID ? ((Window)WinID) : RootWindow(mDisplay, mScreen);
if ( WinID )
{
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
XMapWindow(mDisplay, vo_window);
} else XSelectInput( mDisplay,vo_window,ExposureMask );
}
else
{
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy,
window_width, window_height, flags,
xswa.colormap, "xvidix", title);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc );
vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &mGCV);
#ifdef CONFIG_GUI
}
#endif

View File

@ -166,7 +166,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
uint32_t format)
{
XVisualInfo vinfo;
XGCValues xgcv;
XSetWindowAttributes xswa;
XWindowAttributes attribs;
unsigned long xswamask;
@ -188,8 +187,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
return -1;
}
vo_mouse_autohide = 1;
int_pause = 0;
visible_buf = -1;
@ -246,38 +243,10 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
if (WinID >= 0)
{
vo_window = WinID ? ((Window) WinID) : mRootWin;
if (WinID)
{
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask,
&xswa);
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask |
KeyPressMask |
PropertyChangeMask |
PointerMotionMask |
ButtonPressMask |
ButtonReleaseMask |
ExposureMask);
XMapWindow(mDisplay, vo_window);
vo_x11_update_geometry();
aspect_save_prescale(vo_dwidth, vo_dheight);
} else
XSelectInput(mDisplay, vo_window, ExposureMask);
} else
{
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, vo_dwidth, vo_dheight,
flags, CopyFromParent, "xv", title);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
if (vo_gc != None)
XFreeGC(mDisplay, vo_gc);
vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
XSync(mDisplay, False);
#ifdef CONFIG_XF86VM
if (vm)
{

View File

@ -49,7 +49,6 @@ LIBVO_EXTERN(xvidix)
#define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
/* X11 related variables */
/* Colorkey handling */
static XGCValues mGCV;
static int colorkey;
static vidix_grkey_t gr_key;
@ -205,7 +204,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
image_height = height;
image_width = width;
image_format = format;
vo_mouse_autohide = 1;
window_width = d_width;
window_height = d_height;
@ -268,44 +266,13 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
xswa.colormap =
XCreateColormap(mDisplay, RootWindow(mDisplay, mScreen),
vinfo.visual, AllocNone);
xswa.event_mask =
StructureNotifyMask | ExposureMask | KeyPressMask |
PropertyChangeMask | ((WinID == 0) ? 0
: (ButtonPressMask | ButtonReleaseMask |
PointerMotionMask));
xswamask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
xswamask = CWBackPixel | CWBorderPixel | CWColormap;
if (WinID >= 0)
{
vo_window =
WinID ? ((Window) WinID) : RootWindow(mDisplay, mScreen);
if (WinID)
{
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask,
&xswa);
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask |
KeyPressMask |
PropertyChangeMask |
PointerMotionMask |
ButtonPressMask |
ButtonReleaseMask |
ExposureMask);
XMapWindow(mDisplay, vo_window);
} else
XSelectInput(mDisplay, vo_window, ExposureMask);
} else
{
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy,
window_width, window_height, flags,
CopyFromParent, "xvidix", title);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
if (vo_gc != None)
XFreeGC(mDisplay, vo_gc);
vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &mGCV);
#ifdef CONFIG_GUI
}
#endif

View File

@ -455,7 +455,6 @@ int numblocks,blocks_per_macroblock;//bpmb we have 6,8,12
//from vo_xv
XVisualInfo vinfo;
XGCValues xgcv;
XSetWindowAttributes xswa;
XWindowAttributes attribs;
unsigned long xswamask;
@ -633,8 +632,6 @@ found_subpic:
skip_surface_allocation:
vo_mouse_autohide = 1;
#ifdef CONFIG_XF86VM
if( flags&VOFLAG_MODESWITCHING ) vm = 1;
#endif
@ -663,29 +660,10 @@ skip_surface_allocation:
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
if ( WinID>=0 ){
vo_window = WinID ? ((Window)WinID) : mRootWin;
if ( WinID )
{
Window mRoot;
uint32_t drwBorderWidth, drwDepth;
XUnmapWindow( mDisplay,vo_window );
XChangeWindowAttributes( mDisplay,vo_window,xswamask,&xswa );
vo_x11_selectinput_witherr( mDisplay,vo_window,StructureNotifyMask | KeyPressMask | PropertyChangeMask | PointerMotionMask | ButtonPressMask | ButtonReleaseMask | ExposureMask );
XMapWindow( mDisplay,vo_window );
XGetGeometry(mDisplay, vo_window, &mRoot,
&drwX, &drwY, &vo_dwidth, &vo_dheight,
&drwBorderWidth, &drwDepth);
aspect_save_prescale(vo_dwidth, vo_dheight);
}
} else
vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, flags,
CopyFromParent, "xvmc", title);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc );
vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv);
XSync(mDisplay, False);
#ifdef CONFIG_XF86VM
if ( vm )
{

View File

@ -1269,6 +1269,23 @@ void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
Colormap col_map,
const char *classname, const char *title)
{
XGCValues xgcv;
if (WinID >= 0) {
vo_window = WinID ? (Window)WinID : mRootWin;
if (col_map != CopyFromParent) {
unsigned long xswamask = CWColormap;
XSetWindowAttributes xswa;
xswa.colormap = col_map;
XUnmapWindow(mDisplay, vo_window);
XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
XMapWindow(mDisplay, vo_window);
}
if (WinID) vo_x11_update_geometry();
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask | KeyPressMask | PointerMotionMask |
ButtonPressMask | ButtonReleaseMask | ExposureMask);
goto final;
}
if (vo_window == None) {
XSizeHints hint;
XEvent xev;
@ -1304,6 +1321,12 @@ void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
vo_x11_fullscreen();
final:
if (vo_gc != None)
XFreeGC(mDisplay, vo_gc);
vo_gc = XCreateGC(mDisplay, vo_window, GCForeground, &xgcv);
XSync(mDisplay, False);
vo_mouse_autohide = 1;
}
void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,