From f0cd9f4009a8082ed4e28ed9b61334dc017e8e8b Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Sat, 13 Apr 2024 11:12:54 +0530 Subject: [PATCH] [fix] unmap layer shell surfaces before destroying them --- libwayshot/src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs index cd0aab2a..bca52bce 100644 --- a/libwayshot/src/lib.rs +++ b/libwayshot/src/lib.rs @@ -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(()) @@ -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 }