Skip to content

Commit

Permalink
chore: add rwh-6 feature
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Mar 28, 2024
1 parent a698efe commit 2263426
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"]
10 changes: 10 additions & 0 deletions src/dnd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ impl<T: RawSurface> DndSurface<T> {
}
}

#[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()
Expand Down

0 comments on commit 2263426

Please sign in to comment.