diff --git a/CHANGELOG.md b/CHANGELOG.md index 241c0cc4e..3e45e1f0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Unreleased +- On Wayland, added a `get_wayland_display` function to `EventsLoopExt`. - On Windows, fix `CursorMoved(0, 0)` getting dispatched on window focus. - On macOS, fix command key event left and right reverse. - On FreeBSD, NetBSD, and OpenBSD, fix build of X11 backend. diff --git a/src/os/unix.rs b/src/os/unix.rs index 3a468bc2c..f5e2f61c9 100644 --- a/src/os/unix.rs +++ b/src/os/unix.rs @@ -113,6 +113,13 @@ pub trait EventsLoopExt { #[doc(hidden)] fn get_xlib_xconnection(&self) -> Option>; + + /// Returns a pointer to the `wl_display` object of wayland that is used by this `EventsLoop`. + /// + /// Returns `None` if the `EventsLoop` doesn't use wayland (if it uses xlib for example). + /// + /// The pointer will become invalid when the glutin `EventsLoop` is destroyed. + fn get_wayland_display(&self) -> Option<*mut raw::c_void>; } impl EventsLoopExt for EventsLoop { @@ -152,6 +159,14 @@ impl EventsLoopExt for EventsLoop { fn get_xlib_xconnection(&self) -> Option> { self.events_loop.x_connection().cloned() } + + #[inline] + fn get_wayland_display(&self) -> Option<*mut raw::c_void> { + match self.events_loop { + LinuxEventsLoop::Wayland(ref e) => Some(e.get_display().c_ptr() as *mut _), + _ => None + } + } } /// Additional methods on `Window` that are specific to Unix. diff --git a/src/platform/linux/wayland/event_loop.rs b/src/platform/linux/wayland/event_loop.rs index ee483487c..82275e634 100644 --- a/src/platform/linux/wayland/event_loop.rs +++ b/src/platform/linux/wayland/event_loop.rs @@ -229,6 +229,10 @@ impl EventsLoop { pub fn get_available_monitors(&self) -> VecDeque { get_available_monitors(&self.env.outputs) } + + pub fn get_display(&self) -> &Display { + &*self.display + } } /*