From f044915a172ae6b0413dd2ff17ef392fc6fefbaa Mon Sep 17 00:00:00 2001 From: elwrcl Date: Sat, 3 Oct 2026 01:42:13 +0300 Subject: [PATCH] fix: destroy the toolbar before the round-trip that hides it --- src/toolbar/mod.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/toolbar/mod.rs b/src/toolbar/mod.rs index 749f7a6..3b1f7c9 100644 --- a/src/toolbar/mod.rs +++ b/src/toolbar/mod.rs @@ -121,20 +121,16 @@ fn pick(wl: &mut Wayland, output: &Output, initial: ToolbarState) -> Result<(Too outcome: None, }); let result = wl.dispatch_blocking(|s| s.toolbar.as_ref().is_some_and(|t| t.outcome.is_some())); - let toolbar = wl.state.toolbar.take(); - // The bar must be gone before anything is captured. + // Keep only the answer: dropping the toolbar destroys its surface, and + // the bar must be gone (flushed and round-tripped) before anything is + // captured. + let ended = wl.state.toolbar.take().map(|t| (t.state, t.outcome)); let _ = wl.conn.flush(); let _ = wl.queue.roundtrip(&mut wl.state); result?; - let toolbar = toolbar.context("the toolbar vanished")?; - match toolbar.outcome.flatten() { - Some(mode) => Ok(( - ToolbarState { - mode, - ..toolbar.state - }, - mode, - )), + let (state, outcome) = ended.context("the toolbar vanished")?; + match outcome.flatten() { + Some(mode) => Ok((ToolbarState { mode, ..state }, mode)), None => Err(Cancelled.into()), } }