Mercurial > mplayer.hg
changeset 9317:c7f5df43b937
- support command line parameter -fstype, eg. -fstype layer=12,above,fullscreen
- help (-fstype help) also availabible
- support state BELOW (someone may want to use it...) and by -fstype none forcing of
not changing window layer (user request)
- drop icelayer option, it can be set by -fstype layer=<number>
- simplify vo_x11_fullscreen
- fs change code cleanup
author | filon |
---|---|
date | Fri, 07 Feb 2003 19:38:39 +0000 |
parents | 7a0d466a51a8 |
children | 51a9af80d874 |
files | Gui/wm/ws.c cfg-mplayer.h help/help_mp-en.h libvo/x11_common.c libvo/x11_common.h mplayer.c |
diffstat | 6 files changed, 143 insertions(+), 104 deletions(-) [+] |
line wrap: on
line diff
--- a/Gui/wm/ws.c Fri Feb 07 18:56:55 2003 +0000 +++ b/Gui/wm/ws.c Fri Feb 07 19:38:39 2003 +0000 @@ -738,18 +738,12 @@ #endif } - if ( net_wm_support != SUPPORT_FULLSCREEN || metacity_hack == 1 ) - { - vo_x11_decoration( wsDisplay,win->WindowID,decoration ); - vo_x11_sizehint( win->X,win->Y,win->Width,win->Height,0 ); - } + vo_x11_decoration( wsDisplay,win->WindowID,decoration ); + vo_x11_sizehint( win->X,win->Y,win->Width,win->Height,0 ); vo_x11_setlayer( wsDisplay,win->WindowID,win->isFullScreen ); - if ( net_wm_support != SUPPORT_FULLSCREEN || metacity_hack == 1 ) - { - if ( vo_wm_type == vo_wm_Unknown && !(vo_fsmode&16) ) - XWithdrawWindow( wsDisplay,win->WindowID,wsScreen ); - XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height ); - } + if ( vo_wm_type == 0 && !(vo_fsmode&16) ) + XWithdrawWindow( wsDisplay,win->WindowID,wsScreen ); + XMoveResizeWindow( wsDisplay,win->WindowID,win->X,win->Y,win->Width,win->Height ); XMapRaised( wsDisplay,win->WindowID ); XRaiseWindow( wsDisplay,win->WindowID ); XFlush( wsDisplay ); @@ -860,7 +854,7 @@ win->SizeHint.win_gravity=StaticGravity; win->SizeHint.base_width=sx; win->SizeHint.base_height=sy; - if ( vo_wm_type == vo_wm_Unknown ) XUnmapWindow( wsDisplay,win->WindowID ); + if ( vo_wm_type == 0 ) XUnmapWindow( wsDisplay,win->WindowID ); XSetWMNormalHints( wsDisplay,win->WindowID,&win->SizeHint ); XResizeWindow( wsDisplay,win->WindowID,sx,sy );
--- a/cfg-mplayer.h Fri Feb 07 18:56:55 2003 +0000 +++ b/cfg-mplayer.h Fri Feb 07 19:38:39 2003 +0000 @@ -80,9 +80,10 @@ #ifdef HAVE_X11 extern char *mDisplayName; extern int WinID; -extern int ice_layer; +extern int fs_layer; extern int stop_xscreensaver; extern int vo_x11_keepaspect; +extern char **vo_fstype_list; #endif #ifdef HAVE_AA @@ -274,6 +275,7 @@ // start in fullscreen mode: {"fs", &fullscreen, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nofs", &fullscreen, CONF_TYPE_FLAG, 0, 1, 0, NULL}, + {"fstype", &vo_fstype_list, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL}, // set fullscreen switch method (workaround for buggy WMs) {"fsmode", "option 'fsmode' is obsolete, avoid using it! if you really want it, try -fsmode-dontuse, but don't report bugs with this option used!", CONF_TYPE_PRINT, CONF_RANGE, 0, 31, NULL}, {"fsmode-dontuse", &vo_fsmode, CONF_TYPE_INT, CONF_RANGE, 0, 31, NULL}, @@ -294,7 +296,7 @@ // x11,xv,xmga,xvidix {"wid", &WinID, CONF_TYPE_INT, 0, 0, 0, NULL}, {"rootwin", &WinID, CONF_TYPE_FLAG, 0, -1, 0, NULL}, - {"icelayer", &ice_layer, CONF_TYPE_INT, CONF_RANGE, 0, 15, NULL}, + {"icelayer", "Use -fstype layer:<number> instead. -icelayer was obsoleted\n", CONF_TYPE_PRINT, 0, 0, 0, NULL}, {"stop_xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 0, 1, NULL}, {"nostop_xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 1, 0, NULL}, {"keepaspect", &vo_x11_keepaspect, CONF_TYPE_FLAG, 0, 0, 1, NULL},
--- a/help/help_mp-en.h Fri Feb 07 18:56:55 2003 +0000 +++ b/help/help_mp-en.h Fri Feb 07 19:38:39 2003 +0000 @@ -127,6 +127,8 @@ #define MSGTR_AvailableVideoCodecs "Available video codecs:\n" #define MSGTR_AvailableAudioFm "\nAvailable (compiled-in) audio codec families/drivers:\n" #define MSGTR_AvailableVideoFm "\nAvailable (compiled-in) video codec families/drivers:\n" +#define MSGTR_AvailableFsType "Available fullscreen layer change modes:\n" +#define MSGTR_DefaultFsType "\nThe deafult order is \"layer=%d,stays_on_top,above,fullscreen\".\nIt will be used in case of specifying incorrect or unsupported types.\n" #define MSGTR_UsingRTCTiming "Using Linux hardware RTC timing (%ldHz).\n" #define MSGTR_CannotReadVideoProperties "Video: Cannot read properties.\n" #define MSGTR_NoStreamFound "No stream found.\n"
--- a/libvo/x11_common.c Fri Feb 07 18:56:55 2003 +0000 +++ b/libvo/x11_common.c Fri Feb 07 19:38:39 2003 +0000 @@ -15,6 +15,7 @@ #include <sys/mman.h> #include "video_out.h" +#include "help_mp.h" #include <X11/Xmd.h> #include <X11/Xlib.h> @@ -46,8 +47,8 @@ #define WIN_LAYER_ONTOP 6 #define WIN_LAYER_ABOVE_DOCK 10 -int ice_layer=WIN_LAYER_ABOVE_DOCK; -int orig_layer=WIN_LAYER_NORMAL; +int fs_layer=WIN_LAYER_ABOVE_DOCK; +int orig_layer; int stop_xscreensaver=0; @@ -65,18 +66,19 @@ /* output window id */ int WinID=-1; int vo_mouse_autohide = 0; -int vo_wm_type = -1; +int vo_wm_type = 0; +int vo_fs_type = 0; +char** vo_fstype_list; /* if equal to 1 means that WM is a metacity (broken as hell) */ int metacity_hack = 0; -int net_wm_support = 0; - Atom XA_NET_SUPPORTED; Atom XA_NET_WM_STATE; Atom XA_NET_WM_STATE_FULLSCREEN; Atom XA_NET_WM_STATE_ABOVE; Atom XA_NET_WM_STATE_STAYS_ON_TOP; +Atom XA_NET_WM_STATE_BELOW; Atom XA_NET_WM_PID; Atom XA_WIN_PROTOCOLS; Atom XA_WIN_LAYER; @@ -147,14 +149,30 @@ #undef MSGLEN } +void fstype_help(void) +{ + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_AvailableFsType); + + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "none", "don't set fullscreen window layer"); + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "layer", "use _WIN_LAYER hint with default layer"); + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "layer=<0..15>", "use _WIN_LAYER hint with a given layer number"); + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "above", "use _NETWM_STATE_ABOVE hint if available"); + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "below", "use _NETWM_STATE_BELOW hint if vailable"); + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "fullscreen", "use _NETWM_STATE_FULLSCREEN hint if availale"); + mp_msg(MSGT_VO, MSGL_INFO, " %-21s %s\n", "stays_on_top", "use _NETWM_STATE_STAYS_ON_TOP hint if available"); + + mp_msg(MSGT_VO, MSGL_INFO, MSGTR_DefaultFsType, WIN_LAYER_ABOVE_DOCK); +} + int net_wm_support_state_test( Atom atom ) { -#define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_dbg( MSGT_VO,MSGL_STATUS, "[x11] Detected wm supports " #x " state.\n" ); return SUPPORT_##x; } } +#define NET_WM_STATE_TEST(x) { if (atom == XA_NET_WM_STATE_##x) { mp_msg( MSGT_VO,MSGL_V, "[x11] Detected wm supports " #x " state.\n" ); return vo_wm_##x; } } NET_WM_STATE_TEST(FULLSCREEN); NET_WM_STATE_TEST(ABOVE); NET_WM_STATE_TEST(STAYS_ON_TOP); - return SUPPORT_NONE; + NET_WM_STATE_TEST(BELOW); + return 0; } int x11_get_property(Atom type, Atom **args, unsigned long *nitems) @@ -170,63 +188,57 @@ int vo_wm_detect( void ) { int i; - int wm = vo_wm_Unknown; + int wm = 0; unsigned long nitems; Atom * args = NULL; - if ( WinID >= 0 ) return vo_wm_Unknown; + if ( WinID >= 0 ) return 0; // -- supports layers if (x11_get_property(XA_WIN_PROTOCOLS, &args, &nitems)) { - mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm supports layers.\n" ); + mp_msg( MSGT_VO,MSGL_V,"[x11] Detected wm supports layers.\n" ); for (i = 0; i < nitems; i++) { if ( args[i] == XA_WIN_LAYER) { - wm = vo_wm_Layered; + wm |= vo_wm_LAYER; metacity_hack |= 1; - } + } else if ( args[i] == XA_WIN_HINTS) - // metacity is the only manager which supports _WIN_LAYER but not _WIN_HINTS + // metacity is the only manager which reports that supports _WIN_LAYER but not _WIN_HINTS. // what's more is has broken _WIN_LAYER support metacity_hack |= 2; } XFree( args ); - if (wm && metacity_hack == 3) - return wm; + if (wm && (metacity_hack == 1)) + { + // metacity reports that it supports layers, but it is not really truth :-) + wm ^= vo_wm_LAYER; + mp_msg( MSGT_VO,MSGL_V,"[x11] Using workaround for Metacity bugs.\n" ); + } } - if (metacity_hack == 1) - mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Using workaround for Metacity bugs.\n" ); - // --- netwm if (x11_get_property(XA_NET_SUPPORTED, &args, &nitems)) { - mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is of class NetWM.\n" ); - net_wm_support = 0; + mp_msg( MSGT_VO,MSGL_V,"[x11] Detected wm supports NetWM.\n" ); for (i = 0; i < nitems; i++) - net_wm_support |= net_wm_support_state_test (args[i]); + wm |= net_wm_support_state_test (args[i]); XFree( args ); - if (net_wm_support) + // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support + // (in their implementation it only changes internal state of window, nothing more!!!) + if (wm & vo_wm_FULLSCREEN) { - // ugly hack for broken OpenBox _NET_WM_STATE_FULLSCREEN support - // (in their implementation it only changes internal state of window, nothing more!!!) - if (net_wm_support & SUPPORT_FULLSCREEN) - { - if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems)) + if (x11_get_property(XA_BLACKBOX_PID, &args, &nitems)) { - mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is a broken OpenBox.\n" ); - net_wm_support=0; - XFree( args ); - return vo_wm_Unknown; + mp_msg( MSGT_VO,MSGL_V,"[x11] Detected wm is a broken OpenBox.\n" ); + wm ^= vo_wm_FULLSCREEN; } - XFree (args); - } - return vo_wm_NetWM; + XFree (args); } } - - if ( wm == vo_wm_Unknown ) mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Unknown wm type...\n" ); + + if ( wm == 0 ) mp_msg( MSGT_VO,MSGL_V,"[x11] Unknown wm type...\n" ); return wm; } @@ -237,6 +249,7 @@ XA_INIT(_NET_WM_STATE_FULLSCREEN); XA_INIT(_NET_WM_STATE_ABOVE); XA_INIT(_NET_WM_STATE_STAYS_ON_TOP); + XA_INIT(_NET_WM_STATE_BELOW); XA_INIT(_NET_WM_PID); XA_INIT(_WIN_PROTOCOLS); XA_INIT(_WIN_LAYER); @@ -367,6 +380,8 @@ vo_wm_type=vo_wm_detect(); + vo_fs_type=vo_x11_get_fs_type(vo_wm_type); + saver_off(mDisplay); return 1; } @@ -659,7 +674,6 @@ case PropertyNotify: { char * name = XGetAtomName( mydisplay,Event.xproperty.atom ); - int wm = vo_wm_Unknown; if ( !name ) break; @@ -708,7 +722,7 @@ &bytesafter, (unsigned char **) &args) == Success && nitems > 0 && args) { - mp_msg (MSGT_VO, MSGL_STATUS, "[x11] original window layer is %d.\n", *args); + mp_msg (MSGT_VO, MSGL_V, "[x11] original window layer is %d.\n", *args); return *args; } return WIN_LAYER_NORMAL; @@ -716,13 +730,9 @@ void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer ) { - if ( WinID >= 0 ) return; + if (WinID >= 0) return; - // window manager could be changed during play - vo_wm_type=vo_wm_detect(); - - switch ( vo_wm_type ) - { case vo_wm_Layered: + if ( vo_fs_type & vo_wm_LAYER ) { XClientMessageEvent xev; @@ -734,15 +744,13 @@ xev.window = vo_window; xev.message_type = XA_WIN_LAYER; xev.format = 32; - xev.data.l[0] = layer?ice_layer:orig_layer; // if not fullscreen, stay on default layer + xev.data.l[0] = layer?fs_layer:orig_layer; // if not fullscreen, stay on default layer xev.data.l[1] = CurrentTime; - mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Layered style stay on top ( layer %d ).\n",xev.data.l[0] ); - printf( "[x11] Layered style stay on top ( layer %d ).\n",(int)xev.data.l[0] ); + mp_msg( MSGT_VO,MSGL_V,"[x11] Layered style stay on top ( layer %d ).\n",xev.data.l[0] ); XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask, (XEvent *) &xev); - break; - } - case vo_wm_NetWM: - { + } else + if ( vo_fs_type & vo_wm_NETWM ) + { XClientMessageEvent xev; char *state; @@ -754,38 +762,71 @@ xev.format=32; xev.data.l[0]=layer; - if (net_wm_support & SUPPORT_ABOVE) - { - xev.data.l[1]=XA_NET_WM_STATE_ABOVE; - XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev ); - } else - if (net_wm_support & SUPPORT_STAYS_ON_TOP) - { + if ( vo_fs_type & vo_wm_STAYS_ON_TOP ) xev.data.l[1]=XA_NET_WM_STATE_STAYS_ON_TOP; - XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev ); - } else - if (net_wm_support & SUPPORT_FULLSCREEN) - { + else + if ( vo_fs_type & vo_wm_ABOVE ) + xev.data.l[1]=XA_NET_WM_STATE_ABOVE; + else + if ( vo_fs_type & vo_wm_FULLSCREEN ) xev.data.l[1]=XA_NET_WM_STATE_FULLSCREEN; - XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev ); - } + else + if ( vo_fs_type & vo_wm_BELOW ) + // This is not fallback. We can safely assume that situation where + // only NETWM_STATE_BELOW is supported and others not, doesn't exist. + xev.data.l[1]=XA_NET_WM_STATE_BELOW; + + XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev ); state = XGetAtomName (mDisplay, xev.data.l[1]); - mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] NET style stay on top ( layer %d ). Using state %s.\n",layer,state ); - printf( "[x11] NET style stay on top ( layer %d ). Using state %s.\n",layer,state ); + mp_msg( MSGT_VO,MSGL_V,"[x11] NET style stay on top ( layer %d ). Using state %s.\n",layer,state ); XFree (state); - } } } +int vo_x11_get_fs_type( int supported ) +{ + int i; + int type; + + if (vo_fstype_list) { + i = 0; + for (i = 0; vo_fstype_list[i]; i++) + { + type = supported; + + if (strncmp(vo_fstype_list[i], "layer", 5) == 0) + { + if (vo_fstype_list[i][5] == '=') + { + char *endptr = NULL; + int layer = strtol(vo_fstype_list[i]+6, &endptr, 10); + + if (endptr && *endptr == '\0' && layer >= 0 && layer <= 15) + fs_layer = layer; + } + type &= vo_wm_LAYER; + } + else if (strcmp(vo_fstype_list[i], "above") == 0) type &= vo_wm_ABOVE; + else if (strcmp(vo_fstype_list[i], "fullscreen") == 0) type &= vo_wm_FULLSCREEN; + else if (strcmp(vo_fstype_list[i], "stays_on_top") == 0) type &= vo_wm_STAYS_ON_TOP; + else if (strcmp(vo_fstype_list[i], "below") == 0) type &= vo_wm_BELOW; + else if (strcmp(vo_fstype_list[i], "none") == 0) return 0; + else type = 0; + + if (type) + return type; + } + } + + return supported; +} + void vo_x11_fullscreen( void ) { int x,y,w,h; if ( WinID >= 0 ) return; - // window manager could be changed during play - vo_wm_type=vo_wm_detect(); - if ( vo_fs ){ // fs->win if(vo_dwidth != vo_screenwidth && vo_dheight != vo_screenheight) return; @@ -800,19 +841,13 @@ vo_old_x=vo_dx; vo_old_y=vo_dy; vo_old_width=vo_dwidth; vo_old_height=vo_dheight; x=0; y=0; w=vo_screenwidth; h=vo_screenheight; } - if (net_wm_support!=SUPPORT_FULLSCREEN || metacity_hack==1) - { - vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 0 : 1 ); - vo_x11_sizehint( x,y,w,h,0 ); - } + vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 0 : 1 ); + vo_x11_sizehint( x,y,w,h,0 ); vo_x11_setlayer( mDisplay,vo_window,vo_fs ); - if (net_wm_support!=SUPPORT_FULLSCREEN || metacity_hack==1) - { - if(vo_wm_type==vo_wm_Unknown && !(vo_fsmode&16)) - // XUnmapWindow( mDisplay,vo_window ); // required for MWM + if(vo_wm_type==0 && !(vo_fsmode&16)) +// XUnmapWindow( mDisplay,vo_window ); // required for MWM XWithdrawWindow(mDisplay,vo_window,mScreen); - XMoveResizeWindow( mDisplay,vo_window,x,y,w,h ); - } + XMoveResizeWindow( mDisplay,vo_window,x,y,w,h ); #ifdef HAVE_XINERAMA vo_x11_xinerama_move(mDisplay,vo_window); #endif
--- a/libvo/x11_common.h Fri Feb 07 18:56:55 2003 +0000 +++ b/libvo/x11_common.h Fri Feb 07 19:38:39 2003 +0000 @@ -7,16 +7,13 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> -#define vo_wm_Unknown 0 -#define vo_wm_NetWM 1 -#define vo_wm_Layered 2 +#define vo_wm_LAYER 1 +#define vo_wm_FULLSCREEN 2 +#define vo_wm_STAYS_ON_TOP 4 +#define vo_wm_ABOVE 8 +#define vo_wm_BELOW 16 +#define vo_wm_NETWM (vo_wm_FULLSCREEN | vo_wm_STAYS_ON_TOP | vo_wm_ABOVE | vo_wm_BELOW) -#define SUPPORT_NONE 0 -#define SUPPORT_FULLSCREEN 1 -#define SUPPORT_ABOVE 2 -#define SUPPORT_STAYS_ON_TOP 4 - -extern int net_wm_support; extern int metacity_hack; extern int vo_fsmode; @@ -26,7 +23,10 @@ extern int vo_dwidth; extern int vo_dheight; extern int vo_fs; +extern int vo_fs_layer; extern int vo_wm_type; +extern int vo_fs_type; +extern char** vo_fstype_list; extern char *mDisplayName; extern Display *mDisplay; @@ -53,6 +53,7 @@ extern Colormap vo_x11_create_colormap(XVisualInfo *vinfo); extern uint32_t vo_x11_set_equalizer(char *name, int value); extern uint32_t vo_x11_get_equalizer(char *name, int *value); +extern void fstype_help(void); #endif