[MPlayer-dev-eng] WM detection

Nilmoni Deb ndeb at ece.cmu.edu
Fri May 10 07:49:40 CEST 2002


Hi,
	This is a follow up of my post in

http://www.mplayerhq.hu/pipermail/mplayer-users/2002-May/014912.html

1. In libvo/x11_common.c, the function vo_wm_detect fails to detect KDE.
In my case, it gives this message:

[x11] Detected wm is NetWM.
==========================================================================
Opening Video Decoder: [mpegpes] MPEG 1/2 Video passthrough

Basically, the execution does not even check for KDE, ICEWM and
WindowMaker. In other words vo_wm_detect() simply fails in this case.

A little search revealed this link

http://developer.kde.org/documentation/library/3.0-api/classref/kdecore/netwm_h.html

which claims that the NET Window Manager Specification is followed by KDE
too. It appears that NetWM is a broad class of wm's.
According to http://dot.kde.org/989854861/989936230/989939090/
KDE, GNOME, KWin and Sawfish belong to this class.


As a minor addition, the 3 break statements between lines 213 and 219 
escape the execution of XFree( name ) at line 221. Thats a memory leak.

2. In libvo/x11_common.c, in the function vo_x11_check_events, the case
statement for PropertyNotify, depending on the sequence of X events,
sometimes fails to find a string with '_KDE_'.

This code repeats what vo_wm_detect() does. So it does not need to be
there if vo_wm_detect() detects the WM once correctly. Worse, it may
undo the good work of vo_wm_detect() by wrong detection (from my
experience).


3. In libvo/x11_common.c, in the function vo_x11_check_events, the value
of ret depends on the sequence of events. Sometimes this code fails to 
find any event. When the first value returned by vo_x11_check_events
is 0, the video window becomes borderless (my guess). This happens about
once in 6-7 runs of mplayer.

I am supplying a patch to address issues 1 and 2 only.

--- libvo/x11_common.c     Fri May 10 00:06:46 2002
+++ libvo/x11_common.c.new  Fri May 10 01:44:58 2002
@@ -190,9 +190,9 @@
  type=XInternAtom( mDisplay,"_NET_SUPPORTED",False );
  if ( Success == XGetWindowProperty( mDisplay,mRootWin,type,0,65536 /
sizeof( long
),False,AnyPropertyType,&type,&format,&nitems,&bytesafter,&args ) &&
nitems > 0 )
   {
-   mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is NetWM.\n" );
+   mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is of class NetWM.\n"
);
    XFree( args );
-   return vo_wm_NetWM;
+   //return vo_wm_NetWM;
   }
 #endif
 // --- other wm
@@ -203,7 +203,8 @@
  XMoveWindow( mDisplay,win,vo_screenwidth,vo_screenheight );
  do 
   { 
-   XCheckWindowEvent( mDisplay,win,PropertyChangeMask |
StructureNotifyMask,&xev );
+   //XCheckWindowEvent( mDisplay,win,PropertyChangeMask |
StructureNotifyMask,&xev );
+   XNextEvent( mDisplay,&xev );
 
    if ( xev.type == PropertyNotify )
     {
@@ -211,14 +212,12 @@
      if ( !name ) break;
 
      if ( !strncmp( name,"_ICEWM_TRAY",11 ) )
-      { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is IceWM.\n" );
wm=vo_wm_IceWM; break; }
+      { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is IceWM.\n" );
wm=vo_wm_IceWM; XFree( name ); break; }
      if ( !strncmp( name,"_KDE_",5 ) )
-      { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is KDE.\n" );
wm=vo_wm_KDE; break; }
+      { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is KDE.\n" );
wm=vo_wm_KDE; XFree( name ); break; }
      if ( !strncmp( name,"KWM_WIN_DESKTOP",15 ) )
-      { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is WindowMaker
style.\n" ); wm=vo_wm_WMakerStyle; break; }
-//     fprintf(stderr,"[ws] PropertyNotify ( 0x%x ) %s ( 0x%x
)\n",win,name,xev.xproperty.atom );
+      { mp_dbg( MSGT_VO,MSGL_STATUS,"[x11] Detected wm is WindowMaker
style.\n" ); wm=vo_wm_WMakerStyle; XFree( name ); break; }
 
-     XFree( name );
     }
  } while( c++ < 25 );
  XDestroyWindow( mDisplay,win );
@@ -615,7 +614,7 @@
            mplayer_put_key(MOUSE_BTN0+Event.xbutton.button-1);
            break;
 #endif
-#if 1
+#if 0
       case PropertyNotify: 
           {
            char * name = XGetAtomName( mydisplay,Event.xproperty.atom );





thanks
- Nil




More information about the MPlayer-dev-eng mailing list