summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gui/wm/ws.c18
-rw-r--r--cfg-mplayer.h6
-rw-r--r--help/help_mp-en.h2
-rw-r--r--libvo/x11_common.c197
-rw-r--r--libvo/x11_common.h19
-rw-r--r--mplayer.c5
6 files changed, 143 insertions, 104 deletions
diff --git a/Gui/wm/ws.c b/Gui/wm/ws.c
index 277452410d..e6fef14c0e 100644
--- a/Gui/wm/ws.c
+++ b/Gui/wm/ws.c
@@ -738,18 +738,12 @@ void wsFullScreen( wsTWindow * win )
#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 @@ void wsResizeWindow( wsTWindow * win,int sx, int sy )
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 );
diff --git a/cfg-mplayer.h b/cfg-mplayer.h
index f858308c2b..f68a6d7867 100644
--- a/cfg-mplayer.h
+++ b/cfg-mplayer.h
@@ -80,9 +80,10 @@ extern int ao_pcm_waveheader;
#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 @@ static config_t mplayer_opts[]={
// 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 @@ static config_t mplayer_opts[]={
// 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},
diff --git a/help/help_mp-en.h b/help/help_mp-en.h
index 44da63dd3d..646e6a9d39 100644
--- a/help/help_mp-en.h
+++ b/help/help_mp-en.h
@@ -127,6 +127,8 @@ static char help_text[]=
#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"
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 0296aa168a..5590c4f2cc 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -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 @@ int mLocalDisplay;
/* 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 @@ static int x11_errorhandler(Display *display, XErrorEvent *event)
#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 x11_get_property(Atom type, Atom **args, unsigned long *nitems)
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 @@ void vo_init_atoms( void )
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 @@ int vo_init( void )
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 @@ int vo_x11_check_events(Display *mydisplay){
case PropertyNotify:
{
char * name = XGetAtomName( mydisplay,Event.xproperty.atom );
- int wm = vo_wm_Unknown;
if ( !name ) break;
@@ -708,7 +722,7 @@ int vo_x11_get_gnome_layer (Display * mDisplay, Window win)
&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 @@ int vo_x11_get_gnome_layer (Display * mDisplay, Window win)
void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer )
{
- if ( WinID >= 0 ) return;
-
- // window manager could be changed during play
- vo_wm_type=vo_wm_detect();
+ if (WinID >= 0) return;
- switch ( vo_wm_type )
- { case vo_wm_Layered:
+ if ( vo_fs_type & vo_wm_LAYER )
{
XClientMessageEvent xev;
@@ -734,15 +744,13 @@ void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer )
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 @@ void vo_x11_setlayer( Display * mDisplay,Window vo_window,int layer )
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 @@ void vo_x11_fullscreen( void )
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
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index f500613d4f..d89526912d 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -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_screenheight;
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 void vo_x11_uninit();
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
diff --git a/mplayer.c b/mplayer.c
index c550e150b9..4c124cf2f7 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -835,6 +835,11 @@ if(!parse_codec_cfg(get_path("codecs.conf"))){
printf("\n");
exit(0);
}
+ if(vo_fstype_list && strcmp(vo_fstype_list[0],"help")==0){
+ fstype_help();
+ printf("\n");
+ exit(0);
+ }
#ifdef USE_EDL
{