[MPlayer-cvslog] r23675 - in trunk/libvo: vo_dxr3.c vo_gl.c vo_gl2.c vo_x11.c vo_xmga.c vo_xover.c vo_xv.c vo_xvidix.c vo_xvmc.c x11_common.c x11_common.h
reimar
subversion at mplayerhq.hu
Wed Jun 27 12:26:14 CEST 2007
Author: reimar
Date: Wed Jun 27 12:26:13 2007
New Revision: 23675
Log:
Make X11 window creation and (with -fixed-vo) management simpler and more
consistent by introducing a new function that handles most of the
ugly things. Changes of behaviour with some vos is unavoidable, bug reports
welcome.
Modified:
trunk/libvo/vo_dxr3.c
trunk/libvo/vo_gl.c
trunk/libvo/vo_gl2.c
trunk/libvo/vo_x11.c
trunk/libvo/vo_xmga.c
trunk/libvo/vo_xover.c
trunk/libvo/vo_xv.c
trunk/libvo/vo_xvidix.c
trunk/libvo/vo_xvmc.c
trunk/libvo/x11_common.c
trunk/libvo/x11_common.h
Modified: trunk/libvo/vo_dxr3.c
==============================================================================
--- trunk/libvo/vo_dxr3.c (original)
+++ trunk/libvo/vo_dxr3.c Wed Jun 27 12:26:13 2007
@@ -616,22 +616,13 @@ static int config(uint32_t width, uint32
depth = 24;
}
XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
+ vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy,
+ d_width, d_height, flags,
+ CopyFromParent, "Viewing Window", title);
xswa.background_pixel = KEY_COLOR;
xswa.border_pixel = 0;
xswamask = CWBackPixel | CWBorderPixel;
- hint.y = vo_dy;
- hint.x = vo_dx;
- hint.base_width = hint.width = vo_dwidth;
- hint.base_height = hint.height = vo_dheight;
- hint.flags = PPosition | PSize;
- vo_window = XCreateWindow(mDisplay, mRootWin, hint.x, hint.y, hint.width, hint.height, 0, depth, CopyFromParent, vinfo.visual, xswamask, &xswa);
- vo_x11_classhint(mDisplay, vo_window, "Viewing Window");
- vo_hidecursor(mDisplay, vo_window);
- vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PropertyChangeMask);
- XSetStandardProperties(mDisplay, vo_window, "DXR3 Overlay", "DXR3 Overlay", None, NULL, 0, &hint);
- XSetWMNormalHints(mDisplay, vo_window, &hint);
- XMapWindow(mDisplay, vo_window);
- XSync(mDisplay, False);
+ XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
/* Start setting up overlay */
Modified: trunk/libvo/vo_gl.c
==============================================================================
--- trunk/libvo/vo_gl.c (original)
+++ trunk/libvo/vo_gl.c Wed Jun 27 12:26:13 2007
@@ -470,65 +470,18 @@ config(uint32_t width, uint32_t height,
ButtonPressMask | ButtonReleaseMask | ExposureMask);
goto glconfig;
}
- if ( vo_window == None ) {
- unsigned int fg, bg;
- XSizeHints hint;
- XVisualInfo *vinfo;
- XEvent xev;
-
- vo_fs = VO_FALSE;
-
- hint.x = vo_dx;
- hint.y = vo_dy;
- hint.width = d_width;
- hint.height = d_height;
- hint.flags = PPosition | PSize;
-
- /* Get some colors */
- bg = WhitePixel(mDisplay, mScreen);
- fg = BlackPixel(mDisplay, mScreen);
-
- /* Make the window */
- vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
+ {
+ XVisualInfo *vinfo=glXChooseVisual( mDisplay,mScreen,wsGLXAttrib );
if (vinfo == NULL)
{
mp_msg(MSGT_VO, MSGL_ERR, "[gl] no GLX support present\n");
return -1;
}
- vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vinfo->visual,
- hint.x, hint.y, hint.width, hint.height, vinfo->depth,
- XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone));
-
- vo_x11_classhint( mDisplay,vo_window,"gl" );
- vo_hidecursor(mDisplay,vo_window);
-
- XSelectInput(mDisplay, vo_window, StructureNotifyMask);
- /* Tell other applications about this window */
- XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
- /* Set the size hints. */
- vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0);
- /* Map window. */
- XMapWindow(mDisplay, vo_window);
-
- /* Wait for map. */
- do {
- XNextEvent(mDisplay, &xev);
- } while (xev.type != MapNotify || xev.xmap.event != vo_window);
-
- XSelectInput(mDisplay, vo_window, NoEventMask);
-
- XSync(mDisplay, False);
-
- vo_x11_selectinput_witherr(mDisplay, vo_window,
- StructureNotifyMask | KeyPressMask | PointerMotionMask |
- ButtonPressMask | ButtonReleaseMask | ExposureMask);
+ vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height, flags,
+ XCreateColormap(mDisplay, mRootWin, vinfo->visual, AllocNone),
+ "gl", title);
}
- if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
-
- vo_x11_nofs_sizepos(vo_dx, vo_dy, d_width, d_height);
- if (vo_fs ^ (flags & VOFLAG_FULLSCREEN))
- vo_x11_fullscreen();
#endif
glconfig:
Modified: trunk/libvo/vo_gl2.c
==============================================================================
--- trunk/libvo/vo_gl2.c (original)
+++ trunk/libvo/vo_gl2.c Wed Jun 27 12:26:13 2007
@@ -518,6 +518,7 @@ static int choose_glx_visual(Display *dp
}
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;
if (WinID >= 0) {
vo_window = WinID ? (Window)WinID : mRootWin;
vo_x11_selectinput_witherr(mDisplay, vo_window,
@@ -525,56 +526,14 @@ static int config_glx(uint32_t width, ui
ButtonPressMask | ButtonReleaseMask | ExposureMask);
return 0;
}
- if ( vo_window == None ) {
- XSizeHints hint;
- XVisualInfo *vinfo, vinfo_buf;
- XEvent xev;
-
- hint.x = vo_dx;
- hint.y = vo_dy;
- hint.width = d_width;
- hint.height = d_height;
- hint.flags = PPosition | PSize;
-
- /* Make the window */
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");
return -1;
}
- vo_fs = VO_FALSE;
- vo_window = vo_x11_create_smooth_window(mDisplay, RootWindow(mDisplay,mScreen),
- vinfo->visual, hint.x, hint.y, hint.width, hint.height, vinfo->depth, vo_x11_create_colormap(vinfo));
-
- vo_x11_classhint( mDisplay,vo_window,"gl2" );
- vo_hidecursor(mDisplay,vo_window);
-
- XSelectInput(mDisplay, vo_window, StructureNotifyMask);
-
- /* Tell other applications about this window */
-
- XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
-
- /* Map window. */
- XMapWindow(mDisplay, vo_window);
- vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
- XClearWindow(mDisplay,vo_window);
-
- /* Wait for map. */
- do {
- XNextEvent(mDisplay, &xev);
- } while (xev.type != MapNotify || xev.xmap.event != vo_window);
-
- XSync(mDisplay, False);
-
- //XSelectInput(mDisplay, vo_window, StructureNotifyMask); // !!!!
- vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PointerMotionMask |
- ButtonPressMask | ButtonReleaseMask | ExposureMask);
- }
- vo_x11_nofs_sizepos(vo_dx, vo_dy, d_width, d_height);
- if (vo_fs ^ (flags & VOFLAG_FULLSCREEN))
- vo_x11_fullscreen();
+ vo_x11_create_vo_window(vinfo, vo_dx, vo_dy, d_width, d_height,
+ flags, vo_x11_create_colormap(vinfo), "gl2", title);
return 0;
}
Modified: trunk/libvo/vo_x11.c
==============================================================================
--- trunk/libvo/vo_x11.c (original)
+++ trunk/libvo/vo_x11.c Wed Jun 27 12:26:13 2007
@@ -440,38 +440,12 @@ static int config(uint32_t width, uint32
XSelectInput(mDisplay, vo_window, ExposureMask);
} else
{
- if (vo_window == None)
- {
- vo_window =
- vo_x11_create_smooth_window(mDisplay, mRootWin,
- vinfo.visual, vo_dx, vo_dy,
- vo_dwidth, vo_dheight,
- depth, theCmap);
-
- vo_x11_classhint(mDisplay, vo_window, "x11");
- vo_hidecursor(mDisplay, vo_window);
- vo_x11_sizehint(vo_dx, vo_dy, vo_dwidth, vo_dheight, 0);
- XSelectInput(mDisplay, vo_window, StructureNotifyMask);
- XStoreName(mDisplay, vo_window, title);
- XMapWindow(mDisplay, vo_window);
-// if(WinID!=0)
- do
- {
- XNextEvent(mDisplay, &xev);
- }
- while (xev.type != MapNotify
- || xev.xmap.event != vo_window);
-
- vo_x11_nofs_sizepos(vo_dx, vo_dy, vo_dwidth, vo_dheight);
- if (fullscreen)
- vo_x11_fullscreen();
- } else
- vo_x11_nofs_sizepos(vo_dx, vo_dy, vo_dwidth, vo_dheight);
+ vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height,
+ flags, theCmap, "x11", title);
}
XSync(mDisplay, False);
- // we cannot grab mouse events on root window :(
vo_x11_selectinput_witherr(mDisplay, vo_window,
StructureNotifyMask | KeyPressMask |
PropertyChangeMask | ExposureMask |
Modified: trunk/libvo/vo_xmga.c
==============================================================================
--- trunk/libvo/vo_xmga.c (original)
+++ trunk/libvo/vo_xmga.c Wed Jun 27 12:26:13 2007
@@ -220,31 +220,8 @@ static int config(uint32_t width, uint32
} else
{
-
- if (vo_window == None)
- {
- vo_window = XCreateWindow(mDisplay, mRootWin,
- vo_dx, vo_dy,
- vo_dwidth, vo_dheight,
- xWAttribs.border_pixel,
- mDepth,
- InputOutput,
- vinfo.visual, xswamask,
- &xWAttribs);
-
- vo_x11_classhint(mDisplay, vo_window, "xmga");
- vo_hidecursor(mDisplay, vo_window);
- vo_x11_sizehint(vo_dx, vo_dy, vo_dwidth, vo_dheight, 0);
-
- XStoreName(mDisplay, vo_window, mTitle);
- XMapWindow(mDisplay, vo_window);
- vo_x11_nofs_sizepos(vo_dx, vo_dy, vo_dwidth, vo_dheight);
-
- if (flags & VOFLAG_FULLSCREEN)
- vo_x11_fullscreen();
-
- } else
- vo_x11_nofs_sizepos(vo_dx, vo_dy, vo_dwidth, vo_dheight);
+ vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height,
+ flags, InputOutput, "xmga", title);
}
if (vo_gc != None)
Modified: trunk/libvo/vo_xover.c
==============================================================================
--- trunk/libvo/vo_xover.c (original)
+++ trunk/libvo/vo_xover.c Wed Jun 27 12:26:13 2007
@@ -300,22 +300,10 @@ static int config(uint32_t width, uint32
}
else
{
- if ( vo_window == None )
- {
- vo_window = XCreateWindow(mDisplay, RootWindow(mDisplay, mScreen),
- vo_dx, vo_dy, window_width, window_height, xswa.border_pixel,
- vinfo.depth, InputOutput, vinfo.visual, xswamask, &xswa);
-
- vo_x11_classhint(mDisplay, vo_window, "xvidix");
- vo_hidecursor(mDisplay, vo_window);
- vo_x11_sizehint( vo_dx,vo_dy,vo_dwidth,vo_dheight,0 );
-
- XStoreName(mDisplay, vo_window, title);
- XMapWindow(mDisplay, vo_window);
-
- if ( flags&VOFLAG_FULLSCREEN ) vo_x11_fullscreen();
-
- } else if ( !(flags&VOFLAG_FULLSCREEN) ) XMoveResizeWindow( mDisplay,vo_window,vo_dx,vo_dy,vo_dwidth,vo_dheight );
+ vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy,
+ window_width, window_height, flags,
+ InputOutput, "xvidix", title);
+ XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc );
Modified: trunk/libvo/vo_xv.c
==============================================================================
--- trunk/libvo/vo_xv.c (original)
+++ trunk/libvo/vo_xv.c Wed Jun 27 12:26:13 2007
@@ -301,48 +301,13 @@ static int config(uint32_t width, uint32
if (vo_dheight <= 0) vo_dheight = d_height;
aspect_save_prescale(vo_dwidth, vo_dheight);
}
- } else if (vo_window == None)
- {
- vo_window =
- vo_x11_create_smooth_window(mDisplay, mRootWin,
- vinfo.visual, hint.x, hint.y,
- hint.width, hint.height, depth,
- CopyFromParent);
- XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
-
- vo_x11_classhint(mDisplay, vo_window, "xv");
- vo_hidecursor(mDisplay, vo_window);
-
- vo_x11_selectinput_witherr(mDisplay, vo_window,
- StructureNotifyMask | KeyPressMask |
- PropertyChangeMask | ((WinID == 0) ?
- 0
- :
- (PointerMotionMask
- |
- ButtonPressMask
- |
- ButtonReleaseMask
- |
- ExposureMask)));
- XSetStandardProperties(mDisplay, vo_window, hello, hello, None,
- NULL, 0, &hint);
- vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0);
- XMapWindow(mDisplay, vo_window);
- vo_x11_nofs_sizepos(hint.x, hint.y, hint.width, hint.height);
- if (flags & VOFLAG_FULLSCREEN)
- vo_x11_fullscreen();
} else
{
- // vo_fs set means we were already at fullscreen
- vo_x11_sizehint(hint.x, hint.y, hint.width, hint.height, 0);
- vo_x11_nofs_sizepos(hint.x, hint.y, hint.width, hint.height);
- if (flags & VOFLAG_FULLSCREEN && !vo_fs)
- vo_x11_fullscreen(); // handle -fs on non-first file
+ vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height,
+ flags, CopyFromParent, "xv", title);
+ XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
-// vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
-
if (vo_gc != None)
XFreeGC(mDisplay, vo_gc);
vo_gc = XCreateGC(mDisplay, vo_window, 0L, &xgcv);
Modified: trunk/libvo/vo_xvidix.c
==============================================================================
--- trunk/libvo/vo_xvidix.c (original)
+++ trunk/libvo/vo_xvidix.c Wed Jun 27 12:26:13 2007
@@ -335,28 +335,10 @@ static int config(uint32_t width, uint32
XSelectInput(mDisplay, vo_window, ExposureMask);
} else
{
- if (vo_window == None)
- {
- vo_window =
- XCreateWindow(mDisplay, RootWindow(mDisplay, mScreen),
- vo_dx, vo_dy, window_width,
- window_height, xswa.border_pixel,
- vinfo.depth, InputOutput, vinfo.visual,
- xswamask, &xswa);
-
- vo_x11_classhint(mDisplay, vo_window, "xvidix");
- vo_hidecursor(mDisplay, vo_window);
- vo_x11_sizehint(vo_dx, vo_dy, vo_dwidth, vo_dheight, 0);
-
- XStoreName(mDisplay, vo_window, title);
- XMapWindow(mDisplay, vo_window);
- vo_x11_nofs_sizepos(vo_dx, vo_dy, vo_dwidth, vo_dheight);
-
- if (flags & VOFLAG_FULLSCREEN)
- vo_x11_fullscreen();
-
- } else
- vo_x11_nofs_sizepos(vo_dx, vo_dy, vo_dwidth, vo_dheight);
+ 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)
Modified: trunk/libvo/vo_xvmc.c
==============================================================================
--- trunk/libvo/vo_xvmc.c (original)
+++ trunk/libvo/vo_xvmc.c Wed Jun 27 12:26:13 2007
@@ -695,33 +695,9 @@ skip_surface_allocation:
aspect_save_prescale(vo_dwidth, vo_dheight);
}
} else
- if ( vo_window == None ){
- vo_window = XCreateWindow(mDisplay, mRootWin,
- hint.x, hint.y, hint.width, hint.height,
- 0, depth,CopyFromParent,vinfo.visual,xswamask,&xswa);
-
- vo_x11_classhint( mDisplay,vo_window,"xvmc" );
- vo_hidecursor(mDisplay,vo_window);
-
- vo_x11_selectinput_witherr(mDisplay, vo_window, StructureNotifyMask | KeyPressMask | PropertyChangeMask | ExposureMask |
- ((WinID==0) ? 0 : (PointerMotionMask
- | ButtonPressMask | ButtonReleaseMask)) );
- XSetStandardProperties(mDisplay, vo_window, hello, hello, None, NULL, 0, &hint);
- XSetWMNormalHints( mDisplay,vo_window,&hint );
- XMapWindow(mDisplay, vo_window);
- vo_x11_nofs_sizepos(hint.x, hint.y, hint.width, hint.height);
- if ( flags&VOFLAG_FULLSCREEN ) vo_x11_fullscreen();
- else {
- vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
- }
- } else {
- // vo_fs set means we were already at fullscreen
- vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
- vo_x11_nofs_sizepos(hint.x, hint.y, hint.width, hint.height);
- if ( flags&VOFLAG_FULLSCREEN && !vo_fs ) vo_x11_fullscreen(); // handle -fs on non-first file
- }
-
-// vo_x11_sizehint( hint.x, hint.y, hint.width, hint.height,0 );
+ 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);
Modified: trunk/libvo/x11_common.c
==============================================================================
--- trunk/libvo/x11_common.c (original)
+++ trunk/libvo/x11_common.c Wed Jun 27 12:26:13 2007
@@ -1265,6 +1265,62 @@ Window vo_x11_create_smooth_window(Displ
return ret_win;
}
+/**
+ * \brief create and setup a window suitable for display
+ * \param vis Visual to use for creating the window
+ * \param x x position of window
+ * \param y y position of window
+ * \param width width of window
+ * \param height height of window
+ * \param flags flags for window creation.
+ * Only VOFLAG_FULLSCREEN is supported so far.
+ * \param col_map Colourmap for window
+ * \param classname name to use for the classhint
+ * \param title title for the window
+ *
+ * This also does the grunt-work like setting Window Manager hints etc.
+ * If vo_window is already set it just moves and resizes it.
+ */
+void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
+ unsigned int width, unsigned int height, int flags,
+ Colormap col_map,
+ const char *classname, const char *title)
+{
+ if (vo_window == None) {
+ XSizeHints hint;
+ XEvent xev;
+ vo_fs = 0;
+ vo_dwidth = width;
+ vo_dheight = height;
+ vo_window = vo_x11_create_smooth_window(mDisplay, mRootWin, vis->visual,
+ x, y, width, height, vis->depth, col_map);
+ vo_x11_classhint(mDisplay, vo_window, classname);
+ XStoreName(mDisplay, vo_window, title);
+ vo_hidecursor(mDisplay, vo_window);
+ XSelectInput(mDisplay, vo_window, StructureNotifyMask);
+ hint.x = x; hint.y = y;
+ hint.width = width; hint.height = height;
+ hint.flags = PPosition | PSize;
+ XSetStandardProperties(mDisplay, vo_window, title, title, None, NULL, 0, &hint);
+ vo_x11_sizehint(x, y, width, height, 0);
+ // map window
+ XMapWindow(mDisplay, vo_window);
+ XClearWindow(mDisplay, vo_window);
+ // wait for map
+ do {
+ XNextEvent(mDisplay, &xev);
+ } while (xev.type != MapNotify || xev.xmap.event != vo_window);
+ XSelectInput(mDisplay, vo_window, NoEventMask);
+ XSync(mDisplay, False);
+ vo_x11_selectinput_witherr(mDisplay, vo_window,
+ StructureNotifyMask | KeyPressMask | PointerMotionMask |
+ ButtonPressMask | ButtonReleaseMask | ExposureMask);
+ }
+ if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);
+ vo_x11_nofs_sizepos(vo_dx, vo_dy, width, height);
+ if (!!vo_fs != !!(flags & VOFLAG_FULLSCREEN))
+ vo_x11_fullscreen();
+}
void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
int img_width, int img_height, int use_fs)
Modified: trunk/libvo/x11_common.h
==============================================================================
--- trunk/libvo/x11_common.h (original)
+++ trunk/libvo/x11_common.h Wed Jun 27 12:26:13 2007
@@ -55,6 +55,9 @@ extern void fstype_help(void);
extern Window vo_x11_create_smooth_window( Display *mDisplay, Window mRoot,
Visual *vis, int x, int y, unsigned int width, unsigned int height,
int depth, Colormap col_map);
+extern void vo_x11_create_vo_window(XVisualInfo *vis, int x, int y,
+ unsigned int width, unsigned int height, int flags,
+ Colormap col_map, const char *classname, const char *title);
extern void vo_x11_clearwindow_part(Display *mDisplay, Window vo_window,
int img_width, int img_height, int use_fs);
extern void vo_x11_clearwindow( Display *mDisplay, Window vo_window );
More information about the MPlayer-cvslog
mailing list