X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/8f924df7df019cce90537647de2627581043b5c4..fff62aa9aea4f6c2aadcef4cdc203cdf60ba224c:/oldXMenu/Activate.c
diff --git a/oldXMenu/Activate.c b/oldXMenu/Activate.c
index 8e1b3742d9..d4683da87f 100644
--- a/oldXMenu/Activate.c
+++ b/oldXMenu/Activate.c
@@ -1,8 +1,23 @@
-/* $Header: /cvs/emacs/oldXMenu/Activate.c,v 1.4 2002/04/22 18:27:03 jhd Exp $ */
/* Copyright Massachusetts Institute of Technology 1985 */
#include "copyright.h"
+/*
+Copyright (C) 2001-2012 Free Software Foundation, Inc.
+
+This program 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 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+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 this program. If not, see . */
+
/*
* XMenu: MIT Project Athena, X Window system menu package
*
@@ -63,7 +78,7 @@
*
* 3) The application has enabled asynchronous event
* queuing mode. In this mode all foreign events
- * will be queued up untill XMenuActivate
+ * will be queued up until XMenuActivate
* terminates; at which time they will be
* returned to the X event queue. As long as
* AEQ mode is enabled any asynchronous event
@@ -82,22 +97,32 @@
#include
#include "XMenuInt.h"
+#include
/* For debug, set this to 0 to not grab the keyboard on menu popup */
int x_menu_grab_keyboard = 1;
+static Wait_func wait_func;
+static void* wait_data;
+
+void
+XMenuActivateSetWaitFunction (Wait_func func, void *data)
+{
+ wait_func = func;
+ wait_data = data;
+}
+
int
-XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data,
- help_callback)
- register Display *display; /* Display to put menu on. */
- register XMenu *menu; /* Menu to activate. */
- int *p_num; /* Pane number selected. */
- int *s_num; /* Selection number selected. */
- int x_pos; /* X coordinate of menu position. */
- int y_pos; /* Y coordinate of menu position. */
- unsigned int event_mask; /* Mouse button event mask. */
- char **data; /* Pointer to return data value. */
- void (* help_callback) (); /* Help callback. */
+XMenuActivate(
+ register Display *display, /* Display to put menu on. */
+ register XMenu *menu, /* Menu to activate. */
+ int *p_num, /* Pane number selected. */
+ int *s_num, /* Selection number selected. */
+ int x_pos, /* X coordinate of menu position. */
+ int y_pos, /* Y coordinate of menu position. */
+ unsigned int event_mask, /* Mouse button event mask. */
+ char **data, /* Pointer to return data value. */
+ void (*help_callback) (char const *, int, int)) /* Help callback. */
{
int status; /* X routine call status. */
int orig_x; /* Upper left menu origin X coord. */
@@ -118,6 +143,7 @@ XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data,
Window root, child;
int root_x, root_y, win_x, win_y;
unsigned int mask;
+ KeySym keysym;
/*
* Define and allocate a foreign event queue to hold events
@@ -267,6 +293,7 @@ XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data,
* Begin event processing loop.
*/
while (1) {
+ if (wait_func) (*wait_func) (wait_data);
XNextEvent(display, &event); /* Get next event. */
switch (event.type) { /* Dispatch on the event type. */
case Expose:
@@ -444,6 +471,18 @@ XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data,
}
selection = True;
break;
+ case KeyPress:
+ case KeyRelease:
+ keysym = XLookupKeysym (&event.xkey, 0);
+
+ /* Pop down on C-g and Escape. */
+ if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0)
+ || keysym == XK_Escape) /* Any escape, ignore modifiers. */
+ {
+ ret_val = XM_NO_SELECT;
+ selection = True;
+ }
+ break;
default:
/*
* If AEQ mode is enabled then queue the event.
@@ -558,6 +597,8 @@ XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data,
free((char *)feq_tmp);
}
+ wait_func = 0;
+
/*
* Return successfully.
*/