From a18222e3df36b48a1e7517272c8336fe3eab098d Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 1 Jan 2023 14:33:07 -0500 Subject: [PATCH] fix(wayland): xdg surface size when not set --- src/wayland/panel_item.rs | 9 ++++++++- src/wayland/xdg_shell.rs | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wayland/panel_item.rs b/src/wayland/panel_item.rs index 1979dad..ae626a7 100644 --- a/src/wayland/panel_item.rs +++ b/src/wayland/panel_item.rs @@ -512,7 +512,14 @@ impl PanelItem { { let queued_state = state.queued_state.as_mut().unwrap(); queued_state.mapped = mapped; - queued_state.size = *surface_data.size.lock(); + if mapped { + queued_state.size = surface_data.size.lock().unwrap_or_else(|| { + self.core_surface() + .unwrap() + .with_data(|data| Vector2::from([data.size.x / 2, data.size.y / 2])) + .unwrap() + }); + } } let Some(node) = self.node.upgrade() else { return }; diff --git a/src/wayland/xdg_shell.rs b/src/wayland/xdg_shell.rs index 5999b3f..fddec97 100644 --- a/src/wayland/xdg_shell.rs +++ b/src/wayland/xdg_shell.rs @@ -83,7 +83,7 @@ impl GlobalDispatch for WaylandState { #[derive(Debug)] pub struct WaylandSurface { wl_surface: Weak, - size: Arc>>, + size: Arc>>>, } impl Dispatch for WaylandState { @@ -105,7 +105,7 @@ impl Dispatch for WaylandState { id, WaylandSurface { wl_surface: surface.downgrade(), - size: Arc::new(Mutex::new(Vector2::from([0; 2]))), + size: Arc::new(Mutex::new(None)), }, ); } @@ -210,7 +210,7 @@ impl Dispatch>, WaylandState> for Wayla pub struct XdgSurfaceData { pub wl_surface: Weak, pub xdg_surface: Weak, - pub size: Arc>>, + pub size: Arc>>>, } impl Dispatch for WaylandState { fn request( @@ -266,7 +266,7 @@ impl Dispatch for WaylandState { width, height, } => { - *data.size.lock() = Vector2::from([width as u32, height as u32]); + *data.size.lock() = Some(Vector2::from([width as u32, height as u32])); } xdg_surface::Request::AckConfigure { serial: _ } => (), xdg_surface::Request::Destroy => (),