From 7abc12d262fe57f09aefddf3b73fefae6d50f319 Mon Sep 17 00:00:00 2001 From: sachahjkl Date: Thu, 12 Nov 2026 18:17:19 +0100 Subject: [PATCH 1/2] Clear the FIFO barriers of windows drawn on no output signal_post_repaint_barriers only cleared the wp_fifo_v1 barriers of windows drawn on the repainted output. A window the config hides (minimized, a hidden tab, a window hidden by its program) is drawn on none, so its barrier stayed set: a client that draws while hidden with a FIFO present mode then waited for it for good and froze (a clipboard manager redrawing after a copy). Such windows now have their barriers cleared at each output refresh. --- src/shojiwm_lib/src/presentation.rs | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/shojiwm_lib/src/presentation.rs b/src/shojiwm_lib/src/presentation.rs index 72cb9001f..c19ea8d07 100644 --- a/src/shojiwm_lib/src/presentation.rs +++ b/src/shojiwm_lib/src/presentation.rs @@ -1097,6 +1097,36 @@ impl ShojiWM { ); } }); + } else if !self + .space + .outputs() + .any(|other| self.window_frame_processing_applies_to_output(window, other)) + { + // Drawn on no output (minimized, a hidden tab, hidden by the config): its + // FIFO barriers are cleared at this output's refresh all the same. Left set, a + // client that draws while hidden (a FIFO present mode) waits for them for + // good and freezes. + window.with_surfaces(|surface, states| { + let fifo_barrier = states + .cached_state + .get::() + .current() + .barrier + .take(); + if let Some(fifo_barrier) = fifo_barrier { + if debug_fifo { + info!( + surface = ?surface.id(), + output = %output.name(), + "fifo barrier signaled for a window drawn on no output" + ); + } + fifo_barrier.signal(); + if let Some(client) = surface.client() { + clients.insert(client.id(), client); + } + } + }); } }); From 5a8c3859628e1a12f6f11ed366e3443ebd8e15f0 Mon Sep 17 00:00:00 2001 From: sachahjkl Date: Thu, 12 Nov 2026 18:33:33 +0100 Subject: [PATCH 2/2] Test: the FIFO barrier of a window drawn on no output is cleared at an output refresh --- src/shojiwm_rs/tests/fifo_hidden_window.rs | 121 +++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 src/shojiwm_rs/tests/fifo_hidden_window.rs diff --git a/src/shojiwm_rs/tests/fifo_hidden_window.rs b/src/shojiwm_rs/tests/fifo_hidden_window.rs new file mode 100644 index 000000000..70ad03c06 --- /dev/null +++ b/src/shojiwm_rs/tests/fifo_hidden_window.rs @@ -0,0 +1,121 @@ +//! A window the config hides is drawn on no output, yet its wp_fifo_v1 +//! barriers are still cleared at each output refresh. A FIFO-mode client +//! commits with set_barrier, then with wait_barrier: if the barrier is never +//! signaled, the second commit stays blocked and the client freezes. + +mod common; + +use shojiwm_rs::prelude::*; +use smithay::{ + desktop::Window as SpaceWindow, + reexports::wayland_server::{Resource, protocol::wl_surface::WlSurface as ServerSurface}, + wayland::compositor::{SurfaceAttributes, with_states}, +}; +use wayland_client::{ + Connection, Dispatch, Proxy, QueueHandle, + protocol::{wl_compositor, wl_region}, +}; +use wayland_protocols::wp::fifo::v1::client::{wp_fifo_manager_v1, wp_fifo_v1}; + +const SIZE: i32 = 200; + +/// Every window is kept mapped but hidden, as a minimized one. +fn setup() { + COMPOSITOR.window.composition(|_| { + ManagedWindow::new() + .rect(Rect::new(0.0, 0.0, SIZE as f64, SIZE as f64)) + .visible(false) + .child(ClientWindow::new()) + }); +} + +fn server_window(session: &common::Session, protocol_id: u32) -> SpaceWindow { + session + .state + .space + .elements() + .find(|window| { + window + .toplevel() + .is_some_and(|toplevel| toplevel.wl_surface().id().protocol_id() == protocol_id) + }) + .cloned() + .expect("the toplevel is not in the space") +} + +/// The opaque region stands for the content of the second commit: unlike the +/// buffer, which the commit handler takes, it stays in the current state. +fn has_opaque_region(surface: &ServerSurface) -> bool { + with_states(surface, |states| { + states + .cached_state + .get::() + .current() + .opaque_region + .is_some() + }) +} + +#[test] +fn fifo_barrier_of_a_hidden_window_is_cleared_at_output_refresh() { + let mut session = common::Session::new(setup); + let surface = session.map_toplevel_with_buffer("hidden", SIZE, SIZE); + // A frame re-reads the windows first; the config's `visible(false)` lands then. + session.state.refresh_window_decorations().unwrap(); + session.roundtrip(); + + let window = server_window(&session, surface.id().protocol_id()); + let server_surface = window.toplevel().unwrap().wl_surface().clone(); + assert!( + !session.state.window_allows_render(&window), + "the config must hide the window, else it is drawn and the old path clears it" + ); + + let qh = session.queue.handle(); + let fifo_manager: wp_fifo_manager_v1::WpFifoManagerV1 = session.bind("wp_fifo_manager_v1", 1); + let fifo = fifo_manager.get_fifo(&surface, &qh, ()); + let compositor: wl_compositor::WlCompositor = session.bind("wl_compositor", 1); + + // First content update: sets the barrier, waits for nothing, so it applies. + fifo.set_barrier(); + surface.commit(); + session.roundtrip(); + assert!(!has_opaque_region(&server_surface)); + + // Second content update: waits for the barrier of the first one. + let region = compositor.create_region(&qh, ()); + region.add(0, 0, SIZE, SIZE); + surface.set_opaque_region(Some(®ion)); + fifo.wait_barrier(); + surface.commit(); + session.roundtrip(); + // Without this, the test passes vacuously if some other path signals the barrier. + assert!( + !has_opaque_region(&server_surface), + "the second commit must be blocked until the barrier is signaled" + ); + + // What a backend does after each repaint of an output. + let output = session.state.space.outputs().next().cloned().unwrap(); + session.state.signal_post_repaint_barriers(&output); + session.roundtrip(); + + assert!( + has_opaque_region(&server_surface), + "the hidden window's FIFO barrier was not cleared: its commit stays blocked" + ); +} + +macro_rules! ignore_events { + ($($proxy:ty),*) => {$( + impl Dispatch<$proxy, ()> for common::Client { + fn event(_: &mut Self, _: &$proxy, _: <$proxy as Proxy>::Event, _: &(), _: &Connection, _: &QueueHandle) {} + } + )*}; +} + +ignore_events!( + wp_fifo_manager_v1::WpFifoManagerV1, + wp_fifo_v1::WpFifoV1, + wl_region::WlRegion +);