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 {
162 pub seat: Seat<State>,162 pub seat: Seat<State>,
163 /// Scancodes of the keys to suppress.163 /// Scancodes of the keys to suppress.
164 pub suppressed_keys: HashSet<u32>,164 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>,
165 169
166 pub cursor_manager: CursorManager,170 pub cursor_manager: CursorManager,
167 pub cursor_texture_cache: CursorTextureCache,171 pub cursor_texture_cache: CursorTextureCache,
@@ -428,15 +432,14 @@ impl State {
428 };432 };
429 433
430 let keyboard = self.niri.seat.get_keyboard().unwrap();434 let keyboard = self.niri.seat.get_keyboard().unwrap();
431- let current_focus = keyboard.current_focus();435+ if self.niri.keyboard_focus != focus {
432- if current_focus != focus {
433 if self.niri.config.borrow().input.keyboard.track_layout == TrackLayout::Window {436 if self.niri.config.borrow().input.keyboard.track_layout == TrackLayout::Window {
434 let current_layout =437 let current_layout =
435 keyboard.with_xkb_state(self, |context| context.active_layout());438 keyboard.with_xkb_state(self, |context| context.active_layout());
436 439
437 let mut new_layout = current_layout;440 let mut new_layout = current_layout;
438 // Store the currently active layout for the surface.441 // 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() {
440 with_states(current_focus, |data| {443 with_states(current_focus, |data| {
441 let cell = data444 let cell = data
442 .data_map445 .data_map
@@ -463,6 +466,7 @@ impl State {
463 }466 }
464 }467 }
465 468
469+ self.niri.keyboard_focus = focus.clone();
466 keyboard.set_focus(self, focus, SERIAL_COUNTER.next_serial());470 keyboard.set_focus(self, focus, SERIAL_COUNTER.next_serial());
467 471
468 // FIXME: can be more granular.472 // FIXME: can be more granular.
@@ -783,6 +787,7 @@ impl Niri {
783 presentation_state,787 presentation_state,
784 788
785 seat,789 seat,
790+ keyboard_focus: None,
786 cursor_manager,791 cursor_manager,
787 cursor_texture_cache: Default::default(),792 cursor_texture_cache: Default::default(),
788 cursor_shape_manager_state,793 cursor_shape_manager_state,