comparison src/xmenu.c @ 8624:2768933d85ad

(xmenu_show): Do nothing special for ButtonPress in the menu. Call XtDispatchEvent for all ButtonRelease events. xlwmenu.c now deals with posting the menu. Check for events in subwidgets of the menu when deciding whether to queue them for later handling.
author Richard M. Stallman <rms@gnu.org>
date Thu, 25 Aug 1994 05:05:50 +0000
parents 1ef305a42786
children f8249d9f509d
comparison
equal deleted inserted replaced
8623:428abda49671 8624:2768933d85ad
1648 /* Process events that apply to the menu. */ 1648 /* Process events that apply to the menu. */
1649 while (1) 1649 while (1)
1650 { 1650 {
1651 XEvent event; 1651 XEvent event;
1652 int queue_and_exit = 0; 1652 int queue_and_exit = 0;
1653 int in_this_menu;
1654 Widget widget;
1653 1655
1654 XtAppNextEvent (Xt_app_con, &event); 1656 XtAppNextEvent (Xt_app_con, &event);
1657
1658 /* Check whether the event happened in the menu
1659 or any child of it. */
1660 widget = XtWindowToWidget (XDISPLAY event.xany.window);
1661 in_this_menu = 0;
1662 while (widget)
1663 {
1664 if (widget == menu)
1665 {
1666 in_this_menu = 1;
1667 break;
1668 }
1669 widget = XtParent (widget);
1670 }
1671
1655 if (event.type == ButtonRelease) 1672 if (event.type == ButtonRelease)
1656 { 1673 {
1657 XtDispatchEvent (&event);
1658
1659 /* Do the work of construct_mouse_click since it can't 1674 /* Do the work of construct_mouse_click since it can't
1660 be called. Initially, the popup menu has been called 1675 be called. Initially, the popup menu has been called
1661 from a ButtonPress in the edit_widget. Then the mouse 1676 from a ButtonPress in the edit_widget. Then the mouse
1662 has been set to grabbed. Reset it now. */ 1677 has been set to grabbed. Reset it now. */
1663 x_mouse_grabbed &= ~(1 << event.xbutton.button); 1678 x_mouse_grabbed &= ~(1 << event.xbutton.button);
1665 Vmouse_depressed = Qnil; 1680 Vmouse_depressed = Qnil;
1666 1681
1667 /* If we release the button soon without selecting anything, 1682 /* If we release the button soon without selecting anything,
1668 stay in the loop--that is, leave the menu posted. 1683 stay in the loop--that is, leave the menu posted.
1669 Otherwise, exit this loop and thus pop down the menu. */ 1684 Otherwise, exit this loop and thus pop down the menu. */
1670 if (! (menu_item_selection == 0 1685 if (! in_this_menu
1671 && !next_release_must_exit 1686 && (next_release_must_exit
1672 && (((XButtonEvent *) (&event))->time - last_event_timestamp 1687 || !(((XButtonEvent *) (&event))->time - last_event_timestamp
1673 < XINT (Vdouble_click_time)))) 1688 < XINT (Vdouble_click_time))))
1674 break; 1689 break;
1675 /* Don't call XtDispatchEvent again for the same event! */ 1690 }
1676 continue; 1691 /* A button press outside the menu => pop it down. */
1677 } 1692 else if (event.type == ButtonPress && !in_this_menu)
1693 break;
1678 else if (event.type == ButtonPress) 1694 else if (event.type == ButtonPress)
1679 { 1695 next_release_must_exit = 1;
1680 next_release_must_exit = 1;
1681 #if 0
1682 XtDispatchEvent (&event);
1683 /* Any mouse button activity that doesn't select in the menu
1684 should unpost the menu. */
1685 if (menu_item_selection == 0)
1686 break;
1687 #endif
1688 /* Don't call XtDispatchEvent for the down event.
1689 Doing so seems to give strange results
1690 when you click on the menu bar while a menu is posted. */
1691 continue;
1692 }
1693 else if (event.type == KeyPress) 1696 else if (event.type == KeyPress)
1694 { 1697 {
1695 /* Exit the loop, but first queue this event for reuse. */ 1698 /* Exit the loop, but first queue this event for reuse. */
1696 queue_and_exit = 1; 1699 queue_and_exit = 1;
1697 } 1700 }
1736 if (event.xunmap.window == menu->core.window) 1739 if (event.xunmap.window == menu->core.window)
1737 break; 1740 break;
1738 } 1741 }
1739 1742
1740 XtDispatchEvent (&event); 1743 XtDispatchEvent (&event);
1741 if (queue_and_exit 1744
1742 || XtWindowToWidget (XDISPLAY event.xany.window) != menu) 1745 if (queue_and_exit || !in_this_menu)
1743 { 1746 {
1744 queue_tmp 1747 queue_tmp
1745 = (struct event_queue *) malloc (sizeof (struct event_queue)); 1748 = (struct event_queue *) malloc (sizeof (struct event_queue));
1746 1749
1747 if (queue_tmp != NULL) 1750 if (queue_tmp != NULL)