From d1c2257bd8aeafe1b7b87912354e4142a7d4d6ca Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Thu, 30 Mar 2023 21:49:48 -0700 Subject: [PATCH] macos: fix CTRL key behavior when use_ime=true refs: https://github.com/wez/wezterm/pull/2435 refs: https://github.com/wez/wezterm/issues/2771 refs: https://github.com/wez/wezterm/issues/2630 --- config/src/config.rs | 10 ++++++++ docs/changelog.md | 8 +++++++ .../macos_forward_to_ime_modifier_mask.md | 24 +++++++++++++++++++ window/src/os/macos/window.rs | 3 ++- 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 docs/config/lua/config/macos_forward_to_ime_modifier_mask.md diff --git a/config/src/config.rs b/config/src/config.rs index f98bc45f8..b85cccc13 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -387,6 +387,9 @@ pub struct Config { #[dynamic(default = "default_true")] pub send_composed_key_when_right_alt_is_pressed: bool, + #[dynamic(default = "default_macos_forward_mods")] + pub macos_forward_to_ime_modifier_mask: Modifiers, + #[dynamic(default)] pub treat_left_ctrlalt_as_altgr: bool, @@ -1909,3 +1912,10 @@ pub(crate) fn validate_domain_name(name: &str) -> Result<(), String> { Ok(()) } } + +/// +/// +/// +fn default_macos_forward_mods() -> Modifiers { + Modifiers::SHIFT +} diff --git a/docs/changelog.md b/docs/changelog.md index 47e199a0c..dacde0851 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -21,6 +21,13 @@ usually the best available version. As features stabilize some brief notes about them will accumulate here. +#### Changed +* macOS: Japanese IME users: CTRL-modified keys are no long routed to the IME + by default, as it introduced problems with CTRL-key combinations for other users. + A new [macos_forward_to_ime_modifier_mask](config/lua/config/macos_forward_to_ime_modifier_mask.md) + option has been introduced to allow you to control which modifier keys get routed + to the IME, so that you can opt back in to that behavior. #2630 #2771 #2435 + #### New * [pane:activate()](config/lua/pane/activate.md) and [tab:activate()](config/lua/MuxTab/activate.md). #3217 * [ulimit_nofile](config/lua/config/ulimit_nofile.md) and [ulimint_nproc](config/lua/config/ulimit_nproc.md) options. ?3353 @@ -46,6 +53,7 @@ As features stabilize some brief notes about them will accumulate here. respect to the dispatch of the assignment. #3405 * [window:perform_action()](config/lua/window/perform_action.md) now correctly resolves overlay panes such as Copy Mode. #3209 +* macOS: CTRL-Q had to be pressed twice to register when `use_ime=true`. #2630 ### 20230326-111934-3666303c diff --git a/docs/config/lua/config/macos_forward_to_ime_modifier_mask.md b/docs/config/lua/config/macos_forward_to_ime_modifier_mask.md new file mode 100644 index 000000000..2c40df954 --- /dev/null +++ b/docs/config/lua/config/macos_forward_to_ime_modifier_mask.md @@ -0,0 +1,24 @@ +# `macos_forward_to_ime_modifier_mask = "SHIFT"` + +{{since('nightly')}} + +On macOS systems, this option controls whether modified key presses are +routed via the IME when [use_ime = true](use_ime.md). + +When processing a key event, if any modifiers are held, if the modifiers +intersect with the value of `macos_forward_to_ime_modifier_mask`, then the key +event is routed to the IME, which may choose to swallow the key event as +part of its own state management. + +The behavior of wezterm has varied in the past: + +|Version |Effective Setting| +|-------------------------------------|-----------------| +|20220905-102802-7d4b8249 and earlier | "SHIFT" | +|20221119-145034-49b9839f | "SHIFT|CTRL" | +|nightly | "SHIFT" | + +Users of a Japanese IME may wish to set this to `"SHIFT|CTRL"`, +but should note that it will prevent certain CTRL key combinations +that are commonly used in unix terminal programs from working as +expected. diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index f81a816db..cef939dc1 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -2384,7 +2384,8 @@ impl WindowView { } else if only_right_alt && !send_composed_key_when_right_alt_is_pressed { false } else { - true + modifiers.is_empty() + || modifiers.intersects(config_handle.macos_forward_to_ime_modifier_mask) } };