Pre-Flight — WP-118 — 2026-11-29

Filled-in copy of docs/reference/pre-flight for WP-118. Verdict at the bottom.

Pre-flighted and executed in one session, started by the WP-104 session after Jeff approved D1–D6 (2026-11-29), and run when Jeff said “Merged, go”. Execution runs inline, so there is no separate session prompt.


Dependency check

Prereq Status in WORK_INDEX Notes
WP-104 🚧 Its theme and packaged defaults are merged (fork PR #36, private PR #63) and on the TV. Its open criterion 10 is this packet’s work.
WP-113 ✅ The game keymap that gives the D-pad to the game in play. Unchanged here.

Rule check: WP-104 isn’t ✅, but the parts WP-118 builds on (the tvapp.ini reader, the TV theme) are merged and installed; noted rather than blocking.

Repo + disc state

What the code has today (fork dc8a9b3a57)

Design

  1. Two kinds of focus. wantsFocus() keeps its meaning (what a click focuses, what a dialog focuses on open). A new Widget::wantsNavigationFocus() (default: wantsFocus()) is also true for buttons and their subclasses (checkbox, radio, drop-down, picture), sliders, pop-ups and the tab row. Mouse use doesn’t change: clicking a button still doesn’t focus it.
  2. Traversal (D3) in Dialog: an arrow the focused widget doesn’t use moves the focus. Candidates are the visible, enabled navigation targets in the dialog’s tree, descending into containers, scroll containers and the active tab, but not into a target’s own children (the list’s scroll bar, the grid’s items). From the focused widget’s focus rectangle (the list’s or grid’s selected row or cell, otherwise its bounds):
    • a candidate lies strictly further along the direction (its centre past the origin’s centre and its far edge past the origin’s far edge);
    • tier 0 overlaps the origin’s beam (its span across the direction), tier 1 lies within 45° by centres, tier 2 is the rest, the lowest tier used;
    • score major² + 4·minor², with major the gap between the edges along the direction and minor the distance between centres across it;
    • ties to the smaller major, then the smaller y, then the smaller x;
    • no candidate: the focus stays (no wrap). Integer arithmetic only, as in the plan’s §5.
  3. Edges. The list hands Up and Down on at its first and last rows; the grid moves by cell and hands on at its edges; a slider changes its value and hands on at its ends; the tab row switches tabs with Left and Right and hands on at its first and last tab; an edit field keeps Left and Right (the caret) and hands on Up and Down.
  4. Activation. Return and keypad Enter on a focused button press it, toggle a checkbox, select a radio button, open a pop-up or a drop-down’s main action. The grid starts the selected game. An edit field reached by the arrows doesn’t open the touch keyboard; Return does.
  5. The focus look (D4). A navigation-focused button, checkbox, radio button, slider or pop-up draws in the highlight state; the tab row draws its active tab highlighted. The list and grid keep their own looks. A scroll container scrolls the focused widget into view.
  6. Initial focus (scope 3). Unchanged where a dialog has a wantsFocus() widget. Where it has none, the dialog focuses its default button (the one whose hotkey is Return), else the top-left target, but only when the switch below is on; on the desktop the first arrow press focuses that widget instead, so a dialog opens looking as it does today. The launcher focuses its list or grid, never the search field.
  7. The switch (D2): a ConfMan key, gui_dpad_focus (default false). The TV app’s tvapp.ini sets it to true. It does two things: Android binds the D-pad (and JOY_HAT_*, where the backend has them) to the GUI’s Up…Right and OK to a new GUI action, and dialogs open with a control focused (6). The traversal itself works on every platform with the keyboard’s arrows.
  8. OK on the TV. A new GUI action, Select (SELT), bound in TV builds to JOY_CENTER, SELECT and JOY_A: it activates the focused control, or, if the pointer moved since the last arrow press (a controller’s left stick), clicks at the pointer as Interact does. Interact keeps its bindings off the TV. Both stay remappable in Global Options → Keymaps.

Amended during execution

What the TV showed changed some of the design above. WP-118 §Result has the details.

Scope lock

This repo: WP-118, EC-018, this file, WORK_INDEX.md, WP-104 (criterion 10 and its row only), docs/ai/DECISIONS.md (D7’s note, if D5 lands).

Fork: gui/dialog.{h,cpp}, gui/widget.{h,cpp}, gui/widgets/list.{h,cpp}, gui/widgets/grid.{h,cpp}, gui/widgets/tab.{h,cpp}, gui/widgets/popup.{h,cpp}, gui/widgets/edittext.{h,cpp}, gui/widgets/scrollcontainer.{h,cpp}, gui/launcher.cpp, gui/gui-manager.{h,cpp}, backends/platform/android/android.cpp, staged by name. Commits brand-free, GUI: / ANDROID: prefixes, one concern each.

Private repo: private/tv-app-identity/assets/tvapp.ini (gui_dpad_focus=true, and gui_launcher_chooser=grid for D5).

TV: adb install -r only; never uninstall, never clear data.

Risk review

Risk Likelihood Impact Mitigation
Desktop behaviour changes: the list now hands Down on at its last row, and the arrows move a focus on dialogs that ignored them. high low Intended (D1: the traversal works with the keyboard everywhere). A dialog opens as before off the TV; a click on another widget clears a navigation-only focus. Checked on Windows (criterion 6).
A widget eats an arrow and traps the focus (the edit field’s Left and Right, a subclass’s own handleKeyDown). med med Edit fields still hand on Up and Down. Every scope-7 dialog walked on the TV with screencaps.
Scroll containers (the options tabs) leave the focus off screen. med med Scroll the focused widget into view on each move.
Pop-ups open a PopUpDialog whose own keys must work. low med It already handles Up, Down, Return and Escape; checked on the TV.
The touch keyboard opens whenever an edit field takes the focus. high med Navigation focus doesn’t open it; OK does. The launcher never starts on the search field.
WP-113’s game keymap: the D-pad must still drive the game’s cursor. low high GUI bindings apply only while the GUI keymap is active; the Virtual Mouse keeps JOY_UP… for games. Checked at Showdown’s Sign In (criterion 5).
OK clicks at a stale pointer. med med Select activates the focus unless the pointer moved since the last arrow.
Old user bindings. A remapped Up…Right in the TV’s scummvm.ini would override the new defaults. low med Checked on the TV before install (run-as read of scummvm.ini).

Verdict

Prepared by: Claude (WP-118 execution session) Date: 2026-11-29