changeset 5865:8dc616f310e8

(xmenu_show ) [USE_X_TOOLKIT]: Implement a Motif behavior for the menubar. Now, if you move the pointer on another menubar item while displaying the contents of a selected menubar item, the current pulldown menu is closed and the new one corresponding to the new pointed item is displayed. Clean up code. Handle the MotionNotify events in the XEvent loop.
author Fred Pierresteguy <F.Pierresteguy@frcl.bull.fr>
date Wed, 09 Feb 1994 13:51:25 +0000
parents 3e0d51feb34f
children 92d91d7479a2
files src/xmenu.c
diffstat 1 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/xmenu.c	Wed Feb 09 09:13:05 1994 +0000
+++ b/src/xmenu.c	Wed Feb 09 13:51:25 1994 +0000
@@ -859,9 +859,10 @@
      int menubarp;
      widget_value *vw;
 {
-  int menu_id, id = (int)f;
+  int menu_id, item_length;
   Lisp_Object selection;
   Widget menu;
+  XlwMenuWidget menuw = (XlwMenuWidget) f->display.x->menubar_widget;
 
   /*
    * Define and allocate a foreign event queue to hold events
@@ -915,6 +916,14 @@
     pop_up_menu (mw, &dummy);
   }
 
+  if (menubarp)
+    {
+      item_length = (x + string_width (menuw, vw->name) 
+		     + (2 * (menuw->menu.horizontal_spacing 
+			     + menuw->menu.shadow_thickness))
+		     - 4);
+    }
+
   /* Enters XEvent loop */
   while (1)
     {
@@ -929,6 +938,38 @@
       else
 	if (event.type == Expose)
 	  process_expose_from_menu (event);
+      else 
+	if (event.type == MotionNotify 
+	        && menubarp
+	        && ((event.xmotion.y_root 
+		      >= (f->display.x->widget->core.y 
+			       + f->display.x->widget->core.border_width))
+		    && (event.xmotion.y_root
+			< (f->display.x->widget->core.y
+			   + f->display.x->widget->core.border_width
+			   + f->display.x->menubar_widget->core.height)))
+	    && (event.xmotion.x_root >= item_length
+		|| event.xmotion.x_root < (x - 4)))
+	  {
+	    BLOCK_INPUT;
+	    XtUngrabPointer ((Widget)
+			     ((XlwMenuWidget)
+			      ((CompositeWidget)menu)->composite.children[0]),
+			     event.xbutton.time);
+	    lw_destroy_all_widgets (menu_id); 
+	    UNBLOCK_INPUT;
+
+	    event.type = ButtonPress;
+	        event.xbutton.time = CurrentTime;
+	        event.xbutton.button = Button1;
+	    event.xbutton.window = XtWindow (f->display.x->menubar_widget);
+	    event.xbutton.x = (event.xbutton.x_root 
+			       - (f->display.x->widget->core.x
+				  + f->display.x->widget->core.border_width));
+	    XPutBackEvent (XDISPLAY &event);
+	    break;
+	  }
+
       XtDispatchEvent (&event);
       feq_tmp = (XMEventQue *) malloc (sizeof (XMEventQue));