diff --git a/Cargo.lock b/Cargo.lock index ddf3a2a4f406a..8d653610a2075 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5495,6 +5495,7 @@ dependencies = [ "foreign-types 0.5.0", "futures 0.3.31", "gpui_macros", + "gtk", "http_client", "image", "itertools 0.13.0", diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index b469a37f042dc..ecf1ab14f23ad 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -119,6 +119,9 @@ http_client = { workspace = true, features = ["test-support"] } unicode-segmentation.workspace = true wry = "0.41.0" +[target.'cfg(target_os = "linux")'.dev-dependencies] +gtk = "0.18.0" + [build-dependencies] embed-resource = "2.4" diff --git a/crates/gpui/examples/webview.rs b/crates/gpui/examples/webview.rs index 5cc687ee12e51..1c988cd0a55d7 100644 --- a/crates/gpui/examples/webview.rs +++ b/crates/gpui/examples/webview.rs @@ -35,6 +35,11 @@ impl Render for WebViewWindow { } fn main() { + #[cfg(target_os = "linux")] + { + gtk::init().unwrap(); + } + App::new().run(|cx: &mut AppContext| { let bounds = Bounds::centered(None, size(px(1200.0), px(800.0)), cx); let window = cx diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 8d4516b3f37b7..bcc4e9b6890f9 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -751,7 +751,10 @@ fn primary_output_scale(state: &mut RefMut) -> i32 { impl rwh::HasWindowHandle for WaylandWindow { fn window_handle(&self) -> Result, rwh::HandleError> { - unimplemented!() + let state = self.borrow(); + let window = NonNull::new(state.surface.id().as_ptr().cast::()).unwrap(); + let handle = rwh::WaylandWindowHandle::new(window); + Ok(unsafe { rwh::WindowHandle::borrow_raw(handle.into()) }) } } impl rwh::HasDisplayHandle for WaylandWindow { diff --git a/crates/gpui/src/platform/linux/x11/window.rs b/crates/gpui/src/platform/linux/x11/window.rs index 15712233c2ffe..06a5f9f1de48e 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -299,7 +299,8 @@ impl rwh::HasDisplayHandle for RawWindow { impl rwh::HasWindowHandle for X11Window { fn window_handle(&self) -> Result { - unimplemented!() + let mut handle = rwh::XlibWindowHandle::new(self.0.x_window as u64); + Ok(unsafe { rwh::WindowHandle::borrow_raw(handle.into()) }) } } impl rwh::HasDisplayHandle for X11Window {