diff --git a/Cargo.toml b/Cargo.toml index 72d4a83..259f97f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ sctk = { package = "smithay-client-toolkit", git = "https://github.com/Smithay/c wayland-backend = { version = "0.3.3", default_features = false, features = [ "client_system", ] } +raw-window-handle = { version = "0.6", optional = true } [dev-dependencies] dirs = "5.0.1" @@ -32,6 +33,7 @@ thiserror = "1.0.57" url = "2.5.0" [features] -default = ["dlopen", "dnd"] +default = ["dlopen", "dnd", "rwh-6"] +rwh-6 = ["raw-window-handle"] dnd = [] dlopen = ["wayland-backend/dlopen"] diff --git a/src/dnd/mod.rs b/src/dnd/mod.rs index f3d1e68..f3bad40 100644 --- a/src/dnd/mod.rs +++ b/src/dnd/mod.rs @@ -34,6 +34,16 @@ impl DndSurface { } } +#[cfg(feature = "rwh-6")] +impl<'a> RawSurface for raw_window_handle::WindowHandle<'a> { + unsafe fn get_ptr(&mut self) -> *mut c_void { + match self.as_raw() { + raw_window_handle::RawWindowHandle::Wayland(handle) => handle.surface.as_ptr().cast(), + _ => panic!("Unsupported window handle type."), + } + } +} + impl RawSurface for WlSurface { unsafe fn get_ptr(&mut self) -> *mut c_void { self.id().as_ptr().cast()