Skip to content

Commit

Permalink
client-toolkit/toplevel_info: Ignore done before cosmic events
Browse files Browse the repository at this point in the history
The compositor sends a `done` event for the
`ext_foreign_toplevel_handle_v1` before we call `get_cosmic_toplevel`.
Ignore that and wait for the `done` that occurs after we get cosmic
events.

`zcosmic_toplevel_handle_v1::state` seems to be a mandatory event, so it
is valid if awkward to use for the purpose. I don't know about a cleaner
solution. We could just ignore the first `done`, but technically it
could race if the compostior sends a state change before it has
processed the `get_cosmic_toplevel`. Maybe a roundtrip/sync could work.
  • Loading branch information
ids1024 authored and Drakulix committed Oct 22, 2024
1 parent e50f3eb commit 0451452
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion client-toolkit/src/toplevel_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct ToplevelInfo {
struct ToplevelData {
current_info: Option<ToplevelInfo>,
pending_info: ToplevelInfo,
has_cosmic_info: bool,
}

#[derive(Debug)]
Expand Down Expand Up @@ -218,6 +219,7 @@ where
data.pending_info.workspace.remove(&workspace);
}
zcosmic_toplevel_handle_v1::Event::State { state } => {
data.has_cosmic_info = true;
data.pending_info.state.clear();
for value in state.chunks_exact(4) {
if let Some(state) = zcosmic_toplevel_handle_v1::State::try_from(
Expand Down Expand Up @@ -340,7 +342,12 @@ where
}
}
ext_foreign_toplevel_handle_v1::Event::Done => {
// XXX
if !data.has_cosmic_info {
// Don't call `new_toplevel` if we have the `ext_foreign_toplevel_handle_v1`,
// but don't have any `zcosmic_toplevel_handle_v1` events yet.
return;
}

let is_new = data.current_info.is_none();
data.current_info = Some(data.pending_info.clone());
let toplevel = toplevel.clone();
Expand Down

0 comments on commit 0451452

Please sign in to comment.