linux: Don't insert characters if modifiers other than shift are held (#33424)
Michael Sloan
created
Closes #32219 #29666
Release Notes:
- Linux: Now skips insertion of characters when modifiers are held. Before, characters were inserted if there's no match in the keymap.
@@ -982,14 +982,17 @@ impl X11WindowStatePtr {
}
}
if let PlatformInput::KeyDown(event) = input {
- let mut state = self.state.borrow_mut();- if let Some(mut input_handler) = state.input_handler.take() {- if let Some(key_char) = &event.keystroke.key_char {- drop(state);- input_handler.replace_text_in_range(None, key_char);- state = self.state.borrow_mut();
+ // only allow shift modifier when inserting text
+ if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) {
+ let mut state = self.state.borrow_mut();
+ if let Some(mut input_handler) = state.input_handler.take() {
+ if let Some(key_char) = &event.keystroke.key_char {
+ drop(state);
+ input_handler.replace_text_in_range(None, key_char);
+ state = self.state.borrow_mut();
+ }
+ state.input_handler = Some(input_handler);
}
- state.input_handler = Some(input_handler);
}
}
}