Skip to content

Commit

Permalink
Destroy layer shell surfaces
Browse files Browse the repository at this point in the history
* [fix] unmap layer shell surfaces before destroying them
  • Loading branch information
CheerfulPianissimo authored May 28, 2024
1 parent 10b748f commit 2dd8af6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions libwayshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,8 @@ impl WayshotConnection {
}
};

let mut layer_shell_surfaces = Vec::with_capacity(frames.len());

for (frame_copy, frame_guard, output_info) in frames {
tracing::span!(
tracing::Level::DEBUG,
Expand Down Expand Up @@ -491,15 +493,23 @@ impl WayshotConnection {

debug!("Committing surface with attached buffer.");
surface.commit();

layer_shell_surfaces.push((surface, layer_surface));
event_queue.blocking_dispatch(&mut state)?;

Ok(())
})?;
}

let callback_result = callback();
layer_shell.destroy();
event_queue.blocking_dispatch(&mut state)?;

debug!("Unmapping and destroying layer shell surfaces.");
for (surface, layer_shell_surface) in layer_shell_surfaces.iter() {
surface.attach(None, 0, 0);
surface.commit(); //unmap surface by committing a null buffer
layer_shell_surface.destroy();
}
event_queue.roundtrip(&mut state)?;

callback_result
}

Expand Down

0 comments on commit 2dd8af6

Please sign in to comment.