linux: Don't insert characters if modifiers other than shift are held (#33424)

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.
This commit is contained in:
Michael Sloan 2025-06-25 17:11:59 -06:00 committed by GitHub
parent b9f81c7ce7
commit dfdeb1bf51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 13 deletions

View file

@ -699,6 +699,7 @@ impl WaylandWindowStatePtr {
} }
} }
if let PlatformInput::KeyDown(event) = input { if let PlatformInput::KeyDown(event) = input {
if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) {
if let Some(key_char) = &event.keystroke.key_char { if let Some(key_char) = &event.keystroke.key_char {
let mut state = self.state.borrow_mut(); let mut state = self.state.borrow_mut();
if let Some(mut input_handler) = state.input_handler.take() { if let Some(mut input_handler) = state.input_handler.take() {
@ -709,6 +710,7 @@ impl WaylandWindowStatePtr {
} }
} }
} }
}
pub fn set_focused(&self, focus: bool) { pub fn set_focused(&self, focus: bool) {
self.state.borrow_mut().active = focus; self.state.borrow_mut().active = focus;

View file

@ -982,6 +982,8 @@ impl X11WindowStatePtr {
} }
} }
if let PlatformInput::KeyDown(event) = input { if let PlatformInput::KeyDown(event) = input {
// only allow shift modifier when inserting text
if event.keystroke.modifiers.is_subset_of(&Modifiers::shift()) {
let mut state = self.state.borrow_mut(); let mut state = self.state.borrow_mut();
if let Some(mut input_handler) = state.input_handler.take() { if let Some(mut input_handler) = state.input_handler.take() {
if let Some(key_char) = &event.keystroke.key_char { if let Some(key_char) = &event.keystroke.key_char {
@ -993,6 +995,7 @@ impl X11WindowStatePtr {
} }
} }
} }
}
pub fn handle_ime_commit(&self, text: String) { pub fn handle_ime_commit(&self, text: String) {
let mut state = self.state.borrow_mut(); let mut state = self.state.borrow_mut();