Skip to content

Fix embedded browser click focus handoff across Linux, macOS, and Windows - #1631

Merged
i2cjak merged 1 commit into
mainfrom
fix-1595-cef-focus
Nov 22, 2026
Merged

i2cjak merged 1 commit into
mainfrom
fix-1595-cef-focus

Conversation

@i2cjak

@i2cjak i2cjak commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Clicking a text field in the embedded CEF browser could leave keyboard focus with Backplane because:

  • on_got_focus never consulted button_down() when pressed_in() was unwatched (Windows and macOS), and single-consume press records dropped paired on_set_focus/on_got_focus callbacks across intervening pump() ticks;
  • CefPage's independent want_focus/want_yank booleans allowed unclicked on_got_focus, background tabs, or cross-tab switches to yank or mis-blur focus;
  • macOS focus_child unconditionally reset firstResponder on the outer wrapper view even when an inner Chromium view held focus, and lacked pre-dispatch click recording.

Add a pure cross-platform FocusHandoff/PressTracker state machine (viewers/cef_focus.rs) with sequence-ordered press/cutoff tracking and unit tests, hook Windows (WH_MOUSE + WH_CALLWNDPROC WM_MOUSEACTIVATE deduplication) and macOS (GPUIApplication -sendEvent: + AppKit hitTest: + arch-exact ObjCBool) mouse-down events, preserve inner NSView firstResponder on macOS, handle window deactivation and inactive handback cleanly, and wire CefPage/Tab through RenderFocusPlan.

Fixes #1595

…dows

Clicking a text field in the embedded CEF browser could leave keyboard focus with Backplane because:
- on_got_focus never consulted button_down() when pressed_in() was unwatched (Windows and macOS), and single-consume press records dropped paired on_set_focus/on_got_focus callbacks across intervening pump() ticks;
- CefPage's independent want_focus/want_yank booleans allowed unclicked on_got_focus, background tabs, or cross-tab switches to yank or mis-blur focus;
- macOS focus_child unconditionally reset firstResponder on the outer wrapper view even when an inner Chromium view held focus, and lacked pre-dispatch click recording.

Add a pure cross-platform FocusHandoff/PressTracker state machine (viewers/cef_focus.rs) with sequence-ordered press/cutoff tracking and unit tests, hook Windows (WH_MOUSE + WH_CALLWNDPROC WM_MOUSEACTIVATE deduplication) and macOS (GPUIApplication -sendEvent: + AppKit hitTest: + arch-exact ObjCBool) mouse-down events, preserve inner NSView firstResponder on macOS, handle window deactivation and inactive handback cleanly, and wire CefPage/Tab through RenderFocusPlan.

Fixes #1595
@i2cjak
i2cjak merged commit 41f0b97 into main Nov 22, 2026
4 of 19 checks passed
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.

Clicking a text field in the embedded browser leaves keyboard focus with Backplane

1 participant