@@ -7,14 +7,14 @@ use std::time::Duration;
77use calloop:: timer:: { TimeoutAction , Timer } ;
88use input:: event:: gesture:: GestureEventCoordinates as _;
99use niri_config:: {
10- Action , Bind , Binds , Config , Key , ModKey , Modifiers , MruDirection , SwitchBinds , Trigger , Xkb ,
10+ Action , Bind , Binds , Config , Key , ModKey , Modifiers , MruDirection , SwitchBinds , Trigger ,
1111} ;
1212use niri_ipc:: LayoutSwitchTarget ;
1313use smithay:: backend:: input:: {
1414 AbsolutePositionEvent , Axis , AxisSource , ButtonState , Device , DeviceCapability , Event ,
1515 GestureBeginEvent , GestureEndEvent , GesturePinchUpdateEvent as _, GestureSwipeUpdateEvent as _,
16- InputEvent , KeyState , KeyboardKeyEvent , Keycode , MouseButton , PointerAxisEvent ,
17- PointerButtonEvent , PointerMotionEvent , ProximityState , Switch , SwitchState , SwitchToggleEvent ,
16+ InputEvent , KeyState , KeyboardKeyEvent , MouseButton , PointerAxisEvent , PointerButtonEvent ,
17+ PointerMotionEvent , ProximityState , Switch , SwitchState , SwitchToggleEvent ,
1818 TabletToolButtonEvent , TabletToolEvent , TabletToolProximityEvent , TabletToolTipEvent ,
1919 TabletToolTipState , TouchEvent ,
2020} ;
@@ -48,7 +48,6 @@ use crate::dbus::freedesktop_a11y::KbMonBlock;
4848use crate :: layout:: scrolling:: ScrollDirection ;
4949use crate :: layout:: { ActivateWindow , LayoutElement as _} ;
5050use crate :: niri:: { CastTarget , PointerVisibility , State } ;
51- use crate :: protocols:: virtual_keyboard:: VirtualKeyboard ;
5251use crate :: ui:: mru:: { WindowMru , WindowMruUi } ;
5352use crate :: ui:: screenshot_ui:: ScreenshotUi ;
5453use crate :: utils:: spawning:: { spawn, spawn_sh} ;
@@ -368,29 +367,6 @@ impl State {
368367 ) where
369368 I :: Device : ' static ,
370369 {
371- // Reset the keymap when handling a physical keyboard after a virtual one.
372- if self . niri . reset_keymap {
373- let device = event. device ( ) ;
374- let is_virtual_keyboard = ( & device as & dyn Any )
375- . downcast_ref :: < VirtualKeyboard > ( )
376- . is_some ( ) ;
377- if !is_virtual_keyboard {
378- self . niri . reset_keymap = false ;
379-
380- let config = self . niri . config . borrow ( ) ;
381- let xkb_config = config. input . keyboard . xkb . clone ( ) ;
382- std:: mem:: drop ( config) ;
383-
384- if xkb_config != Xkb :: default ( ) {
385- self . set_xkb_config ( xkb_config. to_xkb_config ( ) ) ;
386- } else {
387- // Use locale1 settings if xkb config is unset.
388- let xkb = self . niri . xkb_from_locale1 . clone ( ) . unwrap_or_default ( ) ;
389- self . set_xkb_config ( xkb. to_xkb_config ( ) ) ;
390- }
391- }
392- }
393-
394370 let mod_key = self . backend . mod_key ( & self . niri . config . borrow ( ) ) ;
395371
396372 let serial = SERIAL_COUNTER . next_serial ( ) ;
@@ -448,7 +424,6 @@ impl State {
448424 serial,
449425 time,
450426 |this, mods, keysym| {
451- let key_code = event. key_code ( ) ;
452427 let modified = keysym. modified_sym ( ) ;
453428 let raw = keysym. raw_latin_sym_or_raw_current_sym ( ) ;
454429 let modifiers = modifiers_from_state ( * mods) ;
@@ -498,7 +473,7 @@ impl State {
498473 }
499474
500475 // Don't send this press to any clients.
501- this. niri . suppressed_keys . insert ( key_code ) ;
476+ this. niri . suppressed_keys . insert ( modified ) ;
502477 return FilterResult :: Intercept ( None ) ;
503478 }
504479
@@ -507,7 +482,7 @@ impl State {
507482 if this. niri . window_mru_ui . is_open ( ) && !pressed && modifiers. is_empty ( ) {
508483 this. do_action ( Action :: MruConfirm , false ) ;
509484
510- if this. niri . suppressed_keys . remove ( & key_code ) {
485+ if this. niri . suppressed_keys . remove ( & modified ) {
511486 return FilterResult :: Intercept ( None ) ;
512487 } else {
513488 return FilterResult :: Forward ;
@@ -525,7 +500,7 @@ impl State {
525500 . get_pointer ( )
526501 . unwrap ( )
527502 . unset_grab ( this, serial, time) ;
528- this. niri . suppressed_keys . insert ( key_code ) ;
503+ this. niri . suppressed_keys . insert ( modified ) ;
529504 return FilterResult :: Intercept ( None ) ;
530505 }
531506
@@ -542,7 +517,6 @@ impl State {
542517 & mut this. niri . suppressed_keys ,
543518 bindings,
544519 mod_key,
545- key_code,
546520 modified,
547521 raw,
548522 pressed,
@@ -558,7 +532,7 @@ impl State {
558532 if this. niri . keyboard_focus . is_overview ( ) && pressed {
559533 if let Some ( bind) = raw. and_then ( |raw| hardcoded_overview_bind ( raw, * mods) )
560534 {
561- this. niri . suppressed_keys . insert ( key_code ) ;
535+ this. niri . suppressed_keys . insert ( modified ) ;
562536 return FilterResult :: Intercept ( Some ( bind) ) ;
563537 }
564538 }
@@ -4329,10 +4303,9 @@ impl State {
43294303/// to them from being delivered.
43304304#[ allow( clippy:: too_many_arguments) ]
43314305fn should_intercept_key < ' a > (
4332- suppressed_keys : & mut HashSet < Keycode > ,
4306+ suppressed_keys : & mut HashSet < Keysym > ,
43334307 bindings : impl IntoIterator < Item = & ' a Bind > ,
43344308 mod_key : ModKey ,
4335- key_code : Keycode ,
43364309 modified : Keysym ,
43374310 raw : Option < Keysym > ,
43384311 pressed : bool ,
@@ -4344,7 +4317,7 @@ fn should_intercept_key<'a>(
43444317 // Actions are only triggered on presses, release of the key
43454318 // shouldn't try to intercept anything unless we have marked
43464319 // the key to suppress.
4347- if !pressed && !suppressed_keys. contains ( & key_code ) {
4320+ if !pressed && !suppressed_keys. contains ( & modified ) {
43484321 return FilterResult :: Forward ;
43494322 }
43504323
@@ -4395,7 +4368,7 @@ fn should_intercept_key<'a>(
43954368 if is_inhibiting_shortcuts && bind. allow_inhibiting {
43964369 FilterResult :: Forward
43974370 } else {
4398- suppressed_keys. insert ( key_code ) ;
4371+ suppressed_keys. insert ( modified ) ;
43994372 FilterResult :: Intercept ( Some ( bind) )
44004373 }
44014374 }
@@ -4405,7 +4378,7 @@ fn should_intercept_key<'a>(
44054378 // But we don't need to check for shortcuts inhibition here, because
44064379 // if it was inhibited on press (forwarded to the client), it wouldn't be suppressed,
44074380 // so the release would already have been forwarded at the start of this function.
4408- suppressed_keys. remove ( & key_code ) ;
4381+ suppressed_keys. remove ( & modified ) ;
44094382 FilterResult :: Intercept ( None )
44104383 }
44114384 ( None , true ) => FilterResult :: Forward ,
@@ -4466,7 +4439,6 @@ fn find_configured_bind<'a>(
44664439) -> Option < Bind > {
44674440 // Handle configured binds.
44684441 let mut modifiers = modifiers_from_state ( mods) ;
4469-
44704442 let mod_down = modifiers_from_state ( mods) . contains ( mod_key. to_modifiers ( ) ) ;
44714443 if mod_down {
44724444 modifiers |= Modifiers :: COMPOSITOR ;
@@ -5115,13 +5087,11 @@ mod tests {
51155087 // The key_code we pick is arbitrary, the only thing
51165088 // that matters is that they are different between cases.
51175089
5118- let close_key_code = Keycode :: from ( close_keysym. raw ( ) + 8u32 ) ;
5119- let close_key_event = |suppr : & mut HashSet < Keycode > , mods : ModifiersState , pressed| {
5090+ let close_key_event = |suppr : & mut HashSet < Keysym > , mods : ModifiersState , pressed| {
51205091 should_intercept_key (
51215092 suppr,
51225093 & bindings. 0 ,
51235094 comp_mod,
5124- close_key_code,
51255095 close_keysym,
51265096 Some ( close_keysym) ,
51275097 pressed,
@@ -5133,12 +5103,11 @@ mod tests {
51335103 } ;
51345104
51355105 // Key event with the code which can't trigger any action.
5136- let none_key_event = |suppr : & mut HashSet < Keycode > , mods : ModifiersState , pressed| {
5106+ let none_key_event = |suppr : & mut HashSet < Keysym > , mods : ModifiersState , pressed| {
51375107 should_intercept_key (
51385108 suppr,
51395109 & bindings. 0 ,
51405110 comp_mod,
5141- Keycode :: from ( Keysym :: l. raw ( ) + 8 ) ,
51425111 Keysym :: l,
51435112 Some ( Keysym :: l) ,
51445113 pressed,
@@ -5165,7 +5134,7 @@ mod tests {
51655134 ..
51665135 } ) )
51675136 ) ) ;
5168- assert ! ( suppressed_keys. contains( & close_key_code ) ) ;
5137+ assert ! ( suppressed_keys. contains( & close_keysym ) ) ;
51695138
51705139 let filter = close_key_event ( & mut suppressed_keys, mods, false ) ;
51715140 assert ! ( matches!( filter, FilterResult :: Intercept ( None ) ) ) ;
@@ -5266,7 +5235,7 @@ mod tests {
52665235 ..
52675236 } ) )
52685237 ) ) ;
5269- assert ! ( suppressed_keys. contains( & close_key_code ) ) ;
5238+ assert ! ( suppressed_keys. contains( & close_keysym ) ) ;
52705239
52715240 is_inhibiting_shortcuts. set ( true ) ;
52725241
0 commit comments