diff --git a/Cargo.lock b/Cargo.lock index 905312e34d7fd..183d7e16aad0c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5502,6 +5502,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 55ba4f6004d39..8611ddaff54d3 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 ae9abe714691f..c24f764862015 100644 --- a/crates/gpui/src/platform/linux/x11/window.rs +++ b/crates/gpui/src/platform/linux/x11/window.rs @@ -306,7 +306,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 {