gpui: Implement window_handle and display_handle for wayland platform (#28152)

This PR implements the previously unimplemented window_handle and
display_handle methods in the wayland platform. It also exposes the
display_handle method through the Window struct.

Release Notes:

- N/A
This commit is contained in:
Christian Bergschneider 2025-05-31 00:45:03 +02:00 committed by GitHub
parent fe1b36671d
commit 40c91d5df0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 3 deletions

View file

@ -751,12 +751,28 @@ where
impl rwh::HasWindowHandle for WaylandWindow {
fn window_handle(&self) -> Result<rwh::WindowHandle<'_>, rwh::HandleError> {
unimplemented!()
let surface = self.0.surface().id().as_ptr() as *mut libc::c_void;
let c_ptr = NonNull::new(surface).ok_or(rwh::HandleError::Unavailable)?;
let handle = rwh::WaylandWindowHandle::new(c_ptr);
let raw_handle = rwh::RawWindowHandle::Wayland(handle);
Ok(unsafe { rwh::WindowHandle::borrow_raw(raw_handle) })
}
}
impl rwh::HasDisplayHandle for WaylandWindow {
fn display_handle(&self) -> Result<rwh::DisplayHandle<'_>, rwh::HandleError> {
unimplemented!()
let display = self
.0
.surface()
.backend()
.upgrade()
.ok_or(rwh::HandleError::Unavailable)?
.display_ptr() as *mut libc::c_void;
let c_ptr = NonNull::new(display).ok_or(rwh::HandleError::Unavailable)?;
let handle = rwh::WaylandDisplayHandle::new(c_ptr);
let raw_handle = rwh::RawDisplayHandle::Wayland(handle);
Ok(unsafe { rwh::DisplayHandle::borrow_raw(raw_handle) })
}
}