]> code.delx.au - gnu-emacs/blobdiff - lwlib/lwlib-Xlw.c
Close bug#3992.
[gnu-emacs] / lwlib / lwlib-Xlw.c
index 18a65d99c279ba58651d892c7496b07f7ff1936e..115997d361237d870a6cd65c70c9947960509698 100644 (file)
@@ -1,21 +1,31 @@
 /* The lwlib interface to "xlwmenu" menus.
    Copyright (C) 1992 Lucid, Inc.
 /* The lwlib interface to "xlwmenu" menus.
    Copyright (C) 1992 Lucid, 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.
 
 
 This file is part of the Lucid Widget Library.
 
-The Lucid Widget Library is free software; you can redistribute it and/or 
+The Lucid Widget Library is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 1, or (at your option)
 any later version.
 
 The Lucid Widget Library is distributed in the hope that it will be useful,
 modify it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 1, or (at your option)
 any later version.
 
 The Lucid Widget Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of 
+but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 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
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 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, 675 Mass Ave, Cambridge, MA 02139, 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"
 #include <X11/StringDefs.h>
 
 #include "lwlib-Xlw.h"
 #include <X11/StringDefs.h>
@@ -25,7 +35,74 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <X11/Shell.h>
 #include "xlwmenu.h"
 
 #include <X11/Shell.h>
 #include "xlwmenu.h"
 
+#if 0
+
+#include <stdio.h>
+
+/* Print the complete X resource name of widget WIDGET to stderr.
+   This is sometimes handy to have available.  */
+
+void
+x_print_complete_resource_name (widget)
+     Widget widget;
+{
+  int i;
+  String names[100];
+
+  for (i = 0; i < 100 && widget != NULL; ++i)
+    {
+      names[i] = XtName (widget);
+      widget = XtParent (widget);
+    }
+
+  for (--i; i >= 1; --i)
+    fprintf (stderr, "%s.", names[i]);
+  fprintf (stderr, "%s\n", names[0]);
+}
+
+#endif /* 0 */
+
+
 \f/* Menu callbacks */
 \f/* Menu callbacks */
+
+/* Callback XtNhighlightCallback for Lucid menus.  W is the menu
+   widget, CLIENT_DATA contains a pointer to the widget_instance
+   for the menu, CALL_DATA contains a pointer to the widget_value
+   structure for the highlighted menu item.  The latter may be null
+   if there isn't any highlighted menu item.  */
+
+static void
+highlight_hook (w, client_data, call_data)
+     Widget w;
+     XtPointer client_data;
+     XtPointer call_data;
+{
+  widget_instance *instance = (widget_instance *) client_data;
+
+  if (instance->info->highlight_cb
+      && !w->core.being_destroyed)
+    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;
 static void
 pre_hook (w, client_data, call_data)
      Widget w;
@@ -95,6 +172,8 @@ xlw_create_menubar (instance)
 
   XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance);
   XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
 
   XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance);
   XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
+  XtAddCallback (widget, XtNleaveCallback, leave_hook, (XtPointer)instance);
+  XtAddCallback (widget, XtNenterCallback, enter_hook, (XtPointer)instance);
   return widget;
 }
 
   return widget;
 }
 
@@ -105,7 +184,7 @@ xlw_create_popup_menu (instance)
   Widget popup_shell
     = XtCreatePopupShell (instance->info->name, overrideShellWidgetClass,
                          instance->parent, NULL, 0);
   Widget popup_shell
     = XtCreatePopupShell (instance->info->name, overrideShellWidgetClass,
                          instance->parent, NULL, 0);
-  
+
   Widget widget;
   Arg al[2];
   int ac = 0;
   Widget widget;
   Arg al[2];
   int ac = 0;
@@ -120,11 +199,13 @@ xlw_create_popup_menu (instance)
                             popup_shell, al, ac);
 
   XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
                             popup_shell, al, ac);
 
   XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance);
+  XtAddCallback (widget, XtNleaveCallback, leave_hook, (XtPointer)instance);
+  XtAddCallback (widget, XtNenterCallback, enter_hook, (XtPointer)instance);
 
   return popup_shell;
 }
 
 
   return popup_shell;
 }
 
-widget_creation_entry 
+widget_creation_entry
 xlw_creation_table [] =
 {
   {"menubar", xlw_create_menubar},
 xlw_creation_table [] =
 {
   {"menubar", xlw_create_menubar},
@@ -147,20 +228,19 @@ lw_lucid_widget_p (widget)
 }
 
 void
 }
 
 void
+#ifdef PROTOTYPES
+xlw_update_one_widget (widget_instance* instance, Widget widget,
+                      widget_value* val, Boolean deep_p)
+#else
 xlw_update_one_widget (instance, widget, val, deep_p)
      widget_instance* instance;
      Widget widget;
      widget_value* val;
      Boolean deep_p;
 xlw_update_one_widget (instance, widget, val, deep_p)
      widget_instance* instance;
      Widget widget;
      widget_value* val;
      Boolean deep_p;
+#endif
 {
 {
-  XlwMenuWidget mw;
   Arg al[1];
 
   Arg al[1];
 
-  if (XtIsShell (widget))
-    mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];
-  else
-    mw = (XlwMenuWidget)widget;
-
   /* This used to use XtVaSetValues, but some old Xt versions
      that have a bug in XtVaCreateWidget might have it here too.  */
   XtSetArg (al[0], XtNmenu, instance->info->val);
   /* This used to use XtVaSetValues, but some old Xt versions
      that have a bug in XtVaCreateWidget might have it here too.  */
   XtSetArg (al[0], XtNmenu, instance->info->val);
@@ -178,9 +258,13 @@ xlw_update_one_value (instance, widget, val)
 }
 
 void
 }
 
 void
+#ifdef PROTOTYPES
+xlw_pop_instance (widget_instance* instance, Boolean up)
+#else
 xlw_pop_instance (instance, up)
      widget_instance* instance;
      Boolean up;
 xlw_pop_instance (instance, up)
      widget_instance* instance;
      Boolean up;
+#endif
 {
 }
 
 {
 }
 
@@ -189,7 +273,6 @@ xlw_popup_menu (widget, event)
      Widget widget;
      XEvent *event;
 {
      Widget widget;
      XEvent *event;
 {
-  XButtonPressedEvent dummy;
   XlwMenuWidget mw;
 
   if (!XtIsShell (widget))
   XlwMenuWidget mw;
 
   if (!XtIsShell (widget))
@@ -198,21 +281,24 @@ xlw_popup_menu (widget, event)
   mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];
 
   if (event)
   mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0];
 
   if (event)
-    pop_up_menu (mw, event);
+    XtCallActionProc ((Widget) mw, "start", event, NULL, 0);
   else
     {
   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);
     }
 }
 
     }
 }
 
@@ -225,3 +311,5 @@ xlw_destroy_instance (instance)
     XtDestroyWidget (instance->widget);
 }
 
     XtDestroyWidget (instance->widget);
 }
 
+/* arch-tag: 541e3912-477d-406e-9bf2-dbf2b7ff8c3b
+   (do not change this comment) */