input: Forward not-allowed bound keys when locked
Browse files at this commitb4789ddb3df7907738dd10cb477af529ee9426ecParent: 1c441281 changed file +12 -2
- src/input/mod.rs +12 -2
src/input/mod.rsmodified+12 -2
| @@ -4969,6 +4969,16 @@ fn should_intercept_key<'a>( | |||
| 4969 | return ShouldInterceptResult::Forward; | 4969 | return ShouldInterceptResult::Forward; |
| 4970 | } | 4970 | } |
| 4971 | 4971 | ||
| 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 | + | ||
| 4972 | // By default we intercept the key which hides both the press and release from clients. | 4982 | // By default we intercept the key which hides both the press and release from clients. |
| 4973 | // Clients still learn about the modifier state via `advertise_modifier_state()`. | 4983 | // Clients still learn about the modifier state via `advertise_modifier_state()`. |
| 4974 | // | 4984 | // |
| @@ -6211,11 +6221,11 @@ mod tests { | |||
| 6211 | let result = press_close_key(&mut state, &bindings, Modifiers::SUPER); | 6221 | let result = press_close_key(&mut state, &bindings, Modifiers::SUPER); |
| 6212 | 6222 | ||
| 6213 | // `handle_bind()` drops the press while locked, and nothing is recorded to undo. | 6223 | // `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); |
| 6215 | assert!(state.pending_release_binds.is_empty()); | 6225 | assert!(state.pending_release_binds.is_empty()); |
| 6216 | 6226 | ||
| 6217 | let result = release_close_key(&mut state, &bindings, Modifiers::SUPER); | 6227 | let result = release_close_key(&mut state, &bindings, Modifiers::SUPER); |
| 6218 | - assert_matches!(result, ShouldInterceptResult::InterceptOnly); | 6228 | + assert_matches!(result, ShouldInterceptResult::Forward); |
| 6219 | } | 6229 | } |
| 6220 | 6230 | ||
| 6221 | #[test] | 6231 | #[test] |