Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
172 changes: 116 additions & 56 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ gpui-component-macros = { path = "crates/macros", version = "0.5.1" }
gpui-component-assets = { path = "crates/assets", version = "0.5.1" }
story = { path = "crates/story" }

gpui = { git = "https://github.com/zed-industries/zed" }
gpui_platform = { git = "https://github.com/zed-industries/zed", features = ["font-kit", "x11", "wayland", "runtime_shaders"] }
gpui_web = { git = "https://github.com/zed-industries/zed" }
gpui_macros = { git = "https://github.com/zed-industries/zed" }
reqwest_client = { git = "https://github.com/zed-industries/zed" }
gpui = { git = "https://github.com/huacnlee/zed", branch = "gpui-webview-overlay" }
gpui_platform = { git = "https://github.com/huacnlee/zed", branch = "gpui-webview-overlay", features = ["font-kit", "x11", "wayland", "runtime_shaders"] }
gpui_web = { git = "https://github.com/huacnlee/zed", branch = "gpui-webview-overlay" }
gpui_macros = { git = "https://github.com/huacnlee/zed", branch = "gpui-webview-overlay" }
reqwest_client = { git = "https://github.com/huacnlee/zed", branch = "gpui-webview-overlay" }
sum-tree = { version = "0.2.0", package = "zed-sum-tree" }
# reqwest = { version = "0.12.15-zed", package = "zed-reqwest" }
reqwest = { git = "https://github.com/zed-industries/reqwest.git", rev = "c15662463bda39148ba154100dd44d3fba5873a4", default-features = false, features = [
Expand Down
26 changes: 16 additions & 10 deletions crates/ui/src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use gpui::{
Anchor, AnyView, App, AppContext, Bounds, ClipboardItem, Context, DefiniteLength, ElementId,
Entity, EntityId, FocusHandle, Hitbox, InteractiveElement, IntoElement, KeyBinding,
ParentElement as _, Pixels, Render, StyleRefinement, Styled, WeakEntity, WeakFocusHandle,
Window, actions, div, prelude::FluentBuilder as _,
Window, actions, deferred, div, prelude::FluentBuilder as _,
};
use std::{any::TypeId, collections::HashMap, rc::Rc};

Expand Down Expand Up @@ -159,6 +159,15 @@ impl Root {
cx: &mut App,
) -> Option<impl IntoElement + use<>> {
let root = window.root::<Root>()??;
if root
.read(cx)
.notification
.read(cx)
.notifications()
.is_empty()
{
return None;
}

let active_sheet_placement = root.read(cx).active_sheet.clone().map(|d| d.placement);

Expand All @@ -173,7 +182,7 @@ impl Root {

let placement = cx.theme().notification.placement;

Some(
Some(deferred(
div()
.absolute()
.when(matches!(placement, Anchor::TopRight), |this| {
Expand All @@ -199,7 +208,7 @@ impl Root {
.when_some(mb, |this, offset| this.mb(offset))
.when_some(ml, |this, offset| this.ml(offset))
.child(root.read(cx).notification.clone()),
)
))
}

/// Render the Sheet layer.
Expand All @@ -217,12 +226,9 @@ impl Root {

let size = sheet.size;

return Some(
div()
.relative()
.child(sheet)
.on_prepaint(move |_, _, cx| root.update(cx, |r, _| r.sheet_size = Some(size))),
);
return Some(deferred(div().relative().child(sheet).on_prepaint(
move |_, _, cx| root.update(cx, |r, _| r.sheet_size = Some(size)),
)));
}

None
Expand Down Expand Up @@ -273,7 +279,7 @@ impl Root {
}
}

Some(div().children(dialogs))
Some(deferred(div().children(dialogs)))
}

pub fn open_dialog<F>(&mut self, build: F, window: &mut Window, cx: &mut Context<'_, Root>)
Expand Down
15 changes: 14 additions & 1 deletion crates/webview/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,17 @@ doctest = false
[dependencies]
anyhow.workspace = true
gpui.workspace = true
wry = { version = "0.53.3", package = "lb-wry" }
wry = { git = "https://github.com/longbridge/wry", branch = "gpui-composition-controller", package = "lb-wry" }

[target.'cfg(target_os = "macos")'.dependencies]
block2 = "0.6"
objc2 = "0.6"
objc2-app-kit = { version = "0.3", features = ["block2", "NSEvent", "NSView", "NSWindow"] }

[target.'cfg(target_os = "windows")'.dependencies]
webview2-com = "0.38"
windows-core = "0.61"

[target.'cfg(target_os = "windows")'.dependencies.windows]
version = "0.61"
features = ["Win32_Foundation"]
31 changes: 23 additions & 8 deletions crates/webview/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
# Wry for GPUI

A webview supports for GPUI, based on [Wry](https://github.com/tauri-apps/wry).

This still a experimental with limited features, please file issues for any bugs or missing features.

- The WebView will render on top of the GPUI window, any GPUI elements behind the WebView bounds will be covered.
- Only supports macOS and Windows currently.

So, we recommend using the webview in a separate window or in a Popup layer.
A WebView implementation for GPUI, based on [Wry](https://github.com/tauri-apps/wry).

This is still experimental with limited features. Please file issues for bugs or missing features.

- On macOS, GPUI Popovers, Dialogs, Notifications, and Popup Menus can render
above the WebView when using the layered-scene GPUI branch configured by
this repository.
- The WebView owns native keyboard focus after it is clicked. `gpui-wry`
clears GPUI's logical focus at that boundary so an Input does not continue
showing a stale blinking caret.
- On macOS, applications must provide standard Edit-menu actions for Cut,
Copy, Paste, and Select All. AppKit routes their keyboard shortcuts through
the responder chain to either the focused WebView or GPUI.
- This overlay work targets macOS and Windows. Windows support uses WebView2
composition hosting and is still experimental.
- Linux overlay support is intentionally deferred. wry uses different X11 and
Wayland integration paths and does not expose a surface that can be inserted
directly into GPUI's existing composition tree. Matching macOS and Windows
would require substantial integration with GPUI's Linux GTK/GDK window
backend.

See [`WEBVIEW_OVERLAY_RESEARCH.md`](WEBVIEW_OVERLAY_RESEARCH.md) for the
composition, focus, input, and platform details.

## Run Example

Expand Down
Loading
Loading