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

Filip Kalinski filon at pld.org.pl
Mon Dec 30 01:23:14 CET 2002


Hi,

I made a next simple patch for fullscreen, which cleans up the code.
Instead of checking if a property changed after sending event I check
what types of _NET_WM_STATE atoms window manager supports.

The second thing is, that if window manager supports
_NET_WM_STATE_FULLSCREEN we don't have to resize window, change
decoration etc..., so it's good to know it, and it lets broken
sawifsh work without beeping on window resizing bug :-))

I checked again sawfish, metacity, kwin, blackbox and wmaker and it
works (metacity with Gui still doesn't work).

-- 
Filip Kalinski <filon at pld.org.pl>
-------------- next part --------------
--- main.old/libvo/x11_common.c	2002-12-30 01:04:44.000000000 +0100
+++ main.work/libvo/x11_common.c	2002-12-30 01:04:51.000000000 +0100
@@ -66,6 +66,12 @@
 int vo_mouse_autohide = 0;
 int vo_wm_type = -1;
 
+#define SUPPORT_NONE 0
+#define SUPPORT_FULLSCREEN 1
+#define SUPPORT_ABOVE 2
+#define SUPPORT_STAYS_ON_TOP 4
+int net_wm_support = 0;
+
 static int vo_old_x = 0;
 static int vo_old_y = 0;
 static int vo_old_width = 0;
@@ -137,6 +143,18 @@
  return vo_wm_Unknown;
 }
 
+int net_wm_support_state_test( char *name )
+{
+	printf ("AAAAAA: %s\n", name);
+ if ( !strncmp( name,"_NET_WM_STATE_FULLSCREEN", 24 ) )
+  { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm supports FULLSCREEN state.\n" ); return SUPPORT_FULLSCREEN; }
+ if ( !strncmp( name,"_NET_WM_STATE_STAYS_ON_TOP", 24 ) )
+  { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm supports STAYS_ON_TOP state.\n" ); return SUPPORT_STAYS_ON_TOP; }
+ if ( !strncmp( name,"_NET_WM_STATE_ABOVE", 24 ) )
+  { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm supports ABOVE state.\n" ); return SUPPORT_ABOVE; }
+ return SUPPORT_NONE;
+}
+
 int vo_wm_detect( void )
 {
  Atom            type;
@@ -146,17 +164,20 @@
  int             wm = vo_wm_Unknown;
  int             format;
  unsigned long   nitems, bytesafter;
- unsigned char * args = NULL;
+ 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,&args ) && nitems > 0 )
+ 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 is of class NetWM.\n" );
+   for (i = 0; i < nitems; i++)
+     net_wm_support |= net_wm_support_state_test (XGetAtomName (mDisplay, args[i]));
    XFree( args );
    return vo_wm_NetWM;
   }
@@ -649,7 +670,8 @@
  
  if ( WinID >= 0 ) return;
  
- if ( vo_wm_type == vo_wm_IceWM )
+ switch ( vo_wm_type )
+ { case vo_wm_IceWM:
   {
     XClientMessageEvent xev;
     memset(&xev, 0, sizeof(xev));
@@ -662,15 +684,15 @@
     xev.data.l[1] = CurrentTime;
     mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] IceWM style stay on top ( layer %d ).\n",xev.data.l[0] );
     XSendEvent(mDisplay, mRootWin, False, SubstructureNotifyMask, (XEvent *) &xev);
-   return;
+    break;
   }
-
- 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 )
+  case vo_wm_NetWM:
   {
    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 );
@@ -680,19 +702,9 @@
    xev.data.l[0]=layer;
    xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_FULLSCREEN",False );
    XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
-   XFree( args );
-   
-   type=XInternAtom( mDisplay,"_NET_WM_STATE",False );
-   arg1=XInternAtom( mDisplay,"_NET_WM_STATE_FULLSCREEN",False );
-   if ( Success == XGetWindowProperty( mDisplay,vo_window,type,0,16384,False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char**)(&args) ) && nitems > 0 && format == 32) {
-       for (i = 0; i < nitems; i++) {
-	   if (((Atom)args[i] == arg1)) {
-	       XFree( args );
-	       return;
-	   }
-       }
-   }
-   
+   } 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 );
@@ -702,7 +714,9 @@
    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 );
-
+   } else
+   if (net_wm_support & SUPPORT_ABOVE)
+   {
    memset( &xev,0,sizeof( xev ) );
    xev.type=ClientMessage;
    xev.message_type=XInternAtom( mDisplay,"_NET_WM_STATE",False );
@@ -712,23 +726,11 @@
    xev.data.l[0]=layer;
    xev.data.l[1]=XInternAtom( mDisplay,"_NET_WM_STATE_ABOVE",False );
    XSendEvent( mDisplay,mRootWin,False,SubstructureRedirectMask,(XEvent*)&xev );
-   XFree( args );
-
-   type=XInternAtom( mDisplay,"_NET_WM_STATE",False );
-   arg1=XInternAtom( mDisplay,"_NET_WM_STATE_STAYS_ON_TOP",False );
-   arg2=XInternAtom( mDisplay,"_NET_WM_STATE_ABOVE",False );
-   if ( Success == XGetWindowProperty( mDisplay,vo_window,type,0,16384,False,AnyPropertyType,&type,&format,&nitems,&bytesafter,(unsigned char**)(&args) ) && nitems > 0 && format == 32) {
-       for (i = 0; i < nitems; i++) {
-	   if (((Atom)args[i] == arg1) || ((Atom)args[i] == arg2)) {
-	       XFree( args );
-	       return;
-	   }
-       }
    }
-   XFree( args );
-   // State was not set, continue with GNOME hints
+   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 )
   {
@@ -751,6 +753,8 @@
    XFree( args );
    return;
   }
+ }
+ }
 }
 
 void vo_x11_fullscreen( void )
@@ -773,14 +777,19 @@
    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;
  }
-
- vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 0 : 1 );
- vo_x11_sizehint( x,y,w,h,0 );
+ if (! (net_wm_support & SUPPORT_FULLSCREEN))
+ {
+   vo_x11_decoration( mDisplay,vo_window,(vo_fs) ? 0 : 1 );
+   vo_x11_sizehint( x,y,w,h,0 );
+ }
  vo_x11_setlayer( vo_fs );
- if(vo_wm_type==vo_wm_Unknown && !(vo_fsmode&16))
-//     XUnmapWindow( mDisplay,vo_window );  // required for MWM
-    XWithdrawWindow(mDisplay,vo_window,mScreen);
- XMoveResizeWindow( mDisplay,vo_window,x,y,w,h );
+ if (! (net_wm_support & SUPPORT_FULLSCREEN))
+ {
+   if(vo_wm_type==vo_wm_Unknown && !(vo_fsmode&16))
+  //     XUnmapWindow( mDisplay,vo_window );  // required for MWM
+      XWithdrawWindow(mDisplay,vo_window,mScreen);
+   XMoveResizeWindow( mDisplay,vo_window,x,y,w,h );
+ }
 #ifdef HAVE_XINERAMA
  vo_x11_xinerama_move(mDisplay,vo_window);
 #endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20021230/f72e3f32/attachment.pgp>


More information about the MPlayer-dev-eng mailing list