From d77ecd4ae58d8d2bd8e3bfeff83979993bc22d57 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 27 Oct 2018 19:26:56 -0700 Subject: [PATCH] X11 menu tweaks Restore handling for keystrokes on PICK_NONE menus so that scrolling via keys works for them. (That handling was disabled as part of the patch to support MENUCOLORS.) Enable [cancel] button for all menus. (That had apparently been grayed out for PICK_NONE menus since day 1 for X11 windowing.) --- doc/fixes36.2 | 2 ++ win/X11/winX.c | 19 +++++++++++-------- win/X11/winmenu.c | 7 ++++++- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index f8e4c8b11..ac6f516f6 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -199,6 +199,7 @@ tty: fix leftover display artifact when the last field on the row got placed to its left, getting shorter X11: its use of genl_status_update exposed a negative index use that could lead to a segfault +X11: rollback disabling of keystroke input for PICK_NONE menus (for scrolling) Platform- and/or Interface-Specific Fixes @@ -248,6 +249,7 @@ X11: handle X errors via panic X11: don't reuse perm_invent window for picking an object X11: obey mouse_support and allow toggling it in game X11: obey menu movement keys +X11: enable menu [cancel] button for PICK_NONE menus General New Features diff --git a/win/X11/winX.c b/win/X11/winX.c index 0c1016da9..389fa1bab 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -1920,35 +1920,38 @@ char *input; /* Display file ----------------------------------------------------------- */ +/* uses a menu (with no selectors specified) rather than a text window + to allow previous_page and first_menu actions to move backwards */ void X11_display_file(str, complain) const char *str; boolean complain; { dlb *fp; + winid newwin; + struct xwindow *wp; + anything any; + menu_item *menu_list; #define LLEN 128 char line[LLEN]; /* Use the port-independent file opener to see if the file exists. */ fp = dlb_fopen(str, RDTMODE); - if (!fp) { if (complain) pline("Cannot open %s. Sorry.", str); return; /* it doesn't exist, ignore */ } - winid newwin = X11_create_nhwindow(NHW_MENU); - struct xwindow *wp = &window_list[newwin]; - anything any = zeroany; - menu_item *menu_list; - + newwin = X11_create_nhwindow(NHW_MENU); + wp = &window_list[newwin]; X11_start_menu(newwin); + any = zeroany; while (dlb_fgets(line, LLEN, fp)) { - X11_add_menu(newwin, NO_GLYPH, &any, 0, 0, ATR_NONE, line, MENU_UNSELECTED); + X11_add_menu(newwin, NO_GLYPH, &any, 0, 0, ATR_NONE, + line, MENU_UNSELECTED); } - (void) dlb_fclose(fp); /* show file name as the window title */ diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index 05f0bba36..eaba350d4 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -254,7 +254,8 @@ Cardinal *num_params; return; } - if (menu_info->is_active && menu_info->how != PICK_NONE) { /* waiting for input */ + /* don't exclude PICK_NONE menus; doing so disables scrolling via keys */ + if (menu_info->is_active) { /* waiting for input */ /* first check for an explicit selector match, so that it won't be overridden if it happens to duplicate a mapped menu command (':' to look inside a container vs ':' to select via search string) */ @@ -324,12 +325,14 @@ Cardinal *num_params; } else if (ch == MENU_FIRST_PAGE || ch == MENU_LAST_PAGE) { Widget hbar = (Widget) 0, vbar = (Widget) 0; float top = (ch == MENU_FIRST_PAGE) ? 0.0 : 1.0; + find_scrollbars(wp->w, &hbar, &vbar); if (vbar) XtCallCallbacks(vbar, XtNjumpProc, &top); return; } else if (ch == MENU_NEXT_PAGE || ch == MENU_PREVIOUS_PAGE) { Widget hbar = (Widget) 0, vbar = (Widget) 0; + find_scrollbars(wp->w, &hbar, &vbar); if (vbar) { float shown, top; @@ -1029,7 +1032,9 @@ Widget form,under; num_args = 0; XtSetArg(args[num_args], nhStr(XtNfromVert), label); num_args++; XtSetArg(args[num_args], nhStr(XtNfromHoriz), ok); num_args++; +#if 0 /* [cancel] is a viable choice even for PICK_NONE */ XtSetArg(args[num_args], nhStr(XtNsensitive), how != PICK_NONE); num_args++; +#endif XtSetArg(args[num_args], nhStr(XtNtop), XtChainTop); num_args++; XtSetArg(args[num_args], nhStr(XtNbottom), XtChainTop); num_args++; XtSetArg(args[num_args], nhStr(XtNleft), XtChainLeft); num_args++; -- 2.40.0