Mercurial > emacs
comparison oldXMenu/Activate.c @ 49600:23a1cea22d13
Trailing whitespace deleted.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Tue, 04 Feb 2003 14:56:31 +0000 |
parents | 17275bfd5698 |
children | 695cf19ef79e d7ddb3e565de |
comparison
equal
deleted
inserted
replaced
49599:5ade352e8d1c | 49600:23a1cea22d13 |
---|---|
1 /* $Header: /cvsroot/emacs//emacs/oldXMenu/Activate.c,v 1.3 2000/07/21 14:36:24 gerd Exp $ */ | 1 /* $Header: /cvs/emacs/oldXMenu/Activate.c,v 1.4 2002/04/22 18:27:03 jhd Exp $ */ |
2 /* Copyright Massachusetts Institute of Technology 1985 */ | 2 /* Copyright Massachusetts Institute of Technology 1985 */ |
3 | 3 |
4 #include "copyright.h" | 4 #include "copyright.h" |
5 | 5 |
6 /* | 6 /* |
26 * the last known current pane and selection indices). | 26 * the last known current pane and selection indices). |
27 * The following are the defined return states: | 27 * The following are the defined return states: |
28 * | 28 * |
29 * 1) If at any time an error occurs the data | 29 * 1) If at any time an error occurs the data |
30 * pointer is left untouched and XM_FAILURE | 30 * pointer is left untouched and XM_FAILURE |
31 * is returned. | 31 * is returned. |
32 * | 32 * |
33 * 2) When a selection request is received (i.e., | 33 * 2) When a selection request is received (i.e., |
34 * when the specified mouse event occurs) the | 34 * when the specified mouse event occurs) the |
35 * data pointer will be set to the data | 35 * data pointer will be set to the data |
36 * associated with the particular selection | 36 * associated with the particular selection |
40 * 3) If no selection was current at the time a | 40 * 3) If no selection was current at the time a |
41 * selection request is made the data pointer | 41 * selection request is made the data pointer |
42 * will be left untouched and XM_NO_SELECT will | 42 * will be left untouched and XM_NO_SELECT will |
43 * be returned. | 43 * be returned. |
44 * | 44 * |
45 * 4) If the selection that was current at the time | 45 * 4) If the selection that was current at the time |
46 * a selection request is made is not an active | 46 * a selection request is made is not an active |
47 * selection the data pointer will be left | 47 * selection the data pointer will be left |
48 * untouched and XM_IA_SELECT will be returned. | 48 * untouched and XM_IA_SELECT will be returned. |
49 * | 49 * |
50 * Since X processes events in an asynchronous manner | 50 * Since X processes events in an asynchronous manner |
129 struct _xmeventque *next; | 129 struct _xmeventque *next; |
130 } XMEventQue; | 130 } XMEventQue; |
131 | 131 |
132 XMEventQue *feq = NULL; /* Foreign event queue. */ | 132 XMEventQue *feq = NULL; /* Foreign event queue. */ |
133 XMEventQue *feq_tmp; /* Foreign event queue temporary. */ | 133 XMEventQue *feq_tmp; /* Foreign event queue temporary. */ |
134 | 134 |
135 /* | 135 /* |
136 * If there are no panes in the menu then return failure | 136 * If there are no panes in the menu then return failure |
137 * because the menu is not initialized. | 137 * because the menu is not initialized. |
138 */ | 138 */ |
139 if (menu->p_count == 0) { | 139 if (menu->p_count == 0) { |
160 | 160 |
161 /* | 161 /* |
162 * Compute origin of menu so that cursor is in | 162 * Compute origin of menu so that cursor is in |
163 * Correct pane and selection. | 163 * Correct pane and selection. |
164 */ | 164 */ |
165 _XMTransToOrigin(display, | 165 _XMTransToOrigin(display, |
166 menu, | 166 menu, |
167 cur_p, cur_s, | 167 cur_p, cur_s, |
168 x_pos, y_pos, | 168 x_pos, y_pos, |
169 &orig_x, &orig_y); | 169 &orig_x, &orig_y); |
170 menu->x_pos = orig_x; /* Store X and Y coords of menu. */ | 170 menu->x_pos = orig_x; /* Store X and Y coords of menu. */ |
171 menu->y_pos = orig_y; | 171 menu->y_pos = orig_y; |
172 | 172 |
173 if (XMenuRecompute(display, menu) == XM_FAILURE) { | 173 if (XMenuRecompute(display, menu) == XM_FAILURE) { |
174 return(XM_FAILURE); | 174 return(XM_FAILURE); |
175 } | 175 } |
176 | 176 |
177 /* | 177 /* |
210 * XMenu are sent back to the application via an application | 210 * XMenu are sent back to the application via an application |
211 * provided event handler or discarded if the application has | 211 * provided event handler or discarded if the application has |
212 * not provided an event handler. | 212 * not provided an event handler. |
213 */ | 213 */ |
214 XSync(display, 0); | 214 XSync(display, 0); |
215 | 215 |
216 /* | 216 /* |
217 * Grab the mouse for menu input. | 217 * Grab the mouse for menu input. |
218 */ | 218 */ |
219 | 219 |
220 status = XGrabPointer( | 220 status = XGrabPointer( |
221 display, | 221 display, |
222 menu->parent, | 222 menu->parent, |
223 True, | 223 True, |
224 event_mask, | 224 event_mask, |
237 GrabModeAsync, | 237 GrabModeAsync, |
238 CurrentTime); | 238 CurrentTime); |
239 if (status != Success) | 239 if (status != Success) |
240 XUngrabPointer(display, CurrentTime); | 240 XUngrabPointer(display, CurrentTime); |
241 } | 241 } |
242 | 242 |
243 if (status == _X_FAILURE) { | 243 if (status == _X_FAILURE) { |
244 _XMErrorCode = XME_GRAB_MOUSE; | 244 _XMErrorCode = XME_GRAB_MOUSE; |
245 return(XM_FAILURE); | 245 return(XM_FAILURE); |
246 } | 246 } |
247 | 247 |
248 /* | 248 /* |
249 * Map the menu panes. | 249 * Map the menu panes. |
250 */ | 250 */ |
251 XMapWindow(display, cur_p->window); | 251 XMapWindow(display, cur_p->window); |
252 for (p_ptr = menu->p_list->next; | 252 for (p_ptr = menu->p_list->next; |
253 p_ptr != cur_p; | 253 p_ptr != cur_p; |
254 p_ptr = p_ptr->next) | 254 p_ptr = p_ptr->next) |
255 XMapWindow(display, p_ptr->window); | 255 XMapWindow(display, p_ptr->window); |
256 for (p_ptr = cur_p->next; | 256 for (p_ptr = cur_p->next; |
257 p_ptr != menu->p_list; | 257 p_ptr != menu->p_list; |
258 p_ptr = p_ptr->next) | 258 p_ptr = p_ptr->next) |
259 XMapWindow(display, p_ptr->window); | 259 XMapWindow(display, p_ptr->window); |
260 | 260 |
261 XRaiseWindow(display, cur_p->window); /* Make sure current */ | 261 XRaiseWindow(display, cur_p->window); /* Make sure current */ |
262 /* pane is on top. */ | 262 /* pane is on top. */ |
263 | 263 |
264 cur_s = NULL; /* Clear current selection. */ | 264 cur_s = NULL; /* Clear current selection. */ |
265 | 265 |
266 /* | 266 /* |
267 * Begin event processing loop. | 267 * Begin event processing loop. |
268 */ | 268 */ |
269 while (1) { | 269 while (1) { |
270 XNextEvent(display, &event); /* Get next event. */ | 270 XNextEvent(display, &event); /* Get next event. */ |
271 switch (event.type) { /* Dispatch on the event type. */ | 271 switch (event.type) { /* Dispatch on the event type. */ |
272 case Expose: | 272 case Expose: |
273 event_xmp = (XMPane *)XLookUpAssoc(display, | 273 event_xmp = (XMPane *)XLookUpAssoc(display, |
274 menu->assoc_tab, | 274 menu->assoc_tab, |
275 event.xexpose.window); | 275 event.xexpose.window); |
276 if (event_xmp == NULL) { | 276 if (event_xmp == NULL) { |
277 /* | 277 /* |
278 * If AEQ mode is enabled then queue the event. | 278 * If AEQ mode is enabled then queue the event. |
279 */ | 279 */ |
290 else if (_XMEventHandler) (*_XMEventHandler)(&event); | 290 else if (_XMEventHandler) (*_XMEventHandler)(&event); |
291 break; | 291 break; |
292 } | 292 } |
293 if (event_xmp->activated) { | 293 if (event_xmp->activated) { |
294 XSetWindowBackground(display, | 294 XSetWindowBackground(display, |
295 event_xmp->window, | 295 event_xmp->window, |
296 menu->bkgnd_color); | 296 menu->bkgnd_color); |
297 } | 297 } |
298 else { | 298 else { |
299 XSetWindowBackgroundPixmap(display, | 299 XSetWindowBackgroundPixmap(display, |
300 event_xmp->window, | 300 event_xmp->window, |
301 menu->inact_pixmap); | 301 menu->inact_pixmap); |
302 } | 302 } |
303 _XMRefreshPane(display, menu, event_xmp); | 303 _XMRefreshPane(display, menu, event_xmp); |
304 break; | 304 break; |
305 case EnterNotify: | 305 case EnterNotify: |
306 /* | 306 /* |
307 * First wait a small period of time, and see | 307 * First wait a small period of time, and see |
308 * if another EnterNotify event follows hard on the | 308 * if another EnterNotify event follows hard on the |
309 * heels of this one. i.e., the user is simply | 309 * heels of this one. i.e., the user is simply |
310 * "passing through". If so, ignore this one. | 310 * "passing through". If so, ignore this one. |
311 */ | 311 */ |
312 | 312 |
313 event_xmw = (XMWindow *)XLookUpAssoc(display, | 313 event_xmw = (XMWindow *)XLookUpAssoc(display, |
314 menu->assoc_tab, | 314 menu->assoc_tab, |
315 event.xcrossing.window); | 315 event.xcrossing.window); |
316 if (event_xmw == NULL) break; | 316 if (event_xmw == NULL) break; |
317 if (event_xmw->type == SELECTION) { | 317 if (event_xmw->type == SELECTION) { |
322 if (XPending(display) != 0) { | 322 if (XPending(display) != 0) { |
323 XPeekEvent(display, &peek_event); | 323 XPeekEvent(display, &peek_event); |
324 if(peek_event.type == LeaveNotify) { | 324 if(peek_event.type == LeaveNotify) { |
325 break; | 325 break; |
326 } | 326 } |
327 } | 327 } |
328 cur_s = (XMSelect *)event_xmw; | 328 cur_s = (XMSelect *)event_xmw; |
329 help_callback (cur_s->help_string, | 329 help_callback (cur_s->help_string, |
330 cur_p->serial, cur_s->serial); | 330 cur_p->serial, cur_s->serial); |
331 | 331 |
332 /* | 332 /* |
333 * If the pane we are in is active and the | 333 * If the pane we are in is active and the |
334 * selection entered is active then activate | 334 * selection entered is active then activate |
335 * the selection. | 335 * the selection. |
336 */ | 336 */ |
383 * in that case, this is probably an ugly fix! | 383 * in that case, this is probably an ugly fix! |
384 * i hope someone more familiar with this code would | 384 * i hope someone more familiar with this code would |
385 * take it from here. -- caveh@eng.sun.com. | 385 * take it from here. -- caveh@eng.sun.com. |
386 */ | 386 */ |
387 XSetWindowBackground(display, | 387 XSetWindowBackground(display, |
388 event_xmp->window, | 388 event_xmp->window, |
389 menu->bkgnd_color); | 389 menu->bkgnd_color); |
390 _XMRefreshPane(display, menu, event_xmp); | 390 _XMRefreshPane(display, menu, event_xmp); |
391 #endif | 391 #endif |
392 cur_p = event_xmp; | 392 cur_p = event_xmp; |
393 } | 393 } |
398 menu->assoc_tab, | 398 menu->assoc_tab, |
399 event.xcrossing.window | 399 event.xcrossing.window |
400 ); | 400 ); |
401 if (event_xmw == NULL) break; | 401 if (event_xmw == NULL) break; |
402 if(cur_s == NULL) break; | 402 if(cur_s == NULL) break; |
403 | 403 |
404 /* | 404 /* |
405 * If the current selection was activated then | 405 * If the current selection was activated then |
406 * deactivate it. | 406 * deactivate it. |
407 */ | 407 */ |
408 if (cur_s->activated) { | 408 if (cur_s->activated) { |
409 cur_s->activated = False; | 409 cur_s->activated = False; |
410 _XMRefreshSelection(display, menu, cur_s); | 410 _XMRefreshSelection(display, menu, cur_s); |
411 } | 411 } |
412 cur_s = NULL; | 412 cur_s = NULL; |
413 break; | 413 break; |
414 | 414 |
415 case ButtonPress: | 415 case ButtonPress: |
416 case ButtonRelease: | 416 case ButtonRelease: |
417 *p_num = cur_p->serial; | 417 *p_num = cur_p->serial; |
418 /* | 418 /* |
419 * Check to see if there is a current selection. | 419 * Check to see if there is a current selection. |
469 /* | 469 /* |
470 * Unmap the menu. | 470 * Unmap the menu. |
471 */ | 471 */ |
472 for ( p_ptr = menu->p_list->next; | 472 for ( p_ptr = menu->p_list->next; |
473 p_ptr != menu->p_list; | 473 p_ptr != menu->p_list; |
474 p_ptr = p_ptr->next) | 474 p_ptr = p_ptr->next) |
475 { | 475 { |
476 XUnmapWindow(display, p_ptr->window); | 476 XUnmapWindow(display, p_ptr->window); |
477 } | 477 } |
478 | 478 |
479 /* | 479 /* |
480 * Ungrab the mouse. | 480 * Ungrab the mouse. |
481 */ | 481 */ |
482 XUngrabPointer(display, CurrentTime); | 482 XUngrabPointer(display, CurrentTime); |
483 XUngrabKeyboard(display, CurrentTime); | 483 XUngrabKeyboard(display, CurrentTime); |
484 | 484 |
485 /* | 485 /* |
486 * Restore bits under where the menu was if we managed | 486 * Restore bits under where the menu was if we managed |
487 * to save them and free the pixmap. | 487 * to save them and free the pixmap. |
488 */ | 488 */ |
489 | 489 |
490 /* | 490 /* |
500 | 500 |
501 /* | 501 /* |
502 * Synchronize the X buffers and the X event queue. | 502 * Synchronize the X buffers and the X event queue. |
503 */ | 503 */ |
504 XSync(display, 0); | 504 XSync(display, 0); |
505 | 505 |
506 /* | 506 /* |
507 * Dispatch any events remaining on the queue. | 507 * Dispatch any events remaining on the queue. |
508 */ | 508 */ |
509 while (QLength(display)) { | 509 while (QLength(display)) { |
510 /* | 510 /* |
555 feq_tmp = feq; | 555 feq_tmp = feq; |
556 XPutBackEvent(display, &feq_tmp->event); | 556 XPutBackEvent(display, &feq_tmp->event); |
557 feq = feq_tmp->next; | 557 feq = feq_tmp->next; |
558 free((char *)feq_tmp); | 558 free((char *)feq_tmp); |
559 } | 559 } |
560 | 560 |
561 /* | 561 /* |
562 * Return successfully. | 562 * Return successfully. |
563 */ | 563 */ |
564 _XMErrorCode = XME_NO_ERROR; | 564 _XMErrorCode = XME_NO_ERROR; |
565 return(ret_val); | 565 return(ret_val); |