diff --git a/src/wayland/registry.rs b/src/wayland/registry.rs index 66f5d9a..571314e 100644 --- a/src/wayland/registry.rs +++ b/src/wayland/registry.rs @@ -150,7 +150,12 @@ impl WlRegistry for Registry { } RegistryGlobals::WM_BASE => { tracing::info!("Binding WM_BASE"); - client.insert(new_id.object_id, WmBase); + client.insert( + new_id.object_id, + WmBase { + version: new_id.version, + }, + ); } RegistryGlobals::SEAT => { tracing::info!("Binding seat with id {}", new_id.object_id); diff --git a/src/wayland/xdg/popup.rs b/src/wayland/xdg/popup.rs index 84e979a..b63a9dd 100644 --- a/src/wayland/xdg/popup.rs +++ b/src/wayland/xdg/popup.rs @@ -17,6 +17,7 @@ use waynest::{ #[derive(Debug, Dispatcher)] pub struct Popup { id: ObjectId, + version: u32, parent: Weak, surface: Weak, pub panel_item: Weak>, @@ -27,6 +28,7 @@ pub struct Popup { impl Popup { pub fn new( id: ObjectId, + version: u32, parent: &Arc, panel_item: &Arc>, xdg_surface: &Arc, @@ -35,6 +37,7 @@ impl Popup { let positioner_data = positioner.data(); Self { id, + version, parent: Arc::downgrade(parent), surface: Arc::downgrade(xdg_surface), panel_item: Arc::downgrade(panel_item), @@ -67,7 +70,9 @@ impl XdgPopup for Popup { let positioner = client.get::(positioner).unwrap(); let positioner_data = positioner.data(); *self.positioner_data.lock() = positioner_data; - self.repositioned(client, sender_id, token).await?; + if self.version >= 5 { + self.repositioned(client, sender_id, token).await?; + } let geometry = positioner_data.infinite_geometry(); self.configure( client, diff --git a/src/wayland/xdg/surface.rs b/src/wayland/xdg/surface.rs index 5f95880..cef2cd2 100644 --- a/src/wayland/xdg/surface.rs +++ b/src/wayland/xdg/surface.rs @@ -11,13 +11,19 @@ use waynest::{ #[derive(Debug, Dispatcher)] pub struct Surface { id: ObjectId, + version: u32, wl_surface: Weak, configured: Arc, } impl Surface { - pub fn new(id: ObjectId, wl_surface: Arc) -> Self { + pub fn new( + id: ObjectId, + version: u32, + wl_surface: Arc, + ) -> Self { Self { id, + version, wl_surface: Arc::downgrade(&wl_surface), configured: Arc::new(std::sync::atomic::AtomicBool::new(false)), } @@ -127,7 +133,14 @@ impl XdgSurface for Surface { let popup = client.insert( popup_id, - Popup::new(popup_id, &parent, &panel_item, &surface, &positioner), + Popup::new( + popup_id, + self.version, + &parent, + &panel_item, + &surface, + &positioner, + ), ); { diff --git a/src/wayland/xdg/wm_base.rs b/src/wayland/xdg/wm_base.rs index 113f2e6..2959251 100644 --- a/src/wayland/xdg/wm_base.rs +++ b/src/wayland/xdg/wm_base.rs @@ -8,7 +8,9 @@ use waynest::{ use super::positioner::Positioner; #[derive(Debug, Dispatcher, Default)] -pub struct WmBase; +pub struct WmBase { + pub version: u32, +} impl XdgWmBase for WmBase { async fn destroy(&self, _client: &mut Client, _sender_id: ObjectId) -> Result<()> { Ok(()) @@ -36,7 +38,7 @@ impl XdgWmBase for WmBase { .ok_or(waynest::server::Error::Custom( "can't get wayland surface id".to_string(), ))?; - let xdg_surface = Surface::new(xdg_surface_id, wl_surface); + let xdg_surface = Surface::new(xdg_surface_id, self.version, wl_surface); client.insert(xdg_surface_id, xdg_surface); Ok(())