Nathan Sobo f4fe0be1f8 gpui: Composite native views into the scene on macOS (#67311)
## Summary

Adds `NativeView` to GPUI: an element that places a platform view (an
`NSView` on macOS) in a window and composites it with the rest of the
scene, so that GPUI content can be drawn both under and over it. Delta
uses this to show a `WKWebView` in a pane tab with GPUI dialogs and
toolbars drawn over the page.

What it covers on macOS:

- **Compositing.** The native view sits behind the window's Metal layer,
and the renderer cuts a hole in the scene where the view shows, so GPUI
elements painted after it appear above it. The window's layer is
non-opaque only while a scene shows a native view.
- **Keyboard input.** Keys go to a focused native view first. An
embedder can reserve actions that must keep working whatever the view
does with keys, including the first key of a multi-key binding. AppKit
controls beside a native view keep their own input.
- **Pointer.** GPUI elements over a native view block clicks to it, and
the native view chooses the cursor while the pointer is over an
unobscured part of it.
- **Accessibility.** VoiceOver can reach a native view that is shown.

Other platforms get the element and a no-op implementation:
`NativeView::new` reports that the window cannot show native views.

Also included is a small `div` fix that the embedder needed: an item a
scroll handle is asked to scroll to before the handle's first frame is
now scrolled to once it has been laid out.

## Testing

- Two examples: `cargo run -p gpui --example native_view` and `--example
native_view_appkit_field`, which show native views with GPUI drawn over
them.
- The test platform's window records native view placement, with unit
tests for the placement, input-routing policy and reserved-action logic.
- Exercised through Delta's browser tabs on macOS 26: typing, shortcuts,
splits, zoom, dialogs drawn over the page, and hiding and showing tabs.
- Not exercised by hand: the black-flash, stale-cursor and VoiceOver
fixes in the last two commits.

## 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] Added `NativeView`, an element that composites an `NSView` into
a window's scene with GPUI content drawn over it. Only macOS supports it
for now; `NativeView::new` returns an error on other platforms.
- [GPUI] Fixed `ScrollHandle::scroll_to_item` being ignored when called
before the handle's first frame.

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

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-11-22 03:18:59 +00:00
…
2026-11-17 12:43:21 +00:00
2026-01-22 23:57:26 +05:30
2026-09-11 09:13:44 +00:00
2025-02-04 09:02:59 -05:00
2025-10-27 13:27:59 -04: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
Description
No description provided
Readme 1.4 GiB
Languages
Rust 95.4%
JSON-with-Comments 2.4%
Python 0.8%
Inno Setup 0.3%
Tree-sitter Query 0.3%
Other 0.4%