Skip to content

Commit

Permalink
wayland: Return raw pointer from WindowExtWayland::xdg_toplevel
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon committed Jan 5, 2025
1 parent 3bdabd7 commit 735a9b8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/platform/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
//! * `wayland-csd-adwaita-crossfont`.
//! * `wayland-csd-adwaita-notitle`.
use sctk::reexports::protocols::xdg::shell::client::xdg_toplevel::XdgToplevel;
use std::ffi::c_void;
use std::ptr::null_mut;

use sctk::reexports::client::Proxy;

use crate::event_loop::{ActiveEventLoop, EventLoop, EventLoopBuilder};
use crate::monitor::MonitorHandle;
Expand Down Expand Up @@ -76,17 +79,17 @@ impl<T> EventLoopBuilderExtWayland for EventLoopBuilder<T> {

/// Additional methods on [`Window`] that are specific to Wayland.
pub trait WindowExtWayland {
/// Returns `xdg_toplevel` of the window or [`None`] if the window is X11 window.
fn xdg_toplevel(&self) -> Option<&XdgToplevel>;
/// Returns `xdg_toplevel` of the window or null if the window is X11 window.
fn xdg_toplevel(&self) -> *mut c_void;
}

impl WindowExtWayland for Window {
#[inline]
fn xdg_toplevel(&self) -> Option<&XdgToplevel> {
fn xdg_toplevel(&self) -> *mut c_void {
match &self.window {
#[cfg(x11_platform)]
crate::platform_impl::Window::X(_) => None,
crate::platform_impl::Window::Wayland(w) => Some(w.xdg_toplevel()),
crate::platform_impl::Window::X(_) => null_mut(),
crate::platform_impl::Window::Wayland(w) => w.xdg_toplevel().id().as_ptr().cast(),
}
}
}
Expand Down

0 comments on commit 735a9b8

Please sign in to comment.