fix: destroy the toolbar before the round-trip that hides it

This commit is contained in:
elwrcl committed 2026-10-03 01:43:11 +03:00
1 parent 43d56838c1
commit f044915a17
1 file changed
+7 -11
+7 -11
View File
@@ -121,20 +121,16 @@ fn pick(wl: &mut Wayland, output: &Output, initial: ToolbarState) -> Result<(Too
outcome: None, outcome: None,
}); });
let result = wl.dispatch_blocking(|s| s.toolbar.as_ref().is_some_and(|t| t.outcome.is_some())); let result = wl.dispatch_blocking(|s| s.toolbar.as_ref().is_some_and(|t| t.outcome.is_some()));
let toolbar = wl.state.toolbar.take(); // Keep only the answer: dropping the toolbar destroys its surface, and
// The bar must be gone before anything is captured. // 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.conn.flush();
let _ = wl.queue.roundtrip(&mut wl.state); let _ = wl.queue.roundtrip(&mut wl.state);
result?; result?;
let toolbar = toolbar.context("the toolbar vanished")?; let (state, outcome) = ended.context("the toolbar vanished")?;
match toolbar.outcome.flatten() { match outcome.flatten() {
Some(mode) => Ok(( Some(mode) => Ok((ToolbarState { mode, ..state }, mode)),
ToolbarState {
mode,
..toolbar.state
},
mode,
)),
None => Err(Cancelled.into()), None => Err(Cancelled.into()),
} }
} }