From aabf1cdc08c844ca05339f53fe6c2d56aeeaf59a Mon Sep 17 00:00:00 2001 From: Hojjat Date: Thu, 16 Jul 2026 15:58:54 -0600 Subject: [PATCH] fix: flicker on wayland context menu pop up fix --- src/shell/layout/tiling/mod.rs | 24 ++++++++++++++++-------- src/shell/workspace.rs | 11 +++++++++++ 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index 67bf947f..65e901cb 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -4013,6 +4013,7 @@ impl TilingLayout { &self, renderer: &mut R, seat: Option<&Seat>, + focused: Option<&CosmicMapped>, non_exclusive_zone: Rectangle, overview: (OverviewMode, Option<(SwapIndicator, Option<&Tree>)>), resize_indicator: Option<(ResizeMode, ResizeIndicator)>, @@ -4143,6 +4144,7 @@ impl TilingLayout { old_geometries, is_overview, seat, + focused, &self.output, percentage, draw_groups, @@ -5276,6 +5278,7 @@ fn render_new_tree_windows( old_geometries: Option>>, is_overview: bool, seat: Option<&Seat>, + focused: Option<&CosmicMapped>, output: &Output, percentage: f32, transition: Option, @@ -5295,14 +5298,19 @@ fn render_new_tree_windows( CosmicWindowRenderElement: RenderElement, CosmicStackRenderElement: RenderElement, { - let focused = seat - .and_then(|seat| { - seat.get_keyboard() - .unwrap() - .current_focus() - .and_then(|target| TilingLayout::currently_focused_node(target_tree, target)) - }) - .map(|(id, _)| id); + let focused = match seat.and_then(|seat| seat.get_keyboard().unwrap().current_focus()) { + Some(target @ KeyboardFocusTarget::Group(_)) => { + TilingLayout::currently_focused_node(target_tree, target).map(|(id, _)| id) + } + _ => focused.and_then(|mapped| { + let node_id = mapped.tiling_node_id.lock().unwrap().clone()?; + target_tree + .get(&node_id) + .ok() + .filter(|node| node.data().is_mapped(Some(mapped))) + .map(|_| node_id) + }), + }; let focused_geo = if let Some(focused) = focused.as_ref() { geometries .as_ref() diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index e771e502..0cc0a407 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -1799,6 +1799,17 @@ impl Workspace { self.tiling_layer.render( renderer, render_focus.then_some(last_active_seat), + render_focus + .then(|| { + focused.as_ref().and_then(|target| { + if let FocusTarget::Window(mapped) = target { + Some(mapped) + } else { + None + } + }) + }) + .flatten(), zone, overview, resize_indicator,