From 33d2d5de32e017f8d3f0c0c448a97010cc7b87f2 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 26 Aug 2008 11:01:56 +0000 Subject: [PATCH] fix popup menus (broken by recent change to non-popup interaction) svn: r11432 --- src/wxxt/src/Windows/Menu.cc | 1 + src/wxxt/src/XWidgets/xwMenu.c | 13 +++++++++---- src/wxxt/src/XWidgets/xwMenu.h | 3 +++ src/wxxt/src/XWidgets/xwMenuP.h | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/wxxt/src/Windows/Menu.cc b/src/wxxt/src/Windows/Menu.cc index 21ffa65f75..0fe2ba3ecf 100644 --- a/src/wxxt/src/Windows/Menu.cc +++ b/src/wxxt/src/Windows/Menu.cc @@ -181,6 +181,7 @@ Bool wxMenu::PopupMenu(Widget in_w, int root_x, int root_y, Bool forChoice, int XtNbackground, wxGREY_PIXEL, XtNhighlightPixel, wxCTL_HIGHLIGHT_PIXEL, XtNforChoice, forChoice, + XtNforPopup, TRUE, XtNrequestedWidth, requested_width, XtNextraTop, top_extra, NULL); diff --git a/src/wxxt/src/XWidgets/xwMenu.c b/src/wxxt/src/XWidgets/xwMenu.c index c66ba29625..da3d3ee603 100644 --- a/src/wxxt/src/XWidgets/xwMenu.c +++ b/src/wxxt/src/XWidgets/xwMenu.c @@ -130,7 +130,8 @@ static XtResource MenuResources[] = offset(menu.horizontal), XtRImmediate, (XtPointer) True}, {XtNforChoice, XtCForChoice, XtRBoolean, sizeof(Boolean), offset(menu.forChoice), XtRImmediate, (XtPointer) False}, - + {XtNforPopup, XtCForPopup, XtRBoolean, sizeof(Boolean), + offset(menu.forPopup), XtRImmediate, (XtPointer) False}, /* menu structure */ {XtNmenu, XtCMenu, XtRPointer, sizeof(XtPointer), @@ -490,7 +491,9 @@ static void Start(w, ev, params, num_params) mw->menu.grabbed = TRUE; } - if (!HandleMotionEvent(mw, &ev->xmotion, 1)) + if (!HandleMotionEvent(mw, &ev->xmotion, 1) + /* num_params is position when called to start a popup menu */ + && !num_params) DoSelect(w, CurrentTime, 1); } @@ -576,7 +579,8 @@ static void Select(w, event, params, num_params) mw->menu.moused_out = 0; - if (!mw->menu.state || !mw->menu.state->selected) + if (!mw->menu.forPopup + && (!mw->menu.state || !mw->menu.state->selected)) return; force = !HandleMotionEvent(mw, ev, 0); @@ -1552,7 +1556,8 @@ static int HandleMotionEvent(MenuWidget mw, XMotionEvent *ev, int is_click) if (!foundone) mw->menu.moused_out = !in_extra_region; - if (is_click && ms && (item == ms->selected)) { /* pointer on the same item and a click */ + if (!mw->menu.forPopup + && (is_click && ms && (item == ms->selected))) { /* pointer on the same item and a click */ return 0; } diff --git a/src/wxxt/src/XWidgets/xwMenu.h b/src/wxxt/src/XWidgets/xwMenu.h index 416bfd554f..29a8e986d7 100644 --- a/src/wxxt/src/XWidgets/xwMenu.h +++ b/src/wxxt/src/XWidgets/xwMenu.h @@ -48,6 +48,7 @@ SOFTWARE. hMargin HMargin Dimension 1 horizontal Horizontal Boolean True forChoice ForChoice Boolean False + forPopup ForPopup Boolean False menu Menu Pointer NULL onNewItem Callback XtCallbackList NULL onSelect Callback XtCallbackList NULL @@ -75,6 +76,8 @@ SOFTWARE. #define XtCHorizontal "Horizontal" #define XtNforChoice "forChoice" #define XtCForChoice "ForChoice" +#define XtNforPopup "forPopup" +#define XtCForPopup "ForPopup" #define XtNmenu "menu" #define XtCMenu "Menu" #define XtNrefresh "refresh" diff --git a/src/wxxt/src/XWidgets/xwMenuP.h b/src/wxxt/src/XWidgets/xwMenuP.h index 61ce97d6ef..84ad773b2f 100644 --- a/src/wxxt/src/XWidgets/xwMenuP.h +++ b/src/wxxt/src/XWidgets/xwMenuP.h @@ -65,6 +65,7 @@ typedef struct _MenuPart { #endif Boolean horizontal; Boolean forChoice; /* Means extra left and right space */ + Boolean forPopup; Dimension hmargin; /* margins around menu items */ Dimension indicator_size; /* data for toggle, radio and cascade */ Dimension extra_left, extra_top, extra_right, extra_bottom;