annotate oldXMenu/Activate.c @ 84281:1a1bf5f79f55

Move here from ../../man
author Glenn Morris <rgm@gnu.org>
date Thu, 06 Sep 2007 04:58:10 +0000
parents 95361d2f1ff8
children 43c5da03890c f55f9811f5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
1 /* Copyright Massachusetts Institute of Technology 1985 */
Dave Love <fx@gnu.org>
parents:
diff changeset
2
Dave Love <fx@gnu.org>
parents:
diff changeset
3 #include "copyright.h"
Dave Love <fx@gnu.org>
parents:
diff changeset
4
Dave Love <fx@gnu.org>
parents:
diff changeset
5 /*
76169
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
6 Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
7 Free Software Foundation, Inc.
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
8
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
9 This program is free software; you can redistribute it and/or modify
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
10 it under the terms of the GNU General Public License as published by
78306
95361d2f1ff8 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 76169
diff changeset
11 the Free Software Foundation; either version 3, or (at your option)
76169
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
12 any later version.
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
13
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
14 This program is distributed in the hope that it will be useful,
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
17 GNU General Public License for more details.
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
18
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
19 You should have received a copy of the GNU General Public License
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
20 along with this program; see the file COPYING. If not, write to the
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
21 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
22 Boston, MA 02110-1301, USA. */
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
23
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
24
73c4462d95fc Add GPL for FSF copyright.
Glenn Morris <rgm@gnu.org>
parents: 75348
diff changeset
25 /*
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
26 * XMenu: MIT Project Athena, X Window system menu package
Dave Love <fx@gnu.org>
parents:
diff changeset
27 *
Dave Love <fx@gnu.org>
parents:
diff changeset
28 * XMenuActivate - Maps a given menu to the display and activates
Dave Love <fx@gnu.org>
parents:
diff changeset
29 * the menu for user selection. The user is allowed to
Dave Love <fx@gnu.org>
parents:
diff changeset
30 * specify which pane and selection will be current,
Dave Love <fx@gnu.org>
parents:
diff changeset
31 * the X and Y location of the menu (relative to the
Dave Love <fx@gnu.org>
parents:
diff changeset
32 * parent window) and the mouse button event mask that
Dave Love <fx@gnu.org>
parents:
diff changeset
33 * will be used to identify a selection request.
Dave Love <fx@gnu.org>
parents:
diff changeset
34 *
Dave Love <fx@gnu.org>
parents:
diff changeset
35 * A menu selection is shown to be current by placing
Dave Love <fx@gnu.org>
parents:
diff changeset
36 * a highlight box around the selection as the mouse
Dave Love <fx@gnu.org>
parents:
diff changeset
37 * cursor enters its active region. Inactive selections
Dave Love <fx@gnu.org>
parents:
diff changeset
38 * will not be highlighted. As the mouse cursor moved
Dave Love <fx@gnu.org>
parents:
diff changeset
39 * from one menu pane to another menu pane the pane being
Dave Love <fx@gnu.org>
parents:
diff changeset
40 * entered is raised and made current and the pane being
Dave Love <fx@gnu.org>
parents:
diff changeset
41 * left is lowered.
Dave Love <fx@gnu.org>
parents:
diff changeset
42 *
Dave Love <fx@gnu.org>
parents:
diff changeset
43 * Anytime XMenuActivate returns, the p_num and
Dave Love <fx@gnu.org>
parents:
diff changeset
44 * s_num are left at their last known values (i.e.,
Dave Love <fx@gnu.org>
parents:
diff changeset
45 * the last known current pane and selection indices).
Dave Love <fx@gnu.org>
parents:
diff changeset
46 * The following are the defined return states:
Dave Love <fx@gnu.org>
parents:
diff changeset
47 *
Dave Love <fx@gnu.org>
parents:
diff changeset
48 * 1) If at any time an error occurs the data
Dave Love <fx@gnu.org>
parents:
diff changeset
49 * pointer is left untouched and XM_FAILURE
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
50 * is returned.
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
51 *
Dave Love <fx@gnu.org>
parents:
diff changeset
52 * 2) When a selection request is received (i.e.,
Dave Love <fx@gnu.org>
parents:
diff changeset
53 * when the specified mouse event occurs) the
Dave Love <fx@gnu.org>
parents:
diff changeset
54 * data pointer will be set to the data
Dave Love <fx@gnu.org>
parents:
diff changeset
55 * associated with the particular selection
Dave Love <fx@gnu.org>
parents:
diff changeset
56 * current at the time of the selection request
Dave Love <fx@gnu.org>
parents:
diff changeset
57 * and XM_SUCCESS is returned.
Dave Love <fx@gnu.org>
parents:
diff changeset
58 *
Dave Love <fx@gnu.org>
parents:
diff changeset
59 * 3) If no selection was current at the time a
Dave Love <fx@gnu.org>
parents:
diff changeset
60 * selection request is made the data pointer
Dave Love <fx@gnu.org>
parents:
diff changeset
61 * will be left untouched and XM_NO_SELECT will
Dave Love <fx@gnu.org>
parents:
diff changeset
62 * be returned.
Dave Love <fx@gnu.org>
parents:
diff changeset
63 *
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
64 * 4) If the selection that was current at the time
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
65 * a selection request is made is not an active
Dave Love <fx@gnu.org>
parents:
diff changeset
66 * selection the data pointer will be left
Dave Love <fx@gnu.org>
parents:
diff changeset
67 * untouched and XM_IA_SELECT will be returned.
Dave Love <fx@gnu.org>
parents:
diff changeset
68 *
Dave Love <fx@gnu.org>
parents:
diff changeset
69 * Since X processes events in an asynchronous manner
Dave Love <fx@gnu.org>
parents:
diff changeset
70 * it is likely that XMenuActivate will encounter
Dave Love <fx@gnu.org>
parents:
diff changeset
71 * a "foreign event" while it is executing. Foreign
Dave Love <fx@gnu.org>
parents:
diff changeset
72 * events are handled in one of three ways:
Dave Love <fx@gnu.org>
parents:
diff changeset
73 *
Dave Love <fx@gnu.org>
parents:
diff changeset
74 * 1) The event is discarded. This is the default
Dave Love <fx@gnu.org>
parents:
diff changeset
75 * mode and requires no action on the part of the
Dave Love <fx@gnu.org>
parents:
diff changeset
76 * application.
Dave Love <fx@gnu.org>
parents:
diff changeset
77 *
Dave Love <fx@gnu.org>
parents:
diff changeset
78 * 2) The application has identified an asynchronous
Dave Love <fx@gnu.org>
parents:
diff changeset
79 * event handler that will be called and the
Dave Love <fx@gnu.org>
parents:
diff changeset
80 * foreign event handed off to it. Note:
Dave Love <fx@gnu.org>
parents:
diff changeset
81 * AEQ mode disables this mode temporarily.
Dave Love <fx@gnu.org>
parents:
diff changeset
82 *
Dave Love <fx@gnu.org>
parents:
diff changeset
83 * 3) The application has enabled asynchronous event
Dave Love <fx@gnu.org>
parents:
diff changeset
84 * queuing mode. In this mode all foreign events
Dave Love <fx@gnu.org>
parents:
diff changeset
85 * will be queued up untill XMenuActivate
Dave Love <fx@gnu.org>
parents:
diff changeset
86 * terminates; at which time they will be
Dave Love <fx@gnu.org>
parents:
diff changeset
87 * returned to the X event queue. As long as
Dave Love <fx@gnu.org>
parents:
diff changeset
88 * AEQ mode is enabled any asynchronous event
Dave Love <fx@gnu.org>
parents:
diff changeset
89 * handler as temporarily disabled.
Dave Love <fx@gnu.org>
parents:
diff changeset
90 *
Dave Love <fx@gnu.org>
parents:
diff changeset
91 * Any events encountered while taking down the menu
Dave Love <fx@gnu.org>
parents:
diff changeset
92 * (i.e., exposure events from occluded windows) will
Dave Love <fx@gnu.org>
parents:
diff changeset
93 * automatically be returned to the X event queue after
Dave Love <fx@gnu.org>
parents:
diff changeset
94 * XMenuActivate has cleaned the queue of any of its own
Dave Love <fx@gnu.org>
parents:
diff changeset
95 * events that are no longer needed.
Dave Love <fx@gnu.org>
parents:
diff changeset
96 *
Dave Love <fx@gnu.org>
parents:
diff changeset
97 * Author: Tony Della Fera, DEC
Dave Love <fx@gnu.org>
parents:
diff changeset
98 * March 12, 1986
Dave Love <fx@gnu.org>
parents:
diff changeset
99 *
Dave Love <fx@gnu.org>
parents:
diff changeset
100 */
Dave Love <fx@gnu.org>
parents:
diff changeset
101
Dave Love <fx@gnu.org>
parents:
diff changeset
102 #include <config.h>
Dave Love <fx@gnu.org>
parents:
diff changeset
103 #include "XMenuInt.h"
59101
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
104 #include <X11/keysym.h>
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
105
44752
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
106 /* For debug, set this to 0 to not grab the keyboard on menu popup */
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
107 int x_menu_grab_keyboard = 1;
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
108
58167
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
109 typedef void (*Wait_func)();
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
110
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
111 static Wait_func wait_func;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
112 static void* wait_data;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
113
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
114 void
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
115 XMenuActivateSetWaitFunction (func, data)
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
116 Wait_func func;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
117 void *data;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
118 {
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
119 wait_func = func;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
120 wait_data = data;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
121 }
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
122
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
123 int
27457
bbfd0e676041 (XMenuActivate): Add parameter HELP_CALLBACK.
Gerd Moellmann <gerd@gnu.org>
parents: 25858
diff changeset
124 XMenuActivate(display, menu, p_num, s_num, x_pos, y_pos, event_mask, data,
bbfd0e676041 (XMenuActivate): Add parameter HELP_CALLBACK.
Gerd Moellmann <gerd@gnu.org>
parents: 25858
diff changeset
125 help_callback)
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
126 register Display *display; /* Display to put menu on. */
Dave Love <fx@gnu.org>
parents:
diff changeset
127 register XMenu *menu; /* Menu to activate. */
Dave Love <fx@gnu.org>
parents:
diff changeset
128 int *p_num; /* Pane number selected. */
Dave Love <fx@gnu.org>
parents:
diff changeset
129 int *s_num; /* Selection number selected. */
Dave Love <fx@gnu.org>
parents:
diff changeset
130 int x_pos; /* X coordinate of menu position. */
Dave Love <fx@gnu.org>
parents:
diff changeset
131 int y_pos; /* Y coordinate of menu position. */
Dave Love <fx@gnu.org>
parents:
diff changeset
132 unsigned int event_mask; /* Mouse button event mask. */
Dave Love <fx@gnu.org>
parents:
diff changeset
133 char **data; /* Pointer to return data value. */
27457
bbfd0e676041 (XMenuActivate): Add parameter HELP_CALLBACK.
Gerd Moellmann <gerd@gnu.org>
parents: 25858
diff changeset
134 void (* help_callback) (); /* Help callback. */
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
135 {
Dave Love <fx@gnu.org>
parents:
diff changeset
136 int status; /* X routine call status. */
Dave Love <fx@gnu.org>
parents:
diff changeset
137 int orig_x; /* Upper left menu origin X coord. */
Dave Love <fx@gnu.org>
parents:
diff changeset
138 int orig_y; /* Upper left menu origin Y coord. */
Dave Love <fx@gnu.org>
parents:
diff changeset
139 int ret_val; /* Return value. */
Dave Love <fx@gnu.org>
parents:
diff changeset
140
Dave Love <fx@gnu.org>
parents:
diff changeset
141 register XMPane *p_ptr; /* Current XMPane. */
Dave Love <fx@gnu.org>
parents:
diff changeset
142 register XMPane *event_xmp; /* Event XMPane pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
143 register XMPane *cur_p; /* Current pane. */
Dave Love <fx@gnu.org>
parents:
diff changeset
144 register XMSelect *cur_s; /* Current selection. */
Dave Love <fx@gnu.org>
parents:
diff changeset
145 XMWindow *event_xmw; /* Event XMWindow pointer. */
Dave Love <fx@gnu.org>
parents:
diff changeset
146 XEvent event; /* X input event. */
Dave Love <fx@gnu.org>
parents:
diff changeset
147 XEvent peek_event; /* X input peek ahead event. */
Dave Love <fx@gnu.org>
parents:
diff changeset
148
Dave Love <fx@gnu.org>
parents:
diff changeset
149 Bool selection = False; /* Selection has been made. */
Dave Love <fx@gnu.org>
parents:
diff changeset
150 Bool forward = True; /* Moving forward in the pane list. */
Dave Love <fx@gnu.org>
parents:
diff changeset
151
Dave Love <fx@gnu.org>
parents:
diff changeset
152 Window root, child;
Dave Love <fx@gnu.org>
parents:
diff changeset
153 int root_x, root_y, win_x, win_y;
Dave Love <fx@gnu.org>
parents:
diff changeset
154 unsigned int mask;
59101
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
155 KeySym keysym;
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
156
Dave Love <fx@gnu.org>
parents:
diff changeset
157 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
158 * Define and allocate a foreign event queue to hold events
Dave Love <fx@gnu.org>
parents:
diff changeset
159 * that don't belong to XMenu. These events are later restored
Dave Love <fx@gnu.org>
parents:
diff changeset
160 * to the X event queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
161 */
Dave Love <fx@gnu.org>
parents:
diff changeset
162 typedef struct _xmeventque {
Dave Love <fx@gnu.org>
parents:
diff changeset
163 XEvent event;
Dave Love <fx@gnu.org>
parents:
diff changeset
164 struct _xmeventque *next;
Dave Love <fx@gnu.org>
parents:
diff changeset
165 } XMEventQue;
Dave Love <fx@gnu.org>
parents:
diff changeset
166
Dave Love <fx@gnu.org>
parents:
diff changeset
167 XMEventQue *feq = NULL; /* Foreign event queue. */
Dave Love <fx@gnu.org>
parents:
diff changeset
168 XMEventQue *feq_tmp; /* Foreign event queue temporary. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
169
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
170 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
171 * If there are no panes in the menu then return failure
Dave Love <fx@gnu.org>
parents:
diff changeset
172 * because the menu is not initialized.
Dave Love <fx@gnu.org>
parents:
diff changeset
173 */
Dave Love <fx@gnu.org>
parents:
diff changeset
174 if (menu->p_count == 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
175 _XMErrorCode = XME_NOT_INIT;
Dave Love <fx@gnu.org>
parents:
diff changeset
176 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
177 }
Dave Love <fx@gnu.org>
parents:
diff changeset
178
Dave Love <fx@gnu.org>
parents:
diff changeset
179 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
180 * Find the desired current pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
181 */
Dave Love <fx@gnu.org>
parents:
diff changeset
182 cur_p = _XMGetPanePtr(menu, *p_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
183 if (cur_p == NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
184 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
185 }
Dave Love <fx@gnu.org>
parents:
diff changeset
186 cur_p->activated = cur_p->active;
Dave Love <fx@gnu.org>
parents:
diff changeset
187
Dave Love <fx@gnu.org>
parents:
diff changeset
188 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
189 * Find the desired current selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
190 * If the current selection index is out of range a null current selection
Dave Love <fx@gnu.org>
parents:
diff changeset
191 * will be assumed and the cursor will be placed in the current pane
Dave Love <fx@gnu.org>
parents:
diff changeset
192 * header.
Dave Love <fx@gnu.org>
parents:
diff changeset
193 */
Dave Love <fx@gnu.org>
parents:
diff changeset
194 cur_s = _XMGetSelectionPtr(cur_p, *s_num);
Dave Love <fx@gnu.org>
parents:
diff changeset
195
Dave Love <fx@gnu.org>
parents:
diff changeset
196 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
197 * Compute origin of menu so that cursor is in
Dave Love <fx@gnu.org>
parents:
diff changeset
198 * Correct pane and selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
199 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
200 _XMTransToOrigin(display,
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
201 menu,
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
202 cur_p, cur_s,
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
203 x_pos, y_pos,
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
204 &orig_x, &orig_y);
Dave Love <fx@gnu.org>
parents:
diff changeset
205 menu->x_pos = orig_x; /* Store X and Y coords of menu. */
Dave Love <fx@gnu.org>
parents:
diff changeset
206 menu->y_pos = orig_y;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
207
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
208 if (XMenuRecompute(display, menu) == XM_FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
209 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
210 }
Dave Love <fx@gnu.org>
parents:
diff changeset
211
Dave Love <fx@gnu.org>
parents:
diff changeset
212 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
213 * Flush the window creation queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
214 * This batches all window creates since lazy evaluation
Dave Love <fx@gnu.org>
parents:
diff changeset
215 * is more efficient than individual evaluation.
Dave Love <fx@gnu.org>
parents:
diff changeset
216 * This routine also does an XFlush().
Dave Love <fx@gnu.org>
parents:
diff changeset
217 */
Dave Love <fx@gnu.org>
parents:
diff changeset
218 if (_XMWinQueFlush(display, menu, cur_p, cur_s) == _FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
219 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
220 }
Dave Love <fx@gnu.org>
parents:
diff changeset
221
Dave Love <fx@gnu.org>
parents:
diff changeset
222 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
223 * Make sure windows are in correct order (in case we were passed
Dave Love <fx@gnu.org>
parents:
diff changeset
224 * an already created menu in incorrect order.)
Dave Love <fx@gnu.org>
parents:
diff changeset
225 */
Dave Love <fx@gnu.org>
parents:
diff changeset
226 for(p_ptr = menu->p_list->next; p_ptr != cur_p; p_ptr = p_ptr->next)
Dave Love <fx@gnu.org>
parents:
diff changeset
227 XRaiseWindow(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
228 for(p_ptr = menu->p_list->prev; p_ptr != cur_p->prev; p_ptr = p_ptr->prev)
Dave Love <fx@gnu.org>
parents:
diff changeset
229 XRaiseWindow(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
230
Dave Love <fx@gnu.org>
parents:
diff changeset
231 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
232 * Make sure all selection windows are mapped.
Dave Love <fx@gnu.org>
parents:
diff changeset
233 */
Dave Love <fx@gnu.org>
parents:
diff changeset
234 for (
Dave Love <fx@gnu.org>
parents:
diff changeset
235 p_ptr = menu->p_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
236 p_ptr != menu->p_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
237 p_ptr = p_ptr->next
Dave Love <fx@gnu.org>
parents:
diff changeset
238 ){
Dave Love <fx@gnu.org>
parents:
diff changeset
239 XMapSubwindows(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
240 }
Dave Love <fx@gnu.org>
parents:
diff changeset
241
Dave Love <fx@gnu.org>
parents:
diff changeset
242 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
243 * Synchronize the X buffers and the event queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
244 * From here on, all events in the queue that don't belong to
Dave Love <fx@gnu.org>
parents:
diff changeset
245 * XMenu are sent back to the application via an application
Dave Love <fx@gnu.org>
parents:
diff changeset
246 * provided event handler or discarded if the application has
Dave Love <fx@gnu.org>
parents:
diff changeset
247 * not provided an event handler.
Dave Love <fx@gnu.org>
parents:
diff changeset
248 */
Dave Love <fx@gnu.org>
parents:
diff changeset
249 XSync(display, 0);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
250
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
251 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
252 * Grab the mouse for menu input.
Dave Love <fx@gnu.org>
parents:
diff changeset
253 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
254
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
255 status = XGrabPointer(
Dave Love <fx@gnu.org>
parents:
diff changeset
256 display,
Dave Love <fx@gnu.org>
parents:
diff changeset
257 menu->parent,
Dave Love <fx@gnu.org>
parents:
diff changeset
258 True,
Dave Love <fx@gnu.org>
parents:
diff changeset
259 event_mask,
Dave Love <fx@gnu.org>
parents:
diff changeset
260 GrabModeAsync,
Dave Love <fx@gnu.org>
parents:
diff changeset
261 GrabModeAsync,
Dave Love <fx@gnu.org>
parents:
diff changeset
262 None,
Dave Love <fx@gnu.org>
parents:
diff changeset
263 menu->mouse_cursor,
Dave Love <fx@gnu.org>
parents:
diff changeset
264 CurrentTime
Dave Love <fx@gnu.org>
parents:
diff changeset
265 );
44752
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
266 if (status == Success && x_menu_grab_keyboard)
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
267 {
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
268 status = XGrabKeyboard (display,
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
269 menu->parent,
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
270 False,
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
271 GrabModeAsync,
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
272 GrabModeAsync,
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
273 CurrentTime);
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
274 if (status != Success)
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
275 XUngrabPointer(display, CurrentTime);
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
276 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
277
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
278 if (status == _X_FAILURE) {
Dave Love <fx@gnu.org>
parents:
diff changeset
279 _XMErrorCode = XME_GRAB_MOUSE;
Dave Love <fx@gnu.org>
parents:
diff changeset
280 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
281 }
Dave Love <fx@gnu.org>
parents:
diff changeset
282
Dave Love <fx@gnu.org>
parents:
diff changeset
283 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
284 * Map the menu panes.
Dave Love <fx@gnu.org>
parents:
diff changeset
285 */
Dave Love <fx@gnu.org>
parents:
diff changeset
286 XMapWindow(display, cur_p->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
287 for (p_ptr = menu->p_list->next;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
288 p_ptr != cur_p;
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
289 p_ptr = p_ptr->next)
Dave Love <fx@gnu.org>
parents:
diff changeset
290 XMapWindow(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
291 for (p_ptr = cur_p->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
292 p_ptr != menu->p_list;
Dave Love <fx@gnu.org>
parents:
diff changeset
293 p_ptr = p_ptr->next)
Dave Love <fx@gnu.org>
parents:
diff changeset
294 XMapWindow(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
295
Dave Love <fx@gnu.org>
parents:
diff changeset
296 XRaiseWindow(display, cur_p->window); /* Make sure current */
Dave Love <fx@gnu.org>
parents:
diff changeset
297 /* pane is on top. */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
298
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
299 cur_s = NULL; /* Clear current selection. */
Dave Love <fx@gnu.org>
parents:
diff changeset
300
Dave Love <fx@gnu.org>
parents:
diff changeset
301 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
302 * Begin event processing loop.
Dave Love <fx@gnu.org>
parents:
diff changeset
303 */
Dave Love <fx@gnu.org>
parents:
diff changeset
304 while (1) {
58167
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
305 if (wait_func) (*wait_func) (wait_data);
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
306 XNextEvent(display, &event); /* Get next event. */
Dave Love <fx@gnu.org>
parents:
diff changeset
307 switch (event.type) { /* Dispatch on the event type. */
Dave Love <fx@gnu.org>
parents:
diff changeset
308 case Expose:
Dave Love <fx@gnu.org>
parents:
diff changeset
309 event_xmp = (XMPane *)XLookUpAssoc(display,
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
310 menu->assoc_tab,
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
311 event.xexpose.window);
Dave Love <fx@gnu.org>
parents:
diff changeset
312 if (event_xmp == NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
313 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
314 * If AEQ mode is enabled then queue the event.
Dave Love <fx@gnu.org>
parents:
diff changeset
315 */
Dave Love <fx@gnu.org>
parents:
diff changeset
316 if (menu->aeq) {
Dave Love <fx@gnu.org>
parents:
diff changeset
317 feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue));
Dave Love <fx@gnu.org>
parents:
diff changeset
318 if (feq_tmp == NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
319 _XMErrorCode = XME_CALLOC;
Dave Love <fx@gnu.org>
parents:
diff changeset
320 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
321 }
Dave Love <fx@gnu.org>
parents:
diff changeset
322 feq_tmp->event = event;
Dave Love <fx@gnu.org>
parents:
diff changeset
323 feq_tmp->next = feq;
Dave Love <fx@gnu.org>
parents:
diff changeset
324 feq = feq_tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
325 }
Dave Love <fx@gnu.org>
parents:
diff changeset
326 else if (_XMEventHandler) (*_XMEventHandler)(&event);
Dave Love <fx@gnu.org>
parents:
diff changeset
327 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
328 }
Dave Love <fx@gnu.org>
parents:
diff changeset
329 if (event_xmp->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
330 XSetWindowBackground(display,
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
331 event_xmp->window,
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
332 menu->bkgnd_color);
Dave Love <fx@gnu.org>
parents:
diff changeset
333 }
Dave Love <fx@gnu.org>
parents:
diff changeset
334 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
335 XSetWindowBackgroundPixmap(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
336 event_xmp->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
337 menu->inact_pixmap);
Dave Love <fx@gnu.org>
parents:
diff changeset
338 }
Dave Love <fx@gnu.org>
parents:
diff changeset
339 _XMRefreshPane(display, menu, event_xmp);
Dave Love <fx@gnu.org>
parents:
diff changeset
340 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
341 case EnterNotify:
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
342 /*
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
343 * First wait a small period of time, and see
Dave Love <fx@gnu.org>
parents:
diff changeset
344 * if another EnterNotify event follows hard on the
Dave Love <fx@gnu.org>
parents:
diff changeset
345 * heels of this one. i.e., the user is simply
Dave Love <fx@gnu.org>
parents:
diff changeset
346 * "passing through". If so, ignore this one.
Dave Love <fx@gnu.org>
parents:
diff changeset
347 */
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
348
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
349 event_xmw = (XMWindow *)XLookUpAssoc(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
350 menu->assoc_tab,
Dave Love <fx@gnu.org>
parents:
diff changeset
351 event.xcrossing.window);
Dave Love <fx@gnu.org>
parents:
diff changeset
352 if (event_xmw == NULL) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
353 if (event_xmw->type == SELECTION) {
Dave Love <fx@gnu.org>
parents:
diff changeset
354 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
355 * We have entered a selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
356 */
Dave Love <fx@gnu.org>
parents:
diff changeset
357 /* if (XPending(display) == 0) usleep(150000); */
Dave Love <fx@gnu.org>
parents:
diff changeset
358 if (XPending(display) != 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
359 XPeekEvent(display, &peek_event);
Dave Love <fx@gnu.org>
parents:
diff changeset
360 if(peek_event.type == LeaveNotify) {
Dave Love <fx@gnu.org>
parents:
diff changeset
361 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
362 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
363 }
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
364 cur_s = (XMSelect *)event_xmw;
30365
5eece465cb5d (XMenuActivate): Call help callback with two more
Gerd Moellmann <gerd@gnu.org>
parents: 27457
diff changeset
365 help_callback (cur_s->help_string,
5eece465cb5d (XMenuActivate): Call help callback with two more
Gerd Moellmann <gerd@gnu.org>
parents: 27457
diff changeset
366 cur_p->serial, cur_s->serial);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
367
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
368 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
369 * If the pane we are in is active and the
Dave Love <fx@gnu.org>
parents:
diff changeset
370 * selection entered is active then activate
Dave Love <fx@gnu.org>
parents:
diff changeset
371 * the selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
372 */
Dave Love <fx@gnu.org>
parents:
diff changeset
373 if (cur_p->active && cur_s->active > 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
374 cur_s->activated = 1;
Dave Love <fx@gnu.org>
parents:
diff changeset
375 _XMRefreshSelection(display, menu, cur_s);
Dave Love <fx@gnu.org>
parents:
diff changeset
376 }
Dave Love <fx@gnu.org>
parents:
diff changeset
377 }
Dave Love <fx@gnu.org>
parents:
diff changeset
378 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
379 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
380 * We have entered a pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
381 */
Dave Love <fx@gnu.org>
parents:
diff changeset
382 /* if (XPending(display) == 0) usleep(150000); */
Dave Love <fx@gnu.org>
parents:
diff changeset
383 if (XPending(display) != 0) {
Dave Love <fx@gnu.org>
parents:
diff changeset
384 XPeekEvent(display, &peek_event);
Dave Love <fx@gnu.org>
parents:
diff changeset
385 if (peek_event.type == EnterNotify) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
386 }
Dave Love <fx@gnu.org>
parents:
diff changeset
387 XQueryPointer(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
388 menu->parent,
Dave Love <fx@gnu.org>
parents:
diff changeset
389 &root, &child,
Dave Love <fx@gnu.org>
parents:
diff changeset
390 &root_x, &root_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
391 &win_x, &win_y,
Dave Love <fx@gnu.org>
parents:
diff changeset
392 &mask);
Dave Love <fx@gnu.org>
parents:
diff changeset
393 event_xmp = (XMPane *)XLookUpAssoc(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
394 menu->assoc_tab,
Dave Love <fx@gnu.org>
parents:
diff changeset
395 child);
Dave Love <fx@gnu.org>
parents:
diff changeset
396 if (event_xmp == NULL) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
397 if (event_xmp == cur_p) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
398 if (event_xmp->serial > cur_p->serial) forward = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
399 else forward = False;
Dave Love <fx@gnu.org>
parents:
diff changeset
400 p_ptr = cur_p;
Dave Love <fx@gnu.org>
parents:
diff changeset
401 while (p_ptr != event_xmp) {
Dave Love <fx@gnu.org>
parents:
diff changeset
402 if (forward) p_ptr = p_ptr->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
403 else p_ptr = p_ptr->prev;
Dave Love <fx@gnu.org>
parents:
diff changeset
404 XRaiseWindow(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
405 }
Dave Love <fx@gnu.org>
parents:
diff changeset
406 if (cur_p->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
407 cur_p->activated = False;
Dave Love <fx@gnu.org>
parents:
diff changeset
408 XSetWindowBackgroundPixmap(display,
Dave Love <fx@gnu.org>
parents:
diff changeset
409 cur_p->window,
Dave Love <fx@gnu.org>
parents:
diff changeset
410 menu->inact_pixmap);
Dave Love <fx@gnu.org>
parents:
diff changeset
411 _XMRefreshPane(display, menu, cur_p);
Dave Love <fx@gnu.org>
parents:
diff changeset
412 }
Dave Love <fx@gnu.org>
parents:
diff changeset
413 if (event_xmp->active) event_xmp->activated = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
414 #if 1
Dave Love <fx@gnu.org>
parents:
diff changeset
415 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
416 * i suspect the we don't get an EXPOSE event when backing
Dave Love <fx@gnu.org>
parents:
diff changeset
417 * store is enabled; the menu windows content is probably
Dave Love <fx@gnu.org>
parents:
diff changeset
418 * not drawn in when it should be in that case.
Dave Love <fx@gnu.org>
parents:
diff changeset
419 * in that case, this is probably an ugly fix!
Dave Love <fx@gnu.org>
parents:
diff changeset
420 * i hope someone more familiar with this code would
Dave Love <fx@gnu.org>
parents:
diff changeset
421 * take it from here. -- caveh@eng.sun.com.
Dave Love <fx@gnu.org>
parents:
diff changeset
422 */
Dave Love <fx@gnu.org>
parents:
diff changeset
423 XSetWindowBackground(display,
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
424 event_xmp->window,
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
425 menu->bkgnd_color);
Dave Love <fx@gnu.org>
parents:
diff changeset
426 _XMRefreshPane(display, menu, event_xmp);
Dave Love <fx@gnu.org>
parents:
diff changeset
427 #endif
Dave Love <fx@gnu.org>
parents:
diff changeset
428 cur_p = event_xmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
429 }
Dave Love <fx@gnu.org>
parents:
diff changeset
430 break;
Dave Love <fx@gnu.org>
parents:
diff changeset
431 case LeaveNotify:
Dave Love <fx@gnu.org>
parents:
diff changeset
432 event_xmw = (XMWindow *)XLookUpAssoc(
Dave Love <fx@gnu.org>
parents:
diff changeset
433 display,
Dave Love <fx@gnu.org>
parents:
diff changeset
434 menu->assoc_tab,
Dave Love <fx@gnu.org>
parents:
diff changeset
435 event.xcrossing.window
Dave Love <fx@gnu.org>
parents:
diff changeset
436 );
Dave Love <fx@gnu.org>
parents:
diff changeset
437 if (event_xmw == NULL) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
438 if(cur_s == NULL) break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
439
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
440 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
441 * If the current selection was activated then
Dave Love <fx@gnu.org>
parents:
diff changeset
442 * deactivate it.
Dave Love <fx@gnu.org>
parents:
diff changeset
443 */
Dave Love <fx@gnu.org>
parents:
diff changeset
444 if (cur_s->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
445 cur_s->activated = False;
Dave Love <fx@gnu.org>
parents:
diff changeset
446 _XMRefreshSelection(display, menu, cur_s);
Dave Love <fx@gnu.org>
parents:
diff changeset
447 }
Dave Love <fx@gnu.org>
parents:
diff changeset
448 cur_s = NULL;
Dave Love <fx@gnu.org>
parents:
diff changeset
449 break;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
450
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
451 case ButtonPress:
Dave Love <fx@gnu.org>
parents:
diff changeset
452 case ButtonRelease:
Dave Love <fx@gnu.org>
parents:
diff changeset
453 *p_num = cur_p->serial;
Dave Love <fx@gnu.org>
parents:
diff changeset
454 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
455 * Check to see if there is a current selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
456 */
Dave Love <fx@gnu.org>
parents:
diff changeset
457 if (cur_s != NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
458 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
459 * Set the selection number to the current selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
460 */
Dave Love <fx@gnu.org>
parents:
diff changeset
461 *s_num = cur_s->serial;
Dave Love <fx@gnu.org>
parents:
diff changeset
462 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
463 * If the current selection was activated then
Dave Love <fx@gnu.org>
parents:
diff changeset
464 * we have a valid selection otherwise we have
Dave Love <fx@gnu.org>
parents:
diff changeset
465 * an inactive selection.
Dave Love <fx@gnu.org>
parents:
diff changeset
466 */
Dave Love <fx@gnu.org>
parents:
diff changeset
467 if (cur_s->activated) {
Dave Love <fx@gnu.org>
parents:
diff changeset
468 *data = cur_s->data;
Dave Love <fx@gnu.org>
parents:
diff changeset
469 ret_val = XM_SUCCESS;
Dave Love <fx@gnu.org>
parents:
diff changeset
470 }
Dave Love <fx@gnu.org>
parents:
diff changeset
471 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
472 ret_val = XM_IA_SELECT;
Dave Love <fx@gnu.org>
parents:
diff changeset
473 }
Dave Love <fx@gnu.org>
parents:
diff changeset
474 }
Dave Love <fx@gnu.org>
parents:
diff changeset
475 else {
Dave Love <fx@gnu.org>
parents:
diff changeset
476 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
477 * No selection was current.
Dave Love <fx@gnu.org>
parents:
diff changeset
478 */
Dave Love <fx@gnu.org>
parents:
diff changeset
479 ret_val = XM_NO_SELECT;
Dave Love <fx@gnu.org>
parents:
diff changeset
480 }
Dave Love <fx@gnu.org>
parents:
diff changeset
481 selection = True;
Dave Love <fx@gnu.org>
parents:
diff changeset
482 break;
59101
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
483 case KeyPress:
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
484 case KeyRelease:
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
485 keysym = XLookupKeysym (&event.xkey, 0);
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
486
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
487 /* Pop down on C-g and Escape. */
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
488 if ((keysym == XK_g && (event.xkey.state & ControlMask) != 0)
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
489 || keysym == XK_Escape) /* Any escape, ignore modifiers. */
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
490 {
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
491 ret_val = XM_NO_SELECT;
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
492 selection = True;
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
493 }
8aef5660523e * Activate.c (XMenuActivate): Return XM_NO_SELECT if Escape or C-g
Jan Djärv <jan.h.d@swipnet.se>
parents: 58167
diff changeset
494 break;
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
495 default:
Dave Love <fx@gnu.org>
parents:
diff changeset
496 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
497 * If AEQ mode is enabled then queue the event.
Dave Love <fx@gnu.org>
parents:
diff changeset
498 */
Dave Love <fx@gnu.org>
parents:
diff changeset
499 if (menu->aeq) {
Dave Love <fx@gnu.org>
parents:
diff changeset
500 feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue));
Dave Love <fx@gnu.org>
parents:
diff changeset
501 if (feq_tmp == NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
502 _XMErrorCode = XME_CALLOC;
Dave Love <fx@gnu.org>
parents:
diff changeset
503 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
504 }
Dave Love <fx@gnu.org>
parents:
diff changeset
505 feq_tmp->event = event;
Dave Love <fx@gnu.org>
parents:
diff changeset
506 feq_tmp->next = feq;
Dave Love <fx@gnu.org>
parents:
diff changeset
507 feq = feq_tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
508 }
Dave Love <fx@gnu.org>
parents:
diff changeset
509 else if (_XMEventHandler) (*_XMEventHandler)(&event);
Dave Love <fx@gnu.org>
parents:
diff changeset
510 }
Dave Love <fx@gnu.org>
parents:
diff changeset
511 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
512 * If a selection has been made, break out of the event loop.
Dave Love <fx@gnu.org>
parents:
diff changeset
513 */
Dave Love <fx@gnu.org>
parents:
diff changeset
514 if (selection == True) break;
Dave Love <fx@gnu.org>
parents:
diff changeset
515 }
Dave Love <fx@gnu.org>
parents:
diff changeset
516
Dave Love <fx@gnu.org>
parents:
diff changeset
517 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
518 * Unmap the menu.
Dave Love <fx@gnu.org>
parents:
diff changeset
519 */
Dave Love <fx@gnu.org>
parents:
diff changeset
520 for ( p_ptr = menu->p_list->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
521 p_ptr != menu->p_list;
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
522 p_ptr = p_ptr->next)
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
523 {
Dave Love <fx@gnu.org>
parents:
diff changeset
524 XUnmapWindow(display, p_ptr->window);
Dave Love <fx@gnu.org>
parents:
diff changeset
525 }
Dave Love <fx@gnu.org>
parents:
diff changeset
526
Dave Love <fx@gnu.org>
parents:
diff changeset
527 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
528 * Ungrab the mouse.
Dave Love <fx@gnu.org>
parents:
diff changeset
529 */
Dave Love <fx@gnu.org>
parents:
diff changeset
530 XUngrabPointer(display, CurrentTime);
44752
17275bfd5698 Add calls to GrabKeyboard to remove strange
Jan Djärv <jan.h.d@swipnet.se>
parents: 30365
diff changeset
531 XUngrabKeyboard(display, CurrentTime);
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
532
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
533 /*
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
534 * Restore bits under where the menu was if we managed
Dave Love <fx@gnu.org>
parents:
diff changeset
535 * to save them and free the pixmap.
Dave Love <fx@gnu.org>
parents:
diff changeset
536 */
Dave Love <fx@gnu.org>
parents:
diff changeset
537
Dave Love <fx@gnu.org>
parents:
diff changeset
538 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
539 * If there is a current selection deactivate it.
Dave Love <fx@gnu.org>
parents:
diff changeset
540 */
Dave Love <fx@gnu.org>
parents:
diff changeset
541 if (cur_s != NULL) cur_s->activated = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
542
Dave Love <fx@gnu.org>
parents:
diff changeset
543 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
544 * Deactivate the current pane.
Dave Love <fx@gnu.org>
parents:
diff changeset
545 */
Dave Love <fx@gnu.org>
parents:
diff changeset
546 cur_p->activated = 0;
Dave Love <fx@gnu.org>
parents:
diff changeset
547 XSetWindowBackgroundPixmap(display, cur_p->window, menu->inact_pixmap);
Dave Love <fx@gnu.org>
parents:
diff changeset
548
Dave Love <fx@gnu.org>
parents:
diff changeset
549 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
550 * Synchronize the X buffers and the X event queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
551 */
Dave Love <fx@gnu.org>
parents:
diff changeset
552 XSync(display, 0);
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
553
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
554 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
555 * Dispatch any events remaining on the queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
556 */
Dave Love <fx@gnu.org>
parents:
diff changeset
557 while (QLength(display)) {
Dave Love <fx@gnu.org>
parents:
diff changeset
558 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
559 * Fetch the next event.
Dave Love <fx@gnu.org>
parents:
diff changeset
560 */
Dave Love <fx@gnu.org>
parents:
diff changeset
561 XNextEvent(display, &event);
Dave Love <fx@gnu.org>
parents:
diff changeset
562
Dave Love <fx@gnu.org>
parents:
diff changeset
563 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
564 * Discard any events left on the queue that belong to XMenu.
Dave Love <fx@gnu.org>
parents:
diff changeset
565 * All others are held and then returned to the event queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
566 */
Dave Love <fx@gnu.org>
parents:
diff changeset
567 switch (event.type) {
Dave Love <fx@gnu.org>
parents:
diff changeset
568 case Expose:
Dave Love <fx@gnu.org>
parents:
diff changeset
569 case EnterNotify:
Dave Love <fx@gnu.org>
parents:
diff changeset
570 case LeaveNotify:
Dave Love <fx@gnu.org>
parents:
diff changeset
571 case ButtonPress:
Dave Love <fx@gnu.org>
parents:
diff changeset
572 case ButtonRelease:
Dave Love <fx@gnu.org>
parents:
diff changeset
573 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
574 * Does this event belong to one of XMenu's windows?
Dave Love <fx@gnu.org>
parents:
diff changeset
575 * If so, discard it and process the next event.
Dave Love <fx@gnu.org>
parents:
diff changeset
576 * If not fall through and treat it as a foreign event.
Dave Love <fx@gnu.org>
parents:
diff changeset
577 */
Dave Love <fx@gnu.org>
parents:
diff changeset
578 event_xmp = (XMPane *)XLookUpAssoc(
Dave Love <fx@gnu.org>
parents:
diff changeset
579 display,
Dave Love <fx@gnu.org>
parents:
diff changeset
580 menu->assoc_tab,
Dave Love <fx@gnu.org>
parents:
diff changeset
581 event.xbutton.window
Dave Love <fx@gnu.org>
parents:
diff changeset
582 );
Dave Love <fx@gnu.org>
parents:
diff changeset
583 if (event_xmp != NULL) continue;
Dave Love <fx@gnu.org>
parents:
diff changeset
584 default:
Dave Love <fx@gnu.org>
parents:
diff changeset
585 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
586 * This is a foreign event.
Dave Love <fx@gnu.org>
parents:
diff changeset
587 * Queue it for later return to the X event queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
588 */
Dave Love <fx@gnu.org>
parents:
diff changeset
589 feq_tmp = (XMEventQue *)malloc(sizeof(XMEventQue));
Dave Love <fx@gnu.org>
parents:
diff changeset
590 if (feq_tmp == NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
591 _XMErrorCode = XME_CALLOC;
Dave Love <fx@gnu.org>
parents:
diff changeset
592 return(XM_FAILURE);
Dave Love <fx@gnu.org>
parents:
diff changeset
593 }
Dave Love <fx@gnu.org>
parents:
diff changeset
594 feq_tmp->event = event;
Dave Love <fx@gnu.org>
parents:
diff changeset
595 feq_tmp->next = feq;
Dave Love <fx@gnu.org>
parents:
diff changeset
596 feq = feq_tmp;
Dave Love <fx@gnu.org>
parents:
diff changeset
597 }
Dave Love <fx@gnu.org>
parents:
diff changeset
598 }
Dave Love <fx@gnu.org>
parents:
diff changeset
599 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
600 * Return any foreign events that were queued to the X event queue.
Dave Love <fx@gnu.org>
parents:
diff changeset
601 */
Dave Love <fx@gnu.org>
parents:
diff changeset
602 while (feq != NULL) {
Dave Love <fx@gnu.org>
parents:
diff changeset
603 feq_tmp = feq;
Dave Love <fx@gnu.org>
parents:
diff changeset
604 XPutBackEvent(display, &feq_tmp->event);
Dave Love <fx@gnu.org>
parents:
diff changeset
605 feq = feq_tmp->next;
Dave Love <fx@gnu.org>
parents:
diff changeset
606 free((char *)feq_tmp);
Dave Love <fx@gnu.org>
parents:
diff changeset
607 }
49600
23a1cea22d13 Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 44752
diff changeset
608
58167
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
609 wait_func = 0;
9351060ba546 * XMenu.h (XMenuActivateSetWaitFunction): New function.
Jan Djärv <jan.h.d@swipnet.se>
parents: 54770
diff changeset
610
25858
Dave Love <fx@gnu.org>
parents:
diff changeset
611 /*
Dave Love <fx@gnu.org>
parents:
diff changeset
612 * Return successfully.
Dave Love <fx@gnu.org>
parents:
diff changeset
613 */
Dave Love <fx@gnu.org>
parents:
diff changeset
614 _XMErrorCode = XME_NO_ERROR;
Dave Love <fx@gnu.org>
parents:
diff changeset
615 return(ret_val);
Dave Love <fx@gnu.org>
parents:
diff changeset
616
Dave Love <fx@gnu.org>
parents:
diff changeset
617 }
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
618
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
619 /* arch-tag: 6b90b578-ecea-4328-b460-a0c96963f872
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49600
diff changeset
620 (do not change this comment) */