diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-12 17:14:18 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-01-12 17:14:18 +0400 |
| commit | 952ff029828a3f27fdc1ac456ffc3cdb98685b1a (patch) | |
| tree | 453b536c662eb4d32e58b16c7686734ffce3c623 | |
| parent | e1adabed2d7ec67c21703a8672a0d2ee84ec3238 (diff) | |
| download | niri-952ff029828a3f27fdc1ac456ffc3cdb98685b1a.tar.gz niri-952ff029828a3f27fdc1ac456ffc3cdb98685b1a.tar.bz2 niri-952ff029828a3f27fdc1ac456ffc3cdb98685b1a.zip | |
Keep track of keyboard focus manually
| -rw-r--r-- | src/niri.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/niri.rs b/src/niri.rs index cbbfcc29..78679146 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -162,6 +162,10 @@ pub struct Niri { pub seat: Seat<State>, /// Scancodes of the keys to suppress. pub suppressed_keys: HashSet<u32>, + // This is always a toplevel surface focused as far as niri's logic is concerned, even when + // popup grabs are active (which means the real keyboard focus is on a popup descending from + // this toplevel surface). + pub keyboard_focus: Option<WlSurface>, pub cursor_manager: CursorManager, pub cursor_texture_cache: CursorTextureCache, @@ -428,15 +432,14 @@ impl State { }; let keyboard = self.niri.seat.get_keyboard().unwrap(); - let current_focus = keyboard.current_focus(); - if current_focus != focus { + if self.niri.keyboard_focus != focus { if self.niri.config.borrow().input.keyboard.track_layout == TrackLayout::Window { let current_layout = keyboard.with_xkb_state(self, |context| context.active_layout()); let mut new_layout = current_layout; // Store the currently active layout for the surface. - if let Some(current_focus) = current_focus.as_ref() { + if let Some(current_focus) = self.niri.keyboard_focus.as_ref() { with_states(current_focus, |data| { let cell = data .data_map @@ -463,6 +466,7 @@ impl State { } } + self.niri.keyboard_focus = focus.clone(); keyboard.set_focus(self, focus, SERIAL_COUNTER.next_serial()); // FIXME: can be more granular. @@ -783,6 +787,7 @@ impl Niri { presentation_state, seat, + keyboard_focus: None, cursor_manager, cursor_texture_cache: Default::default(), cursor_shape_manager_state, |
