[Mplayer-cvslog] CVS: main/libvo x11_common.c,1.136,1.137 x11_common.h,1.29,1.30
Filip Kalinski CVS
filon at mplayerhq.hu
Fri Feb 7 20:38:42 CET 2003
Update of /cvsroot/mplayer/main/libvo
In directory mail:/var/tmp.root/cvs-serv18086/libvo
Modified Files:
x11_common.c x11_common.h
Log Message:
- 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
Index: x11_common.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.c,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -r1.136 -r1.137
--- x11_common.c 2 Feb 2003 02:42:59 -0000 1.136
+++ x11_common.c 7 Feb 2003 19:38:39 -0000 1.137
@@ -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
Index: x11_common.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/x11_common.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- x11_common.h 9 Jan 2003 20:47:14 -0000 1.29
+++ x11_common.h 7 Feb 2003 19:38:39 -0000 1.30
@@ -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
More information about the MPlayer-cvslog
mailing list