From 47addfa53c3cc6b54550aace374c53aa2bffec0f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 15 Apr 2022 21:28:26 -0700 Subject: [PATCH] Ctrl-[ and Ctrl-Esc didn't send key_down until key_up Looking closer, I think I'd misread the key event generated by perform_key_equivalent for the ctrl-escape case as a key down. Fixing this is fairly straightforward: when we return YES from perform_key_equivalent we synthesize a key_down event. macos will follow up with the key up. We can fold two cases together in there and remove the horrible hack style fix I just added in a4b68247bbb5e88558f6b0b2a2c47840ca5e9d1d refs: https://github.com/wez/wezterm/issues/1877 --- window/src/os/macos/window.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index cf233a315..152397003 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -1998,10 +1998,7 @@ impl WindowView { // CTRL-Tab only delivers a key-up event, and never a // key-down event. So we just pretend that key-up is // key-down. - // Same for CTRL-[ - // - let key_is_down = if (virtual_key == super::keycodes::kVK_Tab - || virtual_key == super::keycodes::kVK_ANSI_LeftBracket) + let key_is_down = if virtual_key == super::keycodes::kVK_Tab && modifiers.contains(Modifiers::CTRL) && !key_is_down { @@ -2327,7 +2324,9 @@ impl WindowView { modifiers, ); - if chars == "." && modifiers == Modifiers::SUPER { + if (chars == "." && modifiers == Modifiers::SUPER) + || (chars == "\u{1b}" && modifiers == Modifiers::CTRL) + { // Synthesize a key down event for this, because macOS will // not do that, even though we tell it that we handled this event. // @@ -2335,12 +2334,6 @@ impl WindowView { // Prevent macOS from calling doCommandBySelector(cancel:) YES - } else if chars == "\u{1b}" && modifiers == Modifiers::CTRL { - // We don't need to synthesize a key down event for this, - // because macOS will do that once we return YES. - // We need to return YES to prevent macOS from calling - // doCommandBySelector(cancel:) on us. - YES } else { // Allow macOS to process built-in shortcuts like CMD-` // to cycle though windows