forge
Explore
Log in

Don't you dare go Hollow

input: Forward not-allowed bound keys when locked

Browse files at this commit

b4789ddb3df7907738dd10cb477af529ee9426ecIvan MolodetskikhParent: 1c44128
Prevent the chance of being unable to type the password.
src/input/mod.rsmodified+12 -2
@@ -4969,6 +4969,16 @@ fn should_intercept_key<'a>(
49694969 return ShouldInterceptResult::Forward;
49704970 }
49714971
4972+ // If the bind is not allowed when locked, forward the key.
4973+ //
4974+ // This early return is not necessary to prevent the action from running because
4975+ // allow_when_locked is also checked in handle_bind() (this is required for key repeat).
4976+ // However, especially with the GlobalShortcuts portal, it's quite easy to bind single letter
4977+ // keys. This forward lets them work to type on the lock screen so the user isn't locked out.
4978+ if is_locked && !bind_allowed_when_locked(&bind, true) {
4979+ return ShouldInterceptResult::Forward;
4980+ }
4981+
49724982 // By default we intercept the key which hides both the press and release from clients.
49734983 // Clients still learn about the modifier state via `advertise_modifier_state()`.
49744984 //
@@ -6211,11 +6221,11 @@ mod tests {
62116221 let result = press_close_key(&mut state, &bindings, Modifiers::SUPER);
62126222
62136223 // `handle_bind()` drops the press while locked, and nothing is recorded to undo.
6214- assert_matches!(result, ShouldInterceptResult::InterceptAndHandle(_));
6224+ assert_matches!(result, ShouldInterceptResult::Forward);
62156225 assert!(state.pending_release_binds.is_empty());
62166226
62176227 let result = release_close_key(&mut state, &bindings, Modifiers::SUPER);
6218- assert_matches!(result, ShouldInterceptResult::InterceptOnly);
6228+ assert_matches!(result, ShouldInterceptResult::Forward);
62196229 }
62206230
62216231 #[test]