The story so far
----------------

* When moving the mouse over a menu sometimes the submenus
  appear in the lowerleft corner.

* Also, sometimes the submenus do not dissappear when they should.
  Resulting in submenus that never dissappear and clutter the sceen.


Reasons that this happens
-------------------------

A - Because the window manager intercept mapping calls it can happen 
    that the Map, followed by Unmap ends up in the X server as
    Unmap folled by Map.

B - Due to logic in the NSMenu code in combination with the queuing
    in X it could happen that when opening a submenu the 
    "attachedMenu" ivar of the parent menu was not set.  
  
Both reasons could lead to not dissappearing menus.


Solutions
---------

A - Use the XWithdrawWindow call instead of XUnmap.  Any 
    window manager that intercepts the mapping call should
    also listen to the event generated by XWithdrawWindow 
    and do the right thing.  

B - Do not move the menu to (0,0) after closing the menu
    and change the guarding condition for setting the 
    attachedMenu in the parent menu.


Questions and remarks
---------------------

* I am not an experienced X programmer.  The XWithdrawWindow
  call is suggested by the Xlib programming books and in the
  thread mentioned in one of the mails of Michael Hanni.
  But if anyone can give a convincing reason not to use this
  call, please let me know.

* Besides, I am not sure what the reason was for moving the 
  menu location to (0,0) after closing.  Is there is some
  subtle or not so subtle reason for it?

* I have to say that although I can not reproduce this bug
  anymore when running with 

  - WindowMaker
  - sawfish
  - fvwm

  I could, after trying very hard, still reproduce it with
  
  - sawfish run in an Xnest session.

  This could be a Xnest problem. I have quite a few other
  problems with Xnest sessions so I wouldn't be surprised.


Testing
-------

Could someone who experiences these problems test out this 
patch and let me know the result?


Wim Oudshoorn


[ChangeLog excerpt from gui]--------------------------------------------

2003-03-13  Willem Rein Oudshoorn  <[EMAIL PROTECTED]>

        * Source/NSMenu.m ([-display:]): Make sure _attachedMenu is set, 
        due to a race condition it could have happened that it was 
        not set correctly.
        ([-close]): Do not move invisible windows to (0,0).



[ChangeLog excerpt from back]-------------------------------------------

2003-03-13  Willem Rein Oudshoorn  <[EMAIL PROTECTED]>

        * Source/x11/XGServerWindow.m ([-orderwindow:::]):  
        use XWithdrawWindown instead of XUnmap. (ICCCM advices this).
        

[Patch gui]-------------------------------------------------------------

Index: Source/NSMenu.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/gui/Source/NSMenu.m,v
retrieving revision 1.112
diff -u -r1.112 NSMenu.m
--- Source/NSMenu.m	8 Mar 2003 11:47:31 -0000	1.112
+++ Source/NSMenu.m	13 Mar 2003 16:20:14 -0000
@@ -1210,19 +1210,15 @@
   if (_changed)
     [self sizeToFit];
 
-  // get geometry only if not set
-  if ([_aWindow frame].origin.y <= 0)
+  if (_superMenu && ![self isTornOff])
+    {                 
+      // query super menu for position
+      [_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
+      _superMenu->_attachedMenu = self;
+    }
+  else if ([_aWindow frame].origin.y <= 0)   // get geometry only if not set
     {
-      if (_superMenu && ![self isTornOff])
-	{                 
-	  // query super menu for position
-	  [_aWindow setFrameOrigin: [_superMenu locationForSubmenu: self]];
-	  _superMenu->_attachedMenu = self;
-	}
-      else
-        {
-	  [self setGeometry];
-	}
+      [self setGeometry];
     }
   [_aWindow orderFrontRegardless];
 }
@@ -1329,7 +1325,6 @@
       _attachedMenu = sub;
     }
   [_aWindow orderOut: self];
-  [_aWindow setFrameOrigin: NSMakePoint (0, 0)];
 
   if (_superMenu && ![self isTornOff])
     {

[Patch back]------------------------------------------------------------

? back.make
? config.h
? config.log
? config.make
? config.status
? Source/art/shared_obj
? Source/gsc/shared_obj
? Source/x11/shared_obj
? Source/xlib/shared_obj
Index: Source/x11/XGServerWindow.m
===================================================================
RCS file: /cvsroot/gnustep/gnustep/core/back/Source/x11/XGServerWindow.m,v
retrieving revision 1.27
diff -u -r1.27 XGServerWindow.m
--- Source/x11/XGServerWindow.m	12 Feb 2003 00:11:22 -0000	1.27
+++ Source/x11/XGServerWindow.m	13 Mar 2003 16:21:20 -0000
@@ -909,7 +909,7 @@
   XClassHint		classhint;
   RContext              *context;
 
-  NSDebugLLog(@"XGTrace", @"DPSwindow: %@ %d", NSStringFromRect(frame), type);
+  NSDebugLLog(@"XGTrace", @"DPSwindow: %@ type %d style %d", NSStringFromRect(frame), type, style);
   root = [self _rootWindowForScreen: screen];
   context = [self xrContextForScreen: screen];
 
@@ -1582,7 +1582,7 @@
 	break;
 
       case NSWindowOut:
-	XUnmapWindow(dpy, window->ident);
+        XWithdrawWindow (dpy, window->ident, window->screen);
 	break;
     }
   /*
_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to