[MPlayer-dev-eng] [PATCH] Fullscreen cleanup again

Filip Kalinski filon at pld.org.pl
Mon Dec 30 11:59:48 CET 2002


Hi,

I have looked at the fullscreen code and realized that there are
generally two types of layer support for window managers:

- NetWM states (FULLSCREEN, STAYS_ON_TOP, ABOVE)
  sawfish, metacity, kwin
- _WIN_LAYER
  IceWM, WindowMaker

So we don't need any other window manager detection functions, we need
only to check for these two. Also there is no need to keep IceWM stuff
separately, so I changed option "-icelayer" to "-fslayer" (leaving
icelayer as obsolette).

Code tested on lots of windowmanagers.

-- 
Filip Kalinski <filon at pld.org.pl>
-------------- next part --------------
--- main.old/DOCS/Chinese/faq.html	2002-10-05 12:19:07.000000000 +0200
+++ main.work/DOCS/Chinese/faq.html	2002-12-30 11:51:15.000000000 +0100
@@ -282,7 +282,7 @@
   <DD>&nbsp;</DD>
 
   <DT>QŁşIcewmľÄČÎÎńĚő˛ťśĎľÄľ˛×ĄČŤĆÁÄťľÄľçÓ°ŁĄ</DT>
-  <DD>AŁşŐⲝӌ¸ĂÔ١˘ÉúÁËŁŹľŤČçšűËüȡʾČÔČťˇ˘ÉúŁŹĘšÓĂ<CODE>-icelayer</CODE>ŃĄĎĎň
+  <DD>AŁşŐⲝӌ¸ĂÔ١˘ÉúÁËŁŹľŤČçšűËüȡʾČÔČťˇ˘ÉúŁŹĘšÓĂ<CODE>-fslayer</CODE>ŃĄĎĎň
 <A HREF="http://mplayerhq.hu/pipermail/mplayer-users/">mplayer-users</A>ÓĘźţÁĐąíą¨¸ćĄŁ</DD>
   <DD>&nbsp;</DD>
 
--- main.old/DOCS/French/faq.html	2002-12-06 12:41:27.000000000 +0100
+++ main.work/DOCS/French/faq.html	2002-12-30 11:51:25.000000000 +0100
@@ -371,7 +371,7 @@
 
   <DT>Q: La barre des tâches d'Icewm continue de couvrir le film en mode plein écran!</DT>
   <DD>A: Cela ne devrait plus arriver, si c'est toujours le cas utilisez l'option
-    <CODE>-icelayer</CODE> et rapportez son résultat ŕ la liste de diffusion
+    <CODE>-fslayer</CODE> et rapportez son résultat ŕ la liste de diffusion
     <A HREF="http://mplayerhq.hu/pipermail/mplayer-users/">mplayer-users</A>.</DD>
   <DD>&nbsp;</DD>
 
--- main.old/DOCS/German/faq.html	2002-08-24 16:22:46.000000000 +0200
+++ main.work/DOCS/German/faq.html	2002-12-30 11:51:46.000000000 +0100
@@ -331,7 +331,7 @@
   <DD>&nbsp;</DD>
 
   <DT>Q: Icewm's Taskbar bleibt im Vollbildschirm-Modus ständig über der Filmausgabe!</DT>
-  <DD>A: Dies sollte nicht mehr geschehen, falls doch ist die <CODE>-icelayer</CODE>
+  <DD>A: Dies sollte nicht mehr geschehen, falls doch ist die <CODE>-fslayer</CODE>
     Option zu verwenden und ein Bericht an die
     <A HREF="http://mplayerhq.hu/pipermail/mplayer-users/">mplayer-users</A>
     zu senden.</DD>
--- main.old/DOCS/Italian/faq.html	2002-09-26 19:22:49.000000000 +0200
+++ main.work/DOCS/Italian/faq.html	2002-12-30 11:51:08.000000000 +0100
@@ -482,7 +482,7 @@
 </B></TD><TR><TD></TD><TD VALIGN=top>
 <FONT CLASS="text">R:</TD>
 <TD><FONT CLASS="text">
-Questo non dovrebbe piů succedere, se invece succede ancora usa l'opzione <CODE>-icelayer</CODE>
+Questo non dovrebbe piů succedere, se invece succede ancora usa l'opzione <CODE>-fslayer</CODE>
 e segnalalo alla mailinglist <A HREF="http://mplayerhq.hu/pipermail/mplayer-users/">mplayer-users</A>.
 </TD><TR><TD COLSPAN=3>&nbsp;</TD><TR>
 
--- main.old/DOCS/Polish/mplayer.1	2002-12-29 11:46:30.000000000 +0100
+++ main.work/DOCS/Polish/mplayer.1	2002-12-30 11:49:22.000000000 +0100
@@ -1243,8 +1243,9 @@
 Modyfikuj barwę sygnału wideo (domyślnie 0).
 Dzięki tej opcji możesz otrzymać kolorowy negatyw obrazu.
 .TP
-.B \-icelayer <0\-15> (tylko icewm)
-Ustaw warstwę okna pełnoekranowego mplayera dla icewm.
+.B \-fslayer <0\-15>
+Ustaw warstwę okna pełnoekranowego mplayera dla menedżerów okinen wspierających warstwy,
+takich jak IceWM lub WindowMaker.
 
 .PD 0
 .RSs
--- main.old/DOCS/faq.html	2002-10-28 01:23:39.000000000 +0100
+++ main.work/DOCS/faq.html	2002-12-30 11:50:47.000000000 +0100
@@ -368,7 +368,7 @@
 
   <DT>Q: Icewm's taskbar keeps covering the movie in fullscreen mode!</DT>
   <DD>A: This shouldn't happen anymore, if it still does use the
-    <CODE>-icelayer</CODE> option and report it to the
+    <CODE>-fslayer</CODE> option and report it to the
     <A HREF="http://mplayerhq.hu/pipermail/mplayer-users/">mplayer-users</A>
     mailing list.</DD>
   <DD>&nbsp;</DD>
--- main.old/DOCS/mplayer.1	2002-12-29 11:46:27.000000000 +0100
+++ main.work/DOCS/mplayer.1	2002-12-30 11:54:22.000000000 +0100
@@ -1323,8 +1323,9 @@
 Adjust hue of video signal (default: 0).
 You can get colored negative of image with this option.
 .TP
-.B \-icelayer <0\-15> (icewm only)
-Sets the layer of the fullscreen window of mplayer for icewm.
+.B \-fslayer <0\-15>
+Sets the layer of the fullscreen window of mplayer for window managers supporting
+layers, such as IceWM and WindowMaker.
 
 .PD 0
 .RSs
--- main.old/cfg-mplayer.h	2002-12-24 00:21:53.000000000 +0100
+++ main.work/cfg-mplayer.h	2002-12-30 11:59:11.000000000 +0100
@@ -80,7 +80,7 @@
 #ifdef HAVE_X11
 extern char *mDisplayName;
 extern int WinID;
-extern int ice_layer;
+extern int fs_layer;
 extern int stop_xscreensaver;
 #endif
 
@@ -291,7 +291,8 @@
 	// 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", "option 'icelayer' is obsolete. Use -fslayer instead.\n", CONF_TYPE_PRINT, CONF_RANGE, 0, 15, NULL},
+	{"fslayer", &fs_layer, CONF_TYPE_INT, CONF_RANGE, 0, 15, NULL},
 	{"stop_xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 0, 1, NULL},
 	{"nostop_xscreensaver", &stop_xscreensaver, CONF_TYPE_FLAG, 0, 1, 0, NULL},
 #endif
--- main.old/libvo/x11_common.c	2002-12-30 10:15:49.000000000 +0100
+++ main.work/libvo/x11_common.c	2002-12-30 11:55:49.000000000 +0100
@@ -43,11 +43,14 @@
 
 #define vo_wm_Unknown     0
 #define vo_wm_NetWM       1
-#define vo_wm_KDE         2
-#define vo_wm_IceWM       3
-#define vo_wm_WMakerStyle 4
+#define vo_wm_Layered     2
 
-int ice_layer=12;
+#define WIN_LAYER_ONBOTTOM               2
+#define WIN_LAYER_NORMAL                 4
+#define WIN_LAYER_ONTOP                  6
+#define WIN_LAYER_ABOVE_DOCK             12
+ 
+int fs_layer=WIN_LAYER_ABOVE_DOCK;
 int stop_xscreensaver=0;
 
 static int dpms_disabled=0;
@@ -131,18 +134,6 @@
 #undef MSGLEN
 }
 
-int vo_wm_string_test( char * name )
-{
- if ( !strncmp( name,"_ICEWM_TRAY",11 ) )
-  { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is IceWM.\n" ); return vo_wm_IceWM; }
- if ( !strncmp( name,"_KDE_",5 ) )
-  { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is KDE.\n" ); return vo_wm_KDE; }
- if ( !strncmp( name,"KWM_WIN",7 ) )
-  { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is WindowMaker style.\n" ); return vo_wm_WMakerStyle; }
-// fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",win,name,xev.xproperty.atom );
- return vo_wm_Unknown;
-}
-
 int net_wm_support_state_test( char *name )
 {
   mp_dbg(MSGT_VO,MSGL_DBG2, "[x11] NetWM supports %s\n",name);
@@ -158,19 +149,15 @@
 int vo_wm_detect( void )
 {
  Atom            type;
- Window		 win;
  XEvent          xev;
- int		 c = 0;
+ int             i;
  int             wm = vo_wm_Unknown;
  int             format;
  unsigned long   nitems, bytesafter;
  Atom          * args = NULL;
- char          * name = NULL;
- int i;
  
  if ( WinID >= 0 ) return vo_wm_Unknown;
  
-#if 1
 // --- netwm 
  type=XInternAtom( mDisplay,"_NET_SUPPORTED",False );
  if ( Success == XGetWindowProperty( mDisplay,mRootWin,type,0,16384,False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char **) &args ) && nitems > 0 )
@@ -179,35 +166,22 @@
    for (i = 0; i < nitems; i++)
      net_wm_support |= net_wm_support_state_test (XGetAtomName (mDisplay, args[i]));
    XFree( args );
-   return vo_wm_NetWM;
+   if (net_wm_support)
+     return vo_wm_NetWM;
   }
-#endif
-// --- other wm
- mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Create window for WM detect ...\n" );
- win=XCreateSimpleWindow( mDisplay,mRootWin,vo_screenwidth,vo_screenheight,1,1,0,0,0 );
- XSelectInput( mDisplay,win,PropertyChangeMask | StructureNotifyMask );
- XMapWindow( mDisplay,win );
- XMoveWindow( mDisplay,win,vo_screenwidth,vo_screenheight );
- do 
-  { 
-   XCheckWindowEvent( mDisplay,win,PropertyChangeMask | StructureNotifyMask,&xev );
-
-   if ( xev.type == PropertyNotify )
-    {
-     name=XGetAtomName( mDisplay,xev.xproperty.atom );
-     if ( !name ) break;
 
-     wm=vo_wm_string_test( name );
-     if ( wm != vo_wm_Unknown ) break;
-     XFree( name ); name=NULL;
-    }
- } while( c++ < 25 );
- if ( name ) XFree( name );
- XUnmapWindow( mDisplay,win );
- XDestroyWindow( mDisplay,win );
-#ifdef MP_DEBUG
+// -- supports layers
+ type=XInternAtom( mDisplay,"_WIN_PROTOCOLS",False );
+ if ( Success == XGetWindowProperty( mDisplay,mRootWin,type,0,16384,False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char **) &args ) && nitems > 0 )
+  {
+   mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm supports layers.\n" );
+   for (i = 0; i < nitems; i++)
+     if (!strcmp( XGetAtomName (mDisplay, args[i]), "_WIN_LAYER"));
+       return vo_wm_Layered;
+   XFree( args );
+  }
+ 
  if ( wm == vo_wm_Unknown ) mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Unknown wm type...\n" );
-#endif
  return wm;
 }    
 
@@ -628,9 +602,6 @@
 	    
 	    if ( !name ) break;
 	    
-	    wm=vo_wm_string_test(name);
-	    if ( wm != vo_wm_Unknown ) vo_wm_type=wm;
-
 //          fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",vo_window,name,Event.xproperty.atom );
 	      
 	    XFree( name );
@@ -654,12 +625,6 @@
  XSetWMNormalHints( mDisplay,vo_window,&vo_hint );
 }
 
-#define WIN_LAYER_ONBOTTOM               2
-#define WIN_LAYER_NORMAL                 4
-#define WIN_LAYER_ONTOP                  6
-#define WIN_LAYER_ABOVE_DOCK             10
- 
-
 void vo_x11_setlayer( int layer )
 {
  Atom            type,arg1,arg2;
@@ -671,7 +636,7 @@
  if ( WinID >= 0 ) return;
  
  switch ( vo_wm_type )
- { case vo_wm_IceWM:
+ { case vo_wm_Layered:
   {
     XClientMessageEvent xev;
     memset(&xev, 0, sizeof(xev));
@@ -680,9 +645,9 @@
     xev.window = vo_window;
     xev.message_type = XInternAtom(mDisplay, "_WIN_LAYER", False);
     xev.format = 32;
-    xev.data.l[0] = layer?ice_layer:4; // if not fullscreen, stay on layer "Normal"
+    xev.data.l[0] = layer?fs_layer:WIN_LAYER_NORMAL; // if not fullscreen, stay on layer "Normal"
     xev.data.l[1] = CurrentTime;
-    mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] IceWM style stay on top ( layer %d ).\n",xev.data.l[0] );
+    mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Layered style stay on top ( layer %d ).\n",xev.data.l[0] );
     XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask, (XEvent *) &xev);
     break;
   }
@@ -691,8 +656,6 @@
    XClientMessageEvent  xev;
    mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] NET style stay on top ( layer %d ).\n",layer );
 
-   if (net_wm_support & SUPPORT_FULLSCREEN)
-   {
    memset( &xev,0,sizeof( xev ) );
    xev.type=ClientMessage;
    xev.message_type=XInternAtom( mDisplay,"_NET_WM_STATE",False );
@@ -700,61 +663,24 @@
    xev.window=vo_window;
    xev.format=32;
    xev.data.l[0]=layer;
-   xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_FULLSCREEN",False );
-   XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
+   
+   if (net_wm_support & SUPPORT_FULLSCREEN)
+   {
+     xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_FULLSCREEN",False );
+     XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
    } else
    if (net_wm_support & SUPPORT_STAYS_ON_TOP)
    {
-   memset( &xev,0,sizeof( xev ) );
-   xev.type=ClientMessage;
-   xev.message_type=XInternAtom( mDisplay,"_NET_WM_STATE",False );
-   xev.display=mDisplay;
-   xev.window=vo_window;
-   xev.format=32;
-   xev.data.l[0]=layer;
-   xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_STAYS_ON_TOP",False );
-   XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
+     xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_STAYS_ON_TOP",False );
+     XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
    } else
    if (net_wm_support & SUPPORT_ABOVE)
    {
-   memset( &xev,0,sizeof( xev ) );
-   xev.type=ClientMessage;
-   xev.message_type=XInternAtom( mDisplay,"_NET_WM_STATE",False );
-   xev.display=mDisplay;
-   xev.window=vo_window;
-   xev.format=32;
-   xev.data.l[0]=layer;
-   xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_ABOVE",False );
-   XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
+     xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_ABOVE",False );
+     XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
    }
-   break;
-  }
- default:
- {
- type=XInternAtom( mDisplay,"_WIN_SUPPORTING_WM_CHECK",False );
- if ( Success == XGetWindowProperty( mDisplay,mRootWin,type,0,16384,False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char**)(&args) ) && nitems > 0 )
-  {
-   XClientMessageEvent  xev;
-   mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Gnome style stay on top ( layer %d ).\n",layer );
-   memset( &xev,0,sizeof( xev ) );
-   xev.type=ClientMessage;
-   xev.window=vo_window;
-   xev.message_type=XInternAtom( mDisplay,"_WIN_LAYER",False );
-   xev.format=32;
-   switch ( layer ) 
-    {
-     case -1: xev.data.l[0] = WIN_LAYER_ONBOTTOM; break;
-     case  0: xev.data.l[0] = WIN_LAYER_NORMAL;   break;
-     case  1: xev.data.l[0] = WIN_LAYER_ABOVE_DOCK; break;
-    }
-   
-   if ( layer ) XRaiseWindow( mDisplay,vo_window );
-   XSendEvent( mDisplay,mRootWin,False,SubstructureNotifyMask,(XEvent*)&xev );
-   XFree( args );
-   return;
   }
  }
- }
 }
 
 void vo_x11_fullscreen( void )
@@ -763,6 +689,9 @@
 
  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;


More information about the MPlayer-dev-eng mailing list