Skip to content

Commit

Permalink
[fix] unmap layer shell surfaces before destroying them
Browse files Browse the repository at this point in the history
  • Loading branch information
CheerfulPianissimo committed Apr 13, 2024
1 parent 19e3ee8 commit f0cd9f4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libwayshot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ impl WayshotConnection {

debug!("Committing surface with attached buffer.");
surface.commit();
layer_shell_surfaces.push(layer_surface);
layer_shell_surfaces.push((surface, layer_surface));
event_queue.blocking_dispatch(&mut state)?;

Ok(())
Expand All @@ -502,11 +502,13 @@ impl WayshotConnection {

let callback_result = callback();

debug!("Destroying layer shell surfaces.");
for layer_shell_surface in layer_shell_surfaces.into_iter() {
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 commiting a null buffer
layer_shell_surface.destroy();
}
event_queue.blocking_dispatch(&mut state)?;
event_queue.roundtrip(&mut state)?;

callback_result
}
Expand Down

0 comments on commit f0cd9f4

Please sign in to comment.