Allow held key events if key is modifier (#13000)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run

Release Notes:

- (Fixed) Allows held down key events for modifier keys.
([#12566](https://github.com/zed-industries/zed/issues/12566))

---------

Co-authored-by: Angelo <>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
Angelo.Mateus 2024-06-14 03:54:59 +01:00 committed by GitHub
parent a5af5b2883
commit 64bb79b71d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -335,7 +335,6 @@ struct MacWindowState {
input_handler: Option<PlatformInputHandler>, input_handler: Option<PlatformInputHandler>,
last_key_equivalent: Option<KeyDownEvent>, last_key_equivalent: Option<KeyDownEvent>,
synthetic_drag_counter: usize, synthetic_drag_counter: usize,
last_fresh_keydown: Option<Keystroke>,
traffic_light_position: Option<Point<Pixels>>, traffic_light_position: Option<Point<Pixels>>,
previous_modifiers_changed_event: Option<PlatformInput>, previous_modifiers_changed_event: Option<PlatformInput>,
// State tracking what the IME did after the last request // State tracking what the IME did after the last request
@ -615,7 +614,6 @@ impl MacWindow {
input_handler: None, input_handler: None,
last_key_equivalent: None, last_key_equivalent: None,
synthetic_drag_counter: 0, synthetic_drag_counter: 0,
last_fresh_keydown: None,
traffic_light_position: titlebar traffic_light_position: titlebar
.as_ref() .as_ref()
.and_then(|titlebar| titlebar.traffic_light_position), .and_then(|titlebar| titlebar.traffic_light_position),
@ -1219,15 +1217,6 @@ extern "C" fn handle_key_event(this: &Object, native_event: id, key_equivalent:
let keydown = event.keystroke.clone(); let keydown = event.keystroke.clone();
let fn_modifier = keydown.modifiers.function; let fn_modifier = keydown.modifiers.function;
// Ignore events from held-down keys after some of the initially-pressed keys
// were released.
if event.is_held {
if lock.last_fresh_keydown.as_ref() != Some(&keydown) {
return YES;
}
} else {
lock.last_fresh_keydown = Some(keydown.clone());
}
lock.last_ime_inputs = Some(Default::default()); lock.last_ime_inputs = Some(Default::default());
drop(lock); drop(lock);
@ -1439,7 +1428,6 @@ extern "C" fn cancel_operation(this: &Object, _sel: Sel, _sender: id) {
is_held: false, is_held: false,
}); });
lock.last_fresh_keydown = Some(keystroke);
if let Some(mut callback) = lock.event_callback.take() { if let Some(mut callback) = lock.event_callback.take() {
drop(lock); drop(lock);
callback(event); callback(event);