Nathan SoboandClaude Fable 5.2 d31d1074a0 gpui: Fix focus, key equivalent and mouse issues with native views (#67316)
## Summary

Follow-up to #67311, fixing issues a review found in GPUI's native view
support after it merged. All of them affect only windows that show a
native view.

- **A native view that declines keyboard input could recurse without
end.** AppKit answers `YES` to `makeFirstResponder:` even when the view
declines, leaving the window itself as first responder, and GPUI then
asked the same view again from inside the request. The window now checks
where first responder ended up, gives keyboard input to the GPUI view
when the native view didn't take it, and doesn't ask that view again
until it takes input itself or GPUI's focus moves. Reconciling makes at
most two requests.
- **With two native views, a key equivalent could be performed by the
one without keyboard input.** The window asked its superclass, which
searches the whole view hierarchy. It now offers the key equivalent to
the view that holds first responder, and native views sit in a container
that declines key equivalents so AppKit's own search no longer reaches
them.
- **A native view painted more than once left an invisible input
blocker.** Every occurrence inserted a blocking hitbox, though only one
is shown. Only the first-painted visible occurrence blocks now, and the
scene keeps the first occurrence in paint order rather than draw order.
- **A pending multi-key binding stayed armed across a key the view
consumed.** With `cmd-k o` bound, `cmd-k`, then `x` typed into the page,
then `o` still fired the binding. A key that doesn't continue the
pending binding now ends it the way its timeout does.
- **Mouse presses were attributed to a native view from GPUI geometry
alone, and tracked with one flag.** A press on an AppKit control placed
over a native view was also forwarded to GPUI, and with two buttons held
the first release cleared the flag for both. The window now asks
AppKit's hit test which view receives the press, and tracks owed
releases per button.

Not changed: native views are still missing from the window's
accessibility tree, because AccessKit's adapter on the content view
replaces its accessibility children. Moving the adapter to the GPUI view
would change accessibility for every window, and the GPUI view covers
the window, so hit-testing would likely still land in AccessKit's tree.
That needs its own change and a VoiceOver pass.

## Testing

- `cargo test -p gpui -p gpui_macos --lib` passes (457 and 18 tests).
New or extended unit tests cover the declined-view policy, per-button
release tracking, the repeated native view's hit-testing and scene
position, and the pending-binding behaviour; each failed against the
previous code.
- The AppKit behaviours relied on (first responder after a declined
request, the key-equivalent search skipping a declining container, the
hit-test recipient) were confirmed with an offscreen probe.
- Not yet run in an app with a real `WKWebView`: page shortcuts,
reserved bindings, two native views, and a click on a control over a
page.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- N/A
- [GPUI] Fixed a native view that declines keyboard input causing
unbounded recursion.
- [GPUI] Fixed key equivalents reaching a native view without keyboard
input, an unshown repeat of a native view blocking mouse input, a
pending multi-key binding surviving a key the native view used, and
mouse presses on controls over a native view being forwarded to GPUI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-22 13:02:39 +00:00
…
…
2026-11-17 12:43:21 +00:00
…
…
…
…
…

Zed

Zed CI

Welcome to Zed, a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.


Installation

On macOS, Linux, and Windows you can download Zed directly or install Zed via your local package manager (macOS/Linux/Windows).

Other platforms are not yet available:

Developing Zed

Contributing

See CONTRIBUTING.md for ways you can contribute to Zed.

Also... we're hiring! Check out our jobs page for open roles.

Licensing

Zed source code is licensed primarily under GPL-3.0-or-later, with Apache-2.0 components where marked.

License information for third party dependencies must be correctly provided for CI to pass.

We use cargo-about to automatically comply with open source licenses. If CI is failing, check the following:

  • Is it showing a no license specified error for a crate you've created? If so, add publish = false under [package] in your crate's Cargo.toml.
  • Is the error failed to satisfy license requirements for a dependency? If so, first determine what license the project has and whether this system is sufficient to comply with this license's requirements. If you're unsure, ask a lawyer. Once you've verified that this system is acceptable add the license's SPDX identifier to the accepted array in script/licenses/zed-licenses.toml.
  • Is cargo-about unable to find the license for a dependency? If so, add a clarification field at the end of script/licenses/zed-licenses.toml, as specified in the cargo-about book.

Sponsorship

Zed is developed by Zed Industries, Inc., a for-profit company.

If you’d like to financially support the project, you can do so via GitHub Sponsors. Sponsorships go directly to Zed Industries and are used as general company revenue. There are no perks or entitlements associated with sponsorship.

S
Languages
Rust 95.5%
JSON-with-Comments 2.3%
Python 0.8%
Inno Setup 0.3%
Tree-sitter Query 0.3%
Other 0.3%