From 4270f89956b573512984c6bcbfb9544879381461 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Thu, 6 Feb 2025 03:55:17 +0200 Subject: [PATCH] gpui: Implement `HasWindowHandle` on `Window` (#24327) Implement `raw_window_handle::HasWindowHandle` for `gpui::Window` This opens a lot of possibility of using gpui with platform specific APIs. Edit: With this exposed, we can use crates like `window-vibrancy`, `muda` (menus crate) or even use `wry` (a webview renderer) to create a child `WebView` inside the gpui window. Release Notes: - N/A --- crates/gpui/src/window.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/gpui/src/window.rs b/crates/gpui/src/window.rs index e0e473974db2b08694c3eeb7a9574037b0d2ecbc..7639f5e676c25a33aac90083f99f97dfae583625 100644 --- a/crates/gpui/src/window.rs +++ b/crates/gpui/src/window.rs @@ -23,6 +23,7 @@ use futures::FutureExt; #[cfg(target_os = "macos")] use media::core_video::CVImageBuffer; use parking_lot::RwLock; +use raw_window_handle::{HandleError, HasWindowHandle}; use refineable::Refineable; use slotmap::SlotMap; use smallvec::SmallVec; @@ -3943,6 +3944,12 @@ impl AnyWindowHandle { } } +impl HasWindowHandle for Window { + fn window_handle(&self) -> Result, HandleError> { + self.platform_window.window_handle() + } +} + /// An identifier for an [`Element`](crate::Element). /// /// Can be constructed with a string, a number, or both, as well