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.
This commit is contained in:
PatR
2021-02-13 19:17:20 -08:00
parent 8c0e3b2a8d
commit 36179da82f
5 changed files with 40 additions and 16 deletions

View File

@@ -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

View File

@@ -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]);
}
}
}

View File

@@ -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)
{