Sitelet https://github.com/NetHack/NetHack/pull/1671
Skip to content

Qt: size menu and text windows to their contents - #1671

Open
crissman wants to merge 1 commit into
NetHack:NetHack-5.0from
crissman:qt-menu-window-size
Open

crissman wants to merge 1 commit into
NetHack:NetHack-5.0from
crissman:qt-menu-window-size

Conversation

@crissman

@crissman crissman commented Sep 7, 2026 •

Copy link
Copy Markdown

Menu windows in the Qt interface open far too small — often a few rows of a
long inventory — and the inventory window keeps whatever size it had the first
time it was shown, because the core reuses one window for WIN_INVEN and the
layout's cached size hint was never invalidated. The FIXME/TEMPORARY comments in
qt_menu.cpp describe this.

This change:

  • invalidates the table's cached size hint on every MenuResize() and sizes the
    dialog from the fresh hint, so reused windows track their current contents;
  • sizes directly instead of via adjustSize(), whose two-thirds-of-screen cap is
    too small for a long inventory in a large font — cap at 90% of the available
    screen instead, adding the vertical scroll bar's width when the list is taller
    than that;
  • gives NetHackQtTextWindow::Display() the same 90% cap.

Tested on macOS 26, x86_64, Qt 6.11.1: a 21-row inventory in the "Huge" font now
opens at 623×731 with every row visible; shorter menus shrink to fit. Also
compile-checked against current NetHack-5.0.

🤖 Generated with Claude Code

(Reviewed by human Crissman)

https://claude.ai/code/session_01WJwWF29Bgj7KvkVqPrVr5M

The layout caches the menu table's size hint and nothing invalidated it
when the contents changed, so a menu window that the core reuses (the
inventory window, WIN_INVEN) kept the size of the first menu ever shown
in it.  Invalidate the cached hint explicitly and size the dialog from
the fresh value.

Resizing directly instead of via adjustSize() also drops adjustSize()'s
two-thirds-of-screen cap, which is too small for a long inventory in a
large font; use 90% of the available screen instead, and leave room for
the vertical scroll bar when the list is taller than that.  Text windows
get the same treatment.

Replaces the FIXME/TEMPORARY notes about inventory window size in
qt_menu.cpp.
@crissman
crissman marked this pull request as draft September 7, 2026 00:44
@crissman
crissman marked this pull request as ready for review September 7, 2026 01:14
@crissman

Copy link
Copy Markdown
Author

Is sizing Qt menu and text windows to their contents a change you’d welcome? I’d appreciate feedback on the approach or any revisions needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant