diff --git a/anvil/src/input_handler.rs b/anvil/src/input_handler.rs index 150f998e8a..5a001777a9 100644 --- a/anvil/src/input_handler.rs +++ b/anvil/src/input_handler.rs @@ -27,10 +27,7 @@ use smithay::{ compositor::with_states, input_method::InputMethodSeat, keyboard_shortcuts_inhibit::KeyboardShortcutsInhibitorSeat, - shell::{ - wlr_layer::{KeyboardInteractivity, Layer as WlrLayer, LayerSurfaceCachedState}, - xdg::XdgToplevelSurfaceData, - }, + shell::wlr_layer::{KeyboardInteractivity, Layer as WlrLayer, LayerSurfaceCachedState}, }, }; @@ -122,16 +119,8 @@ impl AnvilState { false } }); - let initial_configure_sent = with_states(toplevel.wl_surface(), |states| { - states - .data_map - .get::() - .unwrap() - .lock() - .unwrap() - .initial_configure_sent - }); - if mode_changed && initial_configure_sent { + + if mode_changed && toplevel.is_initial_configure_sent() { toplevel.send_pending_configure(); } } diff --git a/anvil/src/shell/mod.rs b/anvil/src/shell/mod.rs index 4235751233..9dfc3371fa 100644 --- a/anvil/src/shell/mod.rs +++ b/anvil/src/shell/mod.rs @@ -31,7 +31,7 @@ use smithay::{ Layer, LayerSurface as WlrLayerSurface, LayerSurfaceData, WlrLayerShellHandler, WlrLayerShellState, }, - xdg::{XdgPopupSurfaceData, XdgToplevelSurfaceData}, + xdg::XdgToplevelSurfaceData, }, }, }; @@ -322,16 +322,7 @@ fn ensure_initial_configure(surface: &WlSurface, space: &Space, p } }; - let initial_configure_sent = with_states(surface, |states| { - states - .data_map - .get::() - .unwrap() - .lock() - .unwrap() - .initial_configure_sent - }); - if !initial_configure_sent { + if !popup.is_initial_configure_sent() { // NOTE: This should never fail as the initial configure is always // allowed. popup.send_configure().expect("initial configure failed"); diff --git a/anvil/src/shell/xdg.rs b/anvil/src/shell/xdg.rs index 41b4ab2661..3b53483b2f 100644 --- a/anvil/src/shell/xdg.rs +++ b/anvil/src/shell/xdg.rs @@ -311,7 +311,11 @@ impl XdgShellHandler for AnvilState { // The protocol demands us to always reply with a configure, // regardless of we fulfilled the request or not - surface.send_configure(); + if surface.is_initial_configure_sent() { + surface.send_configure(); + } else { + // Will be sent during initial configure + } } fn unfullscreen_request(&mut self, surface: ToplevelSurface) { @@ -367,7 +371,11 @@ impl XdgShellHandler for AnvilState { // The protocol demands us to always reply with a configure, // regardless of we fulfilled the request or not - surface.send_configure(); + if surface.is_initial_configure_sent() { + surface.send_configure(); + } else { + // Will be sent during initial configure + } } fn unmaximize_request(&mut self, surface: ToplevelSurface) { diff --git a/anvil/src/state.rs b/anvil/src/state.rs index a3756b2c6b..946cee7ea9 100644 --- a/anvil/src/state.rs +++ b/anvil/src/state.rs @@ -75,7 +75,7 @@ use smithay::{ wlr_layer::WlrLayerShellState, xdg::{ decoration::{XdgDecorationHandler, XdgDecorationState}, - ToplevelSurface, XdgShellState, XdgToplevelSurfaceData, + ToplevelSurface, XdgShellState, }, }, shm::{ShmHandler, ShmState}, @@ -427,16 +427,7 @@ impl XdgDecorationHandler for AnvilState { }); }); - let initial_configure_sent = with_states(toplevel.wl_surface(), |states| { - states - .data_map - .get::() - .unwrap() - .lock() - .unwrap() - .initial_configure_sent - }); - if initial_configure_sent { + if toplevel.is_initial_configure_sent() { toplevel.send_pending_configure(); } } @@ -445,16 +436,8 @@ impl XdgDecorationHandler for AnvilState { toplevel.with_pending_state(|state| { state.decoration_mode = Some(Mode::ClientSide); }); - let initial_configure_sent = with_states(toplevel.wl_surface(), |states| { - states - .data_map - .get::() - .unwrap() - .lock() - .unwrap() - .initial_configure_sent - }); - if initial_configure_sent { + + if toplevel.is_initial_configure_sent() { toplevel.send_pending_configure(); } } diff --git a/smallvil/src/handlers/xdg_shell.rs b/smallvil/src/handlers/xdg_shell.rs index af4aaf32a8..2819749daa 100644 --- a/smallvil/src/handlers/xdg_shell.rs +++ b/smallvil/src/handlers/xdg_shell.rs @@ -16,8 +16,8 @@ use smithay::{ wayland::{ compositor::with_states, shell::xdg::{ - PopupSurface, PositionerState, ToplevelSurface, XdgPopupSurfaceData, XdgShellHandler, - XdgShellState, XdgToplevelSurfaceData, + PopupSurface, PositionerState, ToplevelSurface, XdgShellHandler, XdgShellState, + XdgToplevelSurfaceData, }, }, }; @@ -177,16 +177,7 @@ pub fn handle_commit(popups: &mut PopupManager, space: &Space, surface: if let Some(popup) = popups.find_popup(surface) { match popup { PopupKind::Xdg(ref xdg) => { - let initial_configure_sent = with_states(surface, |states| { - states - .data_map - .get::() - .unwrap() - .lock() - .unwrap() - .initial_configure_sent - }); - if !initial_configure_sent { + if !xdg.is_initial_configure_sent() { // NOTE: This should never fail as the initial configure is always // allowed. xdg.send_configure().expect("initial configure failed"); diff --git a/src/wayland/shell/xdg/mod.rs b/src/wayland/shell/xdg/mod.rs index 00bc4bc661..ad3a9da9ed 100644 --- a/src/wayland/shell/xdg/mod.rs +++ b/src/wayland/shell/xdg/mod.rs @@ -1526,6 +1526,22 @@ impl ToplevelSurface { serial } + /// Did the surface sent the initial + /// configure event to the client. + /// + /// Calls [`compositor::with_states`] internally. + pub fn is_initial_configure_sent(&self) -> bool { + compositor::with_states(&self.wl_surface, |states| { + states + .data_map + .get::() + .unwrap() + .lock() + .unwrap() + .initial_configure_sent + }) + } + /// Handles the role specific commit logic /// /// This should be called when the underlying WlSurface @@ -1842,6 +1858,22 @@ impl PopupSurface { Ok(serial) } + /// Did the surface sent the initial + /// configure event to the client. + /// + /// Calls [`compositor::with_states`] internally. + pub fn is_initial_configure_sent(&self) -> bool { + compositor::with_states(&self.wl_surface, |states| { + states + .data_map + .get::() + .unwrap() + .lock() + .unwrap() + .initial_configure_sent + }) + } + /// Send a configure event, including the `repositioned` event to the client /// in response to a `reposition` request. ///