[MPlayer-dev-eng] [PATCH] unify x11 window creation an handling
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Tue Jun 26 20:16:29 CEST 2007
Hello,
attached patch makes most x11-based vos use the same code to create and
otherwise handle windows in config().
I will apply rather soon, since the current mess makes it absolutely
impossible to fix bugs or even get a consistent behaviour.
Greetings,
Reimar Döffinger
-------------- next part --------------
diff --git a/libvo/video_out.c b/libvo/video_out.c
diff --git a/libvo/vo_dxr3.c b/libvo/vo_dxr3.c
index 754efd2..1bbc451 100644
--- a/libvo/vo_dxr3.c
+++ b/libvo/vo_dxr3.c
@@ -616,22 +616,14 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_
depth = 24;
}
XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo);
+ vo_x11_create_vo_window(mDisplay, mRootWin, vinfo.visual,
+ vo_dx, vo_dy, d_width, d_height,
+ flags & VOFLAG_FULLSCREEN, depth,
+ 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 */
diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c
index 6f0e684..42eeca2 100644
--- a/libvo/vo_gl.c
+++ b/libvo/vo_gl.c
@@ -470,65 +470,20 @@ config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uin
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(mDisplay, mRootWin, vinfo->visual,
+ vo_dx, vo_dy, d_width, d_height, flags & VOFLAG_FULLSCREEN,
+ vinfo->depth,
+ 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:
diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c
index 40c3236..8315805 100644
--- a/libvo/vo_gl2.c
+++ b/libvo/vo_gl2.c
@@ -518,6 +518,7 @@ 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;
if (WinID >= 0) {
vo_window = WinID ? (Window)WinID : mRootWin;
vo_x11_selectinput_witherr(mDisplay, vo_window,
@@ -525,56 +526,15 @@ static int config_glx(uint32_t width, uint32_t height, uint32_t d_width, uint32_
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(mDisplay, RootWindow(mDisplay,mScreen),
+ vinfo->visual, vo_dx, vo_dy, d_width, d_height, flags & VOFLAG_FULLSCREEN,
+ vinfo->depth, vo_x11_create_colormap(vinfo), "gl2", title);
return 0;
}
diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c
index d9f04be..2d3fcf9 100644
--- a/libvo/vo_x11.c
+++ b/libvo/vo_x11.c
@@ -440,38 +440,13 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
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(mDisplay, mRootWin, vinfo.visual,
+ vo_dx, vo_dy, d_width, d_height, flags & VOFLAG_FULLSCREEN,
+ depth, 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 |
diff --git a/libvo/vo_xmga.c b/libvo/vo_xmga.c
index cd57f5d..22c7ba6 100644
--- a/libvo/vo_xmga.c
+++ b/libvo/vo_xmga.c
@@ -220,31 +220,9 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
} 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(mDisplay, mRootWin, vinfo.visual,
+ vo_dx, vo_dy, d_width, d_height, flags & VOFLAG_FULLSCREEN,
+ mDepth, InputOutput, "xmga", title);
}
if (vo_gc != None)
diff --git a/libvo/vo_xover.c b/libvo/vo_xover.c
index 2a3d8ff..5f01fa9 100644
--- a/libvo/vo_xover.c
+++ b/libvo/vo_xover.c
@@ -300,22 +300,11 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
}
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(mDisplay, RootWindow(mDisplay, mScreen),
+ vinfo.visual, vo_dx, vo_dy, window_width, window_height,
+ flags & VOFLAG_FULLSCREEN,
+ vinfo.depth, InputOutput, "xvidix", title);
+ XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
if ( vo_gc != None ) XFreeGC( mDisplay,vo_gc );
diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c
index 7f68510..d77fdd8 100644
--- a/libvo/vo_xv.c
+++ b/libvo/vo_xv.c
@@ -301,48 +301,14 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
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(mDisplay, mRootWin, vinfo.visual,
+ vo_dx, vo_dy, d_width, d_height, flags & VOFLAG_FULLSCREEN,
+ depth, 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);
diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c
index 68565cd..c4f38b8 100644
--- a/libvo/vo_xvidix.c
+++ b/libvo/vo_xvidix.c
@@ -335,28 +335,11 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width,
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(mDisplay, RootWindow(mDisplay, mScreen),
+ vinfo.visual, vo_dx, vo_dy, window_width, window_height,
+ flags & VOFLAG_FULLSCREEN, vinfo.depth, CopyFromParent,
+ "xvidix", title);
+ XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa);
}
if (vo_gc != None)
diff --git a/libvo/vo_xvmc.c b/libvo/vo_xvmc.c
index ebc292a..c384056 100644
--- a/libvo/vo_xvmc.c
+++ b/libvo/vo_xvmc.c
@@ -695,33 +695,10 @@ 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(mDisplay, mRootWin, vinfo.visual,
+ vo_dx, vo_dy, d_width, d_height, flags & VOFLAG_FULLSCREEN,
+ depth,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);
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index a7ddc9d..6a13b30 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -1265,6 +1265,47 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot,
return ret_win;
}
+void vo_x11_create_vo_window(Display * mDisplay, Window mRoot,
+ Visual * vis, int x, int y,
+ unsigned int width, unsigned int height, int fs,
+ int depth, 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, mRoot, vis,
+ x, y, width, height, 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 != !!fs)
+ vo_x11_fullscreen();
+}
void vo_x11_clearwindow_part(Display * mDisplay, Window vo_window,
int img_width, int img_height, int use_fs)
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 4bae3b0..a97868c 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -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( Display *mDisplay, Window mRoot,
+ Visual *vis, int x, int y, unsigned int width, unsigned int height, int fs,
+ int depth, 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-dev-eng
mailing list