diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-06-27 10:26:13 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-06-27 10:26:13 +0000 |
commit | f131aafff160e816a3c5904d664561ffe9f32058 (patch) | |
tree | 31eb8b5970484238c36a7ca3d2cad288785879a3 /libvo | |
parent | b4be37acaf5d725d0c81508907fef9733acab444 (diff) |
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.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@23675 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/vo_dxr3.c | 17 | ||||
-rw-r--r-- | libvo/vo_gl.c | 57 | ||||
-rw-r--r-- | libvo/vo_gl2.c | 47 | ||||
-rw-r--r-- | libvo/vo_x11.c | 30 | ||||
-rw-r--r-- | libvo/vo_xmga.c | 27 | ||||
-rw-r--r-- | libvo/vo_xover.c | 20 | ||||
-rw-r--r-- | libvo/vo_xv.c | 41 | ||||
-rw-r--r-- | libvo/vo_xvidix.c | 26 | ||||
-rw-r--r-- | libvo/vo_xvmc.c | 30 | ||||
-rw-r--r-- | libvo/x11_common.c | 56 | ||||
-rw-r--r-- | libvo/x11_common.h | 3 |
11 files changed, 89 insertions, 265 deletions
diff --git a/libvo/vo_dxr3.c b/libvo/vo_dxr3.c index 754efd22b2..4e46403a30 100644 --- a/libvo/vo_dxr3.c +++ b/libvo/vo_dxr3.c @@ -616,22 +616,13 @@ 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(&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 */ diff --git a/libvo/vo_gl.c b/libvo/vo_gl.c index 6f0e684c85..cac6e55079 100644 --- a/libvo/vo_gl.c +++ b/libvo/vo_gl.c @@ -470,65 +470,18 @@ 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(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: diff --git a/libvo/vo_gl2.c b/libvo/vo_gl2.c index 40c32364bd..637cd6edab 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,14 @@ 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(vinfo, vo_dx, vo_dy, d_width, d_height, + flags, vo_x11_create_colormap(vinfo), "gl2", title); return 0; } diff --git a/libvo/vo_x11.c b/libvo/vo_x11.c index d9f04bee0b..3f7b81ef91 100644 --- a/libvo/vo_x11.c +++ b/libvo/vo_x11.c @@ -440,38 +440,12 @@ 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(&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 | diff --git a/libvo/vo_xmga.c b/libvo/vo_xmga.c index cd57f5d12e..0b74ec1e7e 100644 --- a/libvo/vo_xmga.c +++ b/libvo/vo_xmga.c @@ -220,31 +220,8 @@ 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(&vinfo, vo_dx, vo_dy, d_width, d_height, + flags, InputOutput, "xmga", title); } if (vo_gc != None) diff --git a/libvo/vo_xover.c b/libvo/vo_xover.c index 2a3d8ff9cb..2ec9f7dea3 100644 --- a/libvo/vo_xover.c +++ b/libvo/vo_xover.c @@ -300,22 +300,10 @@ 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(&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 ); diff --git a/libvo/vo_xv.c b/libvo/vo_xv.c index 7f68510432..391b2b288b 100644 --- a/libvo/vo_xv.c +++ b/libvo/vo_xv.c @@ -301,48 +301,13 @@ 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(&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); diff --git a/libvo/vo_xvidix.c b/libvo/vo_xvidix.c index 68565cdbd5..75a673ca59 100644 --- a/libvo/vo_xvidix.c +++ b/libvo/vo_xvidix.c @@ -335,28 +335,10 @@ 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(&vinfo, vo_dx, vo_dy, + window_width, window_height, flags, + 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 ebc292ab89..3a2265856c 100644 --- a/libvo/vo_xvmc.c +++ b/libvo/vo_xvmc.c @@ -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); diff --git a/libvo/x11_common.c b/libvo/x11_common.c index a7ddc9da18..c316c7af3f 100644 --- a/libvo/x11_common.c +++ b/libvo/x11_common.c @@ -1265,6 +1265,62 @@ Window vo_x11_create_smooth_window(Display * mDisplay, Window mRoot, 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) diff --git a/libvo/x11_common.h b/libvo/x11_common.h index 4bae3b0768..c646e0309e 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(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 ); |