From: PatR Date: Sun, 14 Feb 2021 03:17:20 +0000 (-0800) Subject: X11 perm_invent: handle 'O' toggling off perm_invent X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=36179da82f2ed5ade22064ada558702da9d57c7b;p=nethack X11 perm_invent: handle 'O' toggling off perm_invent When persistent inventory window is up, remove it if 'perm_invent' option gets set to False. This has a side-effect of fixing the end-of-game prompting problem it caused. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 8e2a912d4..d7537d195 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.451 $ $NHDT-Date: 1613258116 2021/02/13 23:15:16 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.452 $ $NHDT-Date: 1613272633 2021/02/14 03:17:13 $ General Fixes and Modified Features ----------------------------------- @@ -664,6 +664,11 @@ X11: extend fancy status one-turn inverse video status-change highlighting to X11: stop including unused column 0 in the map X11: avoid 'bad Atom X Error' when perm_invent is enabled (seemingly window manager dependent) +X11: toggling 'perm_invent' off via 'O' didn't dismiss persistent inventory + window +X11: (possibly X11+OSX): if persistent inventory was displayed at time of + end-of-game prompting, prompting would stall until that window was + manually dismissed General New Features diff --git a/include/winX.h b/include/winX.h index 97375fae2..af1ea596e 100644 --- a/include/winX.h +++ b/include/winX.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 winX.h $NHDT-Date: 1611697182 2021/01/26 21:39:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.42 $ */ +/* NetHack 3.7 winX.h $NHDT-Date: 1613272633 2021/02/14 03:17:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.45 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -357,6 +357,7 @@ extern int x_event(int); /* ### winmenu.c ### */ extern void menu_delete(Widget, XEvent *, String *, Cardinal *); extern void menu_key(Widget, XEvent *, String *, Cardinal *); +extern void x11_no_perminv(struct xwindow *); extern void create_menu_window(struct xwindow *); extern void destroy_menu_window(struct xwindow *); diff --git a/win/X11/X11-issues.txt b/win/X11/X11-issues.txt index dd74208e3..89607f765 100644 --- a/win/X11/X11-issues.txt +++ b/win/X11/X11-issues.txt @@ -1,14 +1,11 @@ -End of game stalls after death is reported if the persistent inventory -window is shown at the time. Closing it manually lets the game-over -sequence proceed. Answering 'y' to "Really quit?" and any valid response -to "Dump core?" behaves likewise. - -Toggling 'perm_invent' Off with the 'O' command while the persistent -inventory window is displayed does not remove it. - Starting or restoring a game with 'perm_invent' enabled via config file or NETHACKOPTIONS does not begin with inventory shown. +When persistent inventory window is first populated, focus is given to +its window (behavior might be window manager-specific; it happens with +default window manager on OSX). Focus should be explicitly directed +back to the main window. + When persistent inventory window is displayed, an update that ought to make it grow won't do so even if there is room on the screen for that. It will add scrollbar(s) when not already there, and it can be resized diff --git a/win/X11/winX.c b/win/X11/winX.c index beaa33051..054c6000c 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 winX.c $NHDT-Date: 1613171266 2021/02/12 23:07:46 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.95 $ */ +/* NetHack 3.7 winX.c $NHDT-Date: 1613272634 2021/02/14 03:17:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.96 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -1242,10 +1242,17 @@ X11_destroy_nhwindow(winid window) void X11_update_inventory(void) { - if (x_inited && window_list[WIN_INVEN].menu_information->is_up) { - updated_inventory = 1; /* hack to avoid mapping&raising window */ - (void) display_inventory((char *) 0, FALSE); - updated_inventory = 0; + if (!x_inited) + return; + + if (window_list[WIN_INVEN].menu_information->is_up) { + if (iflags.perm_invent) { + updated_inventory = 1; /* hack to avoid mapping&raising window */ + (void) display_inventory((char *) 0, FALSE); + updated_inventory = 0; + } else { + x11_no_perminv(&window_list[WIN_INVEN]); + } } } diff --git a/win/X11/winmenu.c b/win/X11/winmenu.c index 690e0fef7..1eb2dde9c 100644 --- a/win/X11/winmenu.c +++ b/win/X11/winmenu.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 winmenu.c $NHDT-Date: 1596498373 2020/08/03 23:46:13 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.39 $ */ +/* NetHack 3.7 winmenu.c $NHDT-Date: 1613272635 2021/02/14 03:17:15 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.42 $ */ /* Copyright (c) Dean Luick, 1992 */ /* NetHack may be freely redistributed. See license for details. */ @@ -575,6 +575,20 @@ menu_popdown(struct xwindow *wp) /* Global functions ======================================================= */ +/* called by X11_update_inventory() if persistent inventory is currently + displayed but the 'perm_invent' option is now Off */ +void +x11_no_perminv(struct xwindow *wp) +{ + if (wp && wp->type == NHW_MENU && wp->menu_information->is_up) { + destroy_menu_entry_widgets(wp); + nh_XtPopdown(wp->popup); + XtDestroyWidget(wp->popup); + wp->w = wp->popup = (Widget) 0; + wp->menu_information->is_up = FALSE; + } +} + void X11_start_menu(winid window, unsigned long mbehavior UNUSED) {