From ac77ab974a958f0f63cd23fc5c7014aebe1ec597 Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Wed, 22 Nov 2023 17:13:03 +0100 Subject: [PATCH] stack: Fix X11 order --- src/shell/element/stack.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/shell/element/stack.rs b/src/shell/element/stack.rs index 1a37f7a6..ac39f084 100644 --- a/src/shell/element/stack.rs +++ b/src/shell/element/stack.rs @@ -541,10 +541,28 @@ impl CosmicStack { ); let (window_elements, popup_elements) = self.0.with_program(|p| { - p.windows.lock().unwrap()[p.active.load(Ordering::SeqCst)] + let windows = p.windows.lock().unwrap(); + let active = p.active.load(Ordering::SeqCst); + + let (mut window_elements, popup_elements) = windows[active] .split_render_elements::>( renderer, window_loc, scale, alpha, - ) + ); + // preparing the other windows will fix their x11 stacking order. + // they won't actually be drawn, but discarded due to the overlap anyway, + // the performance impact is neglible. + for window in windows + .iter() + .enumerate() + .filter(|(i, _)| *i != active) + .map(|(_, w)| w) + { + let (elements, _) = + window.split_render_elements(renderer, window_loc, scale, alpha); + window_elements.extend(elements); + } + + (window_elements, popup_elements) }); (