[Mplayer-cvslog] CVS: main/Gui/wm ws.c,1.37,1.38

Zoltan Ponekker pontscho at mplayerhq.hu
Tue May 7 15:31:31 CEST 2002


Update of /cvsroot/mplayer/main/Gui/wm
In directory mail:/var/tmp.root/cvs-serv27592/Gui/wm

Modified Files:
	ws.c 
Log Message:
wm detection -- round two

Index: ws.c
===================================================================
RCS file: /cvsroot/mplayer/main/Gui/wm/ws.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- ws.c	6 May 2002 15:05:06 -0000	1.37
+++ ws.c	7 May 2002 13:31:13 -0000	1.38
@@ -150,45 +150,58 @@
  unsigned long   nitems, bytesafter;
  unsigned char * args = NULL;
 
- mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is " );
-// --- icewm
-// type=XInternAtom( wsDisplay,"_ICEWM_TRAY",False ); 
-// if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
-//  {
-//   mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"IceWM\n" );
-//   XFree( args );
-//   return wsWMIceWM;
-//  }
+ Window		 win;
+ XEvent          xev;
+ int		 c = 0;
+ int             wm = wsWMUnknown;
 
 // --- gnome
-// type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False );
-// if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
-//  {
-//   mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"Gnome\n" );
-//   XFree( args );
-//   return wsWMGnome;
-//  }
- 
-// --- kde
-// type=XInternAtom( wsDisplay,"_KDE_NET_WM_FRAME_STRUT",False );
-//// type=XInternAtom( wsDisplay,"_KDE_NET_USER_TIME",False );
-// if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
-//  {
-//   mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"KDE\n" );
-//   XFree( args );
-//   return wsWMKDE;
-//  }
+ type=XInternAtom( wsDisplay,"_WIN_SUPPORTING_WM_CHECK",False );
+ if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
+  {
+   mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is Gnome\n" );
+   XFree( args );
+   return wsWMGnome;
+  }
 
 // --- net wm
  type=XInternAtom( wsDisplay,"_NET_SUPPORTED",False );
  if ( Success == XGetWindowProperty( wsDisplay,wsRootWin,type,0,65536 / sizeof( long ),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) && nitems > 0 )
   {
-   mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"NetWM\n" );
+   mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"[ws] Detected wm is NetWM\n" );
    XFree( args );
    return wsWMNetWM;
   }
- 
- mp_dbg( MSGT_GPLAYER,MSGL_STATUS,"Unknow\n" );
+
+// --- other wm
+ mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Create window for WM detect ...\n" );
+ win=XCreateSimpleWindow( wsDisplay,wsRootWin,wsMaxX,wsMaxY,1,1,0,0,0 );
+ XSelectInput( wsDisplay,win,PropertyChangeMask | StructureNotifyMask );
+ XMapWindow( wsDisplay,win );
+ XMoveWindow( wsDisplay,win,wsMaxX,wsMaxY );
+ do 
+  { 
+   XCheckWindowEvent( wsDisplay,win,PropertyChangeMask | StructureNotifyMask,&xev );
+
+   if ( xev.type == PropertyNotify )
+    {
+     char * name = XGetAtomName( wsDisplay,xev.xproperty.atom );
+     if ( !name ) break;
+
+     if ( !strncmp( name,"_ICEWM_TRAY",11 ) )
+      { mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is IceWM.\n" ); wm=wsWMIceWM; break; }
+     if ( !strncmp( name,"_KDE_",5 ) )
+      { mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is KDE.\n" ); wm=wsWMKDE; break; }
+     if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) )
+      { mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Detected wm is WindowMaker style.\n" ); wm=wsWMWMaker; break; }
+//     fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x )\n",win,name,xev.xproperty.atom );
+     XFree( name );
+    }
+ } while( c++ < 25 );
+ XDestroyWindow( wsDisplay,win );
+#ifdef MP_DEBUG
+ if ( wm == wsWMUnknown ) mp_dbg( MSGT_VO,MSGL_STATUS,"[ws] Unknown wm type...\n" );
+#endif
  return wsWMUnknown;
 }
 




More information about the MPlayer-cvslog mailing list