Skip to content

feat: Focus navigation, stick pointer and a better keyboard - #2

Merged
idy merged 3 commits into
mainfrom
codex/browser-navigation
Nov 26, 2026
Merged

idy merged 3 commits into
mainfrom
codex/browser-navigation

Conversation

@idy

@idy idy commented Nov 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Focus navigation: the D-pad moves between links and fields with WebKit spatial navigation and autorepeats when held. A ring marks the focused element, and A opens links, toggles checkboxes or types into fields.
  • Pointer and scrolling: the left stick moves a drawn pointer that A clicks, the right stick scrolls smoothly, L1/R1 page, and L2/R2/Select zoom.
  • Keyboard: a new on-screen keyboard has https://, www., .com, .cn, / and : shortcuts, a symbol layer, shift, caret movement with L1/R1, and a preview of the field. It also types into page fields. Text that is not an address searches Bing. Labels follow the Launcher language.
  • Overlay: keyboard, ring, pointer, load progress and toasts run in an isolated script world, so pages cannot drive it.
  • Responsiveness: gamepads are read as events arrive instead of every 30 ms. Pages paint on the CPU, web processes are capped at 420 MB, the page cache is on, and a mobile user agent requests lighter pages.

Validation

  • On the R36S, the same scrolling page measured p95/max frame times of 25/127 ms with GPU painting and 16/59 ms with CPU painting.
  • The 640×480 start page and in-page keyboard were reviewed in English and Chinese.
  • The ARM64 smoke test drives the real input paths: it types an address, moves focus with the D-pad, follows a link, scrolls, types into a page field and loads a second origin.

@idy

idy commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/codex-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Code Review

❌ 1 blocking finding (P0, P1).

The diff introduces a blocking keyboard-state bug during cached history navigation, plus two input-handling issues. ARM64 builds and device behavior could not be validated in this read-only environment.

Reviewed head a99f7df85f1f7c30d2946bfc8c2fb6fa578fb8c3. Push changes, then comment a new review request to review the new head.

Comment thread src/platform.c
(void)event;
sync_view(browser);
if (event == WEBKIT_LOAD_COMMITTED) {
browser->keyboard = FALSE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Resynchronize overlay state after restoring a cached page.

Returning to a cached address screen restores its open keyboard, but this handler resets the native keyboard flag. Cached documents do not rerun DOMContentLoaded, so the overlay never republishes its state: D-pad and face buttons perform browser actions instead of operating the visible keyboard. Republish keyboard and focus state on persisted pageshow or explicitly request it after restoration, and cover back/forward navigation in the smoke test.

Comment thread src/platform.c
{
(void)fd;
Pad *pad = data;
if (condition & (G_IO_ERR | G_IO_HUP | G_IO_NVAL)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Clear controller state when its input device disconnects.

Disconnecting a controller while a direction or stick is held removes its FD source without clearing the repeat timer or stored axes. Since no release event arrives, navigation, deletion, pointer movement, or scrolling can continue indefinitely. Track active input ownership per pad and cancel its repeats and axis state on both disconnect paths.

Comment thread src/platform.c Outdated
g_autoptr(WebKitUserContentManager) content = webkit_user_content_manager_new();
g_autofree char *script_source = g_strconcat("globalThis.GIZLET_LANG = \"", chinese ? "zh-CN" : "en", "\";\n",
overlay_source, NULL);
WebKitUserScript *script = webkit_user_script_new_for_world(script_source, WEBKIT_USER_CONTENT_INJECT_TOP_FRAME,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Support keyboard activation for fields inside frames.

The overlay runs only in the top frame, so focusing a field inside an iframe produces no editable-focus message. The top document sees the iframe as its active element; A therefore sends Enter rather than opening the keyboard, and pointer clicks cannot open it either. Embedded login and search forms cannot be filled using handheld controls. Add isolated-world focus and editing support for the focused frame, including a cross-origin iframe test.

@idy

idy commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/codex-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Code Review

✅ No blocking findings (2 non-blocking).

The full diff contains two actionable focus-handling gaps in the new keyboard integration. JavaScript and shell syntax checks passed; ARM64 packaging and WebKit runtime tests were unavailable in this checkout.

Reviewed head 7662cb752377d8e22f79b9a52edc891e1079cc0e. Push changes, then comment a new review request to review the new head.

Comment thread src/platform.c
: g_str_equal(kind, "frame") ? FOCUS_FRAME : g_str_equal(kind, "other") ? FOCUS_OTHER : FOCUS_NONE;
} else if (g_str_has_prefix(message, "subfocus:")) {
const char *kind = message + strlen("subfocus:");
browser->frame_text = g_str_has_prefix(kind, "text");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Synchronize top-level focus when a frame reports text focus.

When navigation moves focus into an iframe field without clicking, the child reports subfocus:text, but this handler only updates frame_text. Focus events inside the frame do not bubble to the parent, so browser->focus can remain FOCUS_NONE or FOCUS_OTHER. A then sends Enter instead of opening the keyboard because press() also requires FOCUS_FRAME. Synchronize the parent's active-element state on subframe focus changes and add coverage for entering a frame with the D-pad.

Comment thread ui/overlay.js Outdated
};
const target = () => {
if (start) return document.getElementById("address");
const element = document.activeElement;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Resolve text fields inside shadow roots.

For an input inside a web component's shadow root, document.activeElement is the component host, and the window's focusin event is also retargeted to that host. Consequently, the overlay classifies the field as non-editable and cannot open its keyboard through either A or a pointer click. Resolve the actual focused control through open shadow roots and use the event's composed path when identifying focus targets.

@idy

idy commented Nov 26, 2026

Copy link
Copy Markdown
Member Author

/codex-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Code Review

✅ No blocking findings (2 non-blocking).

Found two input and display regressions worth fixing. The ARM64 build and smoke test were not run in this read-only checkout.

Reviewed head bf10a523e948b5811a2f8ff06a2d2d5d3420ce2b. Push changes, then comment a new review request to review the new head.

Comment thread src/main.rs
extern "C" fn browser_button(code: u16, swap: bool) -> c_int {
let (a, b) = if swap { (BTN_SOUTH, BTN_EAST) } else { (BTN_EAST, BTN_SOUTH) };
let button = match code {
0x220 => Button::Up,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Previously supported D-pad key codes are now ignored.

Pads emitting KEY_UP, KEY_DOWN, KEY_LEFT, and KEY_RIGHT (103/108/105/106) now map every direction to Button::None. These devices were explicitly supported before this change; open_pads() still accepts them, and the HAT handler cannot compensate when they emit no HAT events. Restore the key-code aliases alongside the BTN_DPAD_* mappings.

Comment thread src/platform.c
index = (guint)CLAMP((int)index + step, 0, (int)G_N_ELEMENTS(levels) - 1);
else
index = 4;
webkit_web_view_set_zoom_level(browser->web, levels[index]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Page zoom pushes the keyboard outside the handheld display.

The overlay shares the document's zoom, and that zoom persists when X opens the address screen. At 200% on the R36S's 640×480 display, the viewport is only 320×240 CSS pixels, while the keyboard's six fixed-height rows, padding, and hints exceed that height. The keyboard covers the address field and clips its upper keys; zoom controls are then intercepted as keyboard actions. Keep the overlay independent of page zoom, or resize it to fit, and verify the address screen at the supported zoom levels.

@idy
idy merged commit 47cfd90 into main Nov 26, 2026
2 checks passed
@idy
idy deleted the codex/browser-navigation branch November 26, 2026 11:38
idy added a commit that referenced this pull request Nov 26, 2026
## Summary

Follow-up to #2, from its Codex review.

- Gamepads that report the D-pad as `KEY_UP`, `KEY_DOWN`, `KEY_LEFT` and
`KEY_RIGHT` move focus again, as they did in #1.
- The on-screen keyboard, toasts and pointer counter-scale the page
zoom, so the keyboard keeps its size and fits the 640×480 screen at
200%.

## Validation

The ARM64 smoke test adds a step that zooms to 200% with the keyboard
open and checks that its on-screen height is unchanged.


## Smoke test on the handheld

The smoke test had only run in CI. On an R36S (192.168.4.254) it failed
every time at step 5: `scrollY` is read 600 ms after a single scroll
event, and on the handheld the position arrives about 3 s later. A
failing check is now retried every 250 ms, up to 16 times. A full run
takes about 36 s there, so the deadline is now 90 s instead of 40 s.
With these changes all 17 steps pass on the device.
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