forge
Explore
Log in

Don't you dare go Hollow

Keep track of keyboard focus manually

Browse files at this commit

952ff029828a3f27fdc1ac456ffc3cdb98685b1aIvan MolodetskikhParent: e1adabe
src/niri.rsmodified+8 -3
@@ -162,6 +162,10 @@ pub struct Niri {
162162 pub seat: Seat<State>,
163163 /// Scancodes of the keys to suppress.
164164 pub suppressed_keys: HashSet<u32>,
165+ // This is always a toplevel surface focused as far as niri's logic is concerned, even when
166+ // popup grabs are active (which means the real keyboard focus is on a popup descending from
167+ // this toplevel surface).
168+ pub keyboard_focus: Option<WlSurface>,
165169
166170 pub cursor_manager: CursorManager,
167171 pub cursor_texture_cache: CursorTextureCache,
@@ -428,15 +432,14 @@ impl State {
428432 };
429433
430434 let keyboard = self.niri.seat.get_keyboard().unwrap();
431- let current_focus = keyboard.current_focus();
432- if current_focus != focus {
435+ if self.niri.keyboard_focus != focus {
433436 if self.niri.config.borrow().input.keyboard.track_layout == TrackLayout::Window {
434437 let current_layout =
435438 keyboard.with_xkb_state(self, |context| context.active_layout());
436439
437440 let mut new_layout = current_layout;
438441 // Store the currently active layout for the surface.
439- if let Some(current_focus) = current_focus.as_ref() {
442+ if let Some(current_focus) = self.niri.keyboard_focus.as_ref() {
440443 with_states(current_focus, |data| {
441444 let cell = data
442445 .data_map
@@ -463,6 +466,7 @@ impl State {
463466 }
464467 }
465468
469+ self.niri.keyboard_focus = focus.clone();
466470 keyboard.set_focus(self, focus, SERIAL_COUNTER.next_serial());
467471
468472 // FIXME: can be more granular.
@@ -783,6 +787,7 @@ impl Niri {
783787 presentation_state,
784788
785789 seat,
790+ keyboard_focus: None,
786791 cursor_manager,
787792 cursor_texture_cache: Default::default(),
788793 cursor_shape_manager_state,