forge
Explore
Log in

Don't you dare go Hollow

layer_shell: Drop keyboard focus when surface switches to None

Browse files at this commit

7f81a7f77b0e93464645232bd15ba2dc43ca3782Ivan MolodetskikhParent: 94170eb
src/handlers/layer_shell.rsmodified+9 -0
@@ -178,6 +178,15 @@ impl State {
178178 // little annoying.
179179 self.niri.layer_shell_on_demand_focus = Some(layer.clone());
180180 }
181+
182+ // If a mapped surface switches from on-demand to none, drop its focus immediately,
183+ // because otherwise when a surface switches back and forth in a single event loop
184+ // cycle, the focus will never get dropped.
185+ let none = layer.cached_state().keyboard_interactivity
186+ == wlr_layer::KeyboardInteractivity::None;
187+ if none && self.niri.layer_shell_on_demand_focus.as_ref() == Some(layer) {
188+ self.niri.layer_shell_on_demand_focus = None;
189+ }
181190 } else {
182191 // The surface is unmapped.
183192 if self.niri.mapped_layer_surfaces.remove(layer).is_some() {
src/tests/layer_shell.rsmodified+1 -1
@@ -331,7 +331,7 @@ fn keyboard_interactivity_on_demand_to_none_then_on_demand() {
331331 layer.commit();
332332 f.double_roundtrip(id);
333333
334- assert_snapshot!(f.client(id).state.format_recent_keyboard_events(&surface), @"");
334+ assert_snapshot!(f.client(id).state.format_recent_keyboard_events(&surface), @"leave");
335335 }
336336
337337 #[test]