From 19e3ee8ff8c4d86a793fc5b8ffdfc2557fb4e7a3 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Fri, 12 Apr 2024 22:20:53 +0530 Subject: [PATCH 1/4] [fix] destroy layer_shell_surfaces instead of the layer_shell --- libwayshot/src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs index d0ec88ad..cd0aab2a 100644 --- a/libwayshot/src/lib.rs +++ b/libwayshot/src/lib.rs @@ -452,6 +452,8 @@ impl WayshotConnection { } }; + let mut layer_shell_surfaces = Vec::new(); + for (frame_copy, frame_guard, output_info) in frames { tracing::span!( tracing::Level::DEBUG, @@ -491,15 +493,21 @@ impl WayshotConnection { debug!("Committing surface with attached buffer."); surface.commit(); - + layer_shell_surfaces.push(layer_surface); event_queue.blocking_dispatch(&mut state)?; Ok(()) })?; } + let callback_result = callback(); - layer_shell.destroy(); + + debug!("Destroying layer shell surfaces."); + for layer_shell_surface in layer_shell_surfaces.into_iter() { + layer_shell_surface.destroy(); + } event_queue.blocking_dispatch(&mut state)?; + callback_result } From f0cd9f4009a8082ed4e28ed9b61334dc017e8e8b Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Sat, 13 Apr 2024 11:12:54 +0530 Subject: [PATCH 2/4] [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 } From 78f022baf6d1cc385a4126043d9fa243b0ca4dbb Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Sat, 13 Apr 2024 11:15:36 +0530 Subject: [PATCH 3/4] [style] correct a typo in the comments --- libwayshot/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs index bca52bce..f890c25c 100644 --- a/libwayshot/src/lib.rs +++ b/libwayshot/src/lib.rs @@ -505,7 +505,7 @@ impl WayshotConnection { 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 + surface.commit(); //unmap surface by committing a null buffer layer_shell_surface.destroy(); } event_queue.roundtrip(&mut state)?; From 069441f32667a3fd59493af017898fe5c4ae4f22 Mon Sep 17 00:00:00 2001 From: CheerfulPianissimo Date: Mon, 13 May 2024 10:20:54 +0530 Subject: [PATCH 4/4] [fix] initialize surface_layer vec with correct capacity --- libwayshot/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libwayshot/src/lib.rs b/libwayshot/src/lib.rs index f890c25c..9c52a811 100644 --- a/libwayshot/src/lib.rs +++ b/libwayshot/src/lib.rs @@ -452,7 +452,7 @@ impl WayshotConnection { } }; - let mut layer_shell_surfaces = Vec::new(); + let mut layer_shell_surfaces = Vec::with_capacity(frames.len()); for (frame_copy, frame_guard, output_info) in frames { tracing::span!(