Mercurial > emacs
changeset 8166:6fa3cd9b176d
(xmenu_show) [USE_X_TOOLKIT]: Keyboard input exits the menu.
ButtonRelease does so if within Vdouble_click_time.
Ignore mouse motion if button was already released.
(menu_item_selection): Declare volatile, if __STDC__.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 07 Jul 1994 06:29:09 +0000 |
parents | 02ee07034f11 |
children | ae9b49cc645f |
files | src/xmenu.c |
diffstat | 1 files changed, 33 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/xmenu.c Thu Jul 07 05:07:02 1994 +0000 +++ b/src/xmenu.c Thu Jul 07 06:29:09 1994 +0000 @@ -1064,7 +1064,11 @@ return Qnil; } +#ifdef __STDC__ +static Lisp_Object *volatile menu_item_selection; +#else static Lisp_Object *menu_item_selection; +#endif static void popup_selection_callback (widget, id, client_data) @@ -1367,6 +1371,9 @@ #ifdef USE_X_TOOLKIT +extern unsigned last_event_timestamp; +extern Lisp_Object Vdouble_click_time; + extern unsigned int x_mouse_grabbed; extern Lisp_Object Vmouse_depressed; @@ -1611,7 +1618,7 @@ /* No need to check a second time since this is done in the XEvent loop. This slows done the execution. */ -#if 0 +#ifdef XMENU_FOO /* Check again whether the mouse has moved to another menu bar item. */ if (check_mouse_other_menu_bar (f)) { @@ -1631,6 +1638,7 @@ while (1) { XEvent event; + int queue_and_exit = 0; XtAppNextEvent (Xt_app_con, &event); if (event.type == ButtonRelease) @@ -1646,11 +1654,29 @@ if (!x_mouse_grabbed) Vmouse_depressed = Qnil; } - break; + if (! (menu_item_selection == 0 + && (((XButtonEvent *) (&event))->time - last_event_timestamp + < XINT (Vdouble_click_time)))) + break; + } + else if (event.type == ButtonPress) + { + /* Any mouse button activity that doesn't select in the menu + should unpost the menu. */ + if (menu_item_selection == 0) + break; + } + else if (event.type == KeyPress) + { + /* Exit the loop, but first queue this event for reuse. */ + queue_and_exit = 1; } else if (event.type == Expose) process_expose_from_menu (event); - else if (event.type == MotionNotify) + /* If the mouse moves to a different menu bar item, switch to + that item's menu. But only if the button is still held down. */ + else if (event.type == MotionNotify + && x_mouse_grabbed) { int event_x = (event.xmotion.x_root - (f->display.x->widget->core.x @@ -1679,7 +1705,8 @@ } XtDispatchEvent (&event); - if (XtWindowToWidget(XDISPLAY event.xany.window) != menu) + if (queue_and_exit + || XtWindowToWidget (XDISPLAY event.xany.window) != menu) { queue_tmp = (struct event_queue *) malloc (sizeof (struct event_queue)); @@ -1691,6 +1718,8 @@ queue = queue_tmp; } } + if (queue_and_exit) + break; } pop_down: