Skip to content

gpui: Add window composition tree - #31

Open
huacnlee wants to merge 23 commits into
mainfrom
window-composition-tree
Open

gpui: Add window composition tree#31
huacnlee wants to merge 23 commits into
mainfrom
window-composition-tree

Conversation

@huacnlee

@huacnlee huacnlee commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Objective

  • Add a platform-independent window composition tree to GPUI.
  • Support native and external GPU surfaces inside a GPUI window while preserving correct ordering, clipping, resizing, and GPUI overlays.
  • Provide a working native WebView composition test on macOS and Windows.
image

Solution

  • Add GPUI composition-tree types and APIs for base, overlay, native, and external GPU surfaces.
  • Integrate composition geometry, scene splitting, deferred drawing, hit testing, window presentation, and surface lifecycle into Window and Scene.
  • Add platform surface attachment hooks for bounds, visibility, parent-origin changes, compositor recreation, and platform handles.
  • Implement macOS composition support using Metal-backed surfaces and native WKWebView embedding.
  • Implement Windows composition support using DirectComposition visuals and per-surface swap chains, including:
    • GPUI base and overlay visuals;
    • native/external surface ordering and clipping;
    • resize and device-lost recovery;
    • compositor recreation callbacks;
    • visual opacity and visibility handling.
  • Add the native_webview example with the existing macOS WebKit implementation and a Windows WebView2 ICoreWebView2CompositionController implementation.
  • Forward mouse, button, modifier, and wheel input to WebView2 and update the WebView controller bounds during GPUI layout.
  • Preserve GPUI popup menus, popovers, dialogs, and other overlay elements above the native WebView surface.
  • Add Windows DirectComposition and WebView2 dependencies and document the example.

Linux and Wayland are not included in this change. They require a separate WebKitGTK/GTK integration and cannot reuse Windows DirectComposition directly.

Testing

  • cargo check -p gpui --example native_webview
  • cargo check -p gpui_windows
  • Tested the Windows native WebView example with WebView2, including WebView interaction, resizing, GPUI popup menus, popovers, and dialogs.
  • Tested the macOS composition example path through the existing WebKit implementation.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Improved GPUI window composition with native WebView and external surface support on macOS and Windows.

huacnlee and others added 23 commits July 30, 2026 21:55
Add a transparent macOS GPUI overlay surface that renders deferred window content above embedded native child views while preserving WebView input when the overlay is empty.

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Split DirectComposition into base, native portal, and transparent overlay visuals. Add a platform-neutral native surface handle for binding WebView2 composition controllers.

Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
@huacnlee
huacnlee force-pushed the window-composition-tree branch from d640df4 to 5b1e8e4 Compare August 9, 2026 08:50
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