Commit graph

1 commit

Author SHA1 Message Date
Vadim Peretokin
96335540f5
fix: getWindowGeometry() and windowVisible() answer for the main window (#9714)
#### Brief overview of PR changes/additions
- `getWindowGeometry("main")` and `windowVisible("main")` (and the `""`
spelling of the same) now answer instead of returning `nil, 'window
"main" not found'`; geometry is `0, 0` plus whatever
`getMainWindowSize()` reports, so the two functions cannot disagree
- `windowVisible()` reads `isVisibleTo(mpConsole)` rather than
`isVisible()`, so a profile that is not the front tab - whose whole
console Mudlet hides - stops reporting every one of its labels,
miniconsoles, scroll boxes, command lines and text edits as invisible. A
child of a hidden user window still reports `false`, which is the
documented behaviour
- New two-profile `WindowStateGettersTest` (the busted suite is always
the single front profile, so it cannot reach this), and the two
`UI_spec` specs that asserted the old refusal are replaced

#### Motivation for adding to Mudlet
Both getters are new in 5.0, and as shipped the first one tells a script
the main window does not exist while the second answers wrong for every
profile the user is not currently looking at.

#### Other info (issues closed, discussion etc)
5.0 QA findings C6 (main rejected) and D10 F1 (background profiles). The
background-profile half is the same defect `7bb20fa2c` ("add: widget
state getters for titles, stylesheets, tooltips and scroll bars
(#9645)") fixed for `getScrollBarVisible`; `windowVisible` landed a week
earlier in `1227bc377` ("add: getWindowGeometry(), windowVisible() and
getLabelText() functions (#9528)") and was left reading the widget.

**On excluding `main` - the counter-argument, weighed.** #9528 made that
choice deliberately: it shipped two `UI_spec` specs asserting the
refusal, with the comment "mirrors moveWindow/resizeWindow, which
likewise do not act on main", and the Area 51 draft says the same. So
this overturns a decision rather than filling an oversight. I still
think it is wrong: the message claims a window that manifestly exists
was *not found*, whereas `moveWindow("main", ...)` is a silent no-op and
claims nothing; `windowType("main")` in the same readback family
answers; and `isMain()`, `getRowCount`, `getColumnCount`,
`getWindowWrap` and `getScrollBarVisible` all take `"main"`/`""`.
Refusing is only defensible when there is no sensible answer, and there
is one. The Area 51 text for both functions needs the matching edit
before it goes to the manual.

Two things deliberately left alone, reported rather than fixed:
`Host::windowType()` still special-cases `"main"` without `""`, and a
user element literally named `"main"` is now shadowed by the main
window.


Assisted-by: Claude:claude-opus-5

**Test case:** `print(getWindowGeometry("main"))` and
`print(windowVisible("main"))` answer; with two profiles open,
`createLabel("probe", 0, 0, 50, 50, 1)` in profile A then
`windowVisible("probe")` from a timer while profile B is in front still
returns `true`.
2026-08-07 10:15:30 +02:00