layer_shell: Drop keyboard focus when surface switches to None
Browse files at this commit7f81a7f77b0e93464645232bd15ba2dc43ca3782Parent: 94170eb2 changed files +10 -1
src/handlers/layer_shell.rsmodified+9 -0
| @@ -178,6 +178,15 @@ impl State { | ||
| 178 | 178 | // little annoying. |
| 179 | 179 | self.niri.layer_shell_on_demand_focus = Some(layer.clone()); |
| 180 | 180 | } |
| 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 | + } | |
| 181 | 190 | } else { |
| 182 | 191 | // The surface is unmapped. |
| 183 | 192 | 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() { | ||
| 331 | 331 | layer.commit(); |
| 332 | 332 | f.double_roundtrip(id); |
| 333 | 333 | |
| 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"); | |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | #[test] |