* nsterm.h: Fix last change.
[bpt/emacs.git] / lwlib / lwlib-Xlw.c
index 4793914..115997d 100644 (file)
@@ -1,6 +1,7 @@
 /* The lwlib interface to "xlwmenu" menus.
    Copyright (C) 1992 Lucid, Inc.
-   Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1994, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
+     2008, 2009, 2010 Free Software Foundation, Inc.
 
 This file is part of the Lucid Widget Library.
 
@@ -16,13 +17,14 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
+#include <setjmp.h>
 #include "lisp.h"
 
 #include "lwlib-Xlw.h"
@@ -82,6 +84,25 @@ highlight_hook (w, client_data, call_data)
     instance->info->highlight_cb (w, instance->info->id, call_data);
 }
 
+static void
+enter_hook (w, client_data, call_data)
+     Widget w;
+     XtPointer client_data;
+     XtPointer call_data;
+{
+  highlight_hook (w, client_data, call_data);
+}
+
+static void
+leave_hook (w, client_data, call_data)
+     Widget w;
+     XtPointer client_data;
+     XtPointer call_data;
+{
+  highlight_hook (w, client_data, NULL);
+}
+
+
 static void
 pre_hook (w, client_data, call_data)
      Widget w;
@@ -151,8 +172,8 @@ xlw_create_menubar (instance)
 
   XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance);
   XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
-  XtAddCallback (widget, XtNhighlightCallback, highlight_hook,
-                (XtPointer)instance);
+  XtAddCallback (widget, XtNleaveCallback, leave_hook, (XtPointer)instance);
+  XtAddCallback (widget, XtNenterCallback, enter_hook, (XtPointer)instance);
   return widget;
 }
 
@@ -178,8 +199,9 @@ xlw_create_popup_menu (instance)
                             popup_shell, al, ac);
 
   XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
-  XtAddCallback (widget, XtNhighlightCallback, highlight_hook,
-                (XtPointer)instance);
+  XtAddCallback (widget, XtNleaveCallback, leave_hook, (XtPointer)instance);
+  XtAddCallback (widget, XtNenterCallback, enter_hook, (XtPointer)instance);
+
   return popup_shell;
 }
 
@@ -251,7 +273,6 @@ xlw_popup_menu (widget, event)
      Widget widget;
      XEvent *event;
 {
-  XButtonPressedEvent dummy;
   XlwMenuWidget mw;
 
   if (!XtIsShell (widget))
@@ -260,21 +281,24 @@ xlw_popup_menu (widget, event)
   mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];
 
   if (event)
-    pop_up_menu (mw, (XButtonPressedEvent*) event);
+    XtCallActionProc ((Widget) mw, "start", event, NULL, 0);
   else
     {
-      dummy.type = ButtonPress;
-      dummy.serial = 0;
-      dummy.send_event = 0;
-      dummy.display = XtDisplay (widget);
-      dummy.window = XtWindow (XtParent (widget));
-      dummy.time = CurrentTime;
-      dummy.button = 0;
-      XQueryPointer (dummy.display, dummy.window, &dummy.root,
-                    &dummy.subwindow, &dummy.x_root, &dummy.y_root,
-                    &dummy.x, &dummy.y, &dummy.state);
-
-      pop_up_menu (mw, &dummy);
+      XEvent dummy;
+      XButtonPressedEvent *bd = &dummy.xbutton;
+
+      bd->type = ButtonPress;
+      bd->serial = 0;
+      bd->send_event = 0;
+      bd->display = XtDisplay (widget);
+      bd->window = XtWindow (XtParent (widget));
+      bd->time = CurrentTime;
+      bd->button = 0;
+      XQueryPointer (bd->display, bd->window, &bd->root,
+                    &bd->subwindow, &bd->x_root, &bd->y_root,
+                    &bd->x, &bd->y, &bd->state);
+
+      XtCallActionProc ((Widget) mw, "start", &dummy, NULL, 0);
     }
 }
 
@@ -287,3 +311,5 @@ xlw_destroy_instance (instance)
     XtDestroyWidget (instance->widget);
 }
 
+/* arch-tag: 541e3912-477d-406e-9bf2-dbf2b7ff8c3b
+   (do not change this comment) */