1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-19 02:37:51 +03:00

xkeyboard: resolve ambiguous CTRL-i / CTRL-Tab

We want to avoid normalizing control key presses; there were
two places where it was happening; one in our own code and
the other was in the xkeyboard mapping stuff itself.

refs: https://github.com/wez/wezterm/issues/1851
This commit is contained in:
Wez Furlong 2022-04-15 07:27:01 -07:00
parent 88601f6841
commit fdb3471017
3 changed files with 13 additions and 3 deletions

View File

@ -17,6 +17,7 @@ As features stabilize some brief notes about them will accumulate here.
* Flush after replying to XTGETTCAP. [#1850](https://github.com/wez/wezterm/issues/1850) * Flush after replying to XTGETTCAP. [#1850](https://github.com/wez/wezterm/issues/1850)
* macOS: CMD-. was treated as CTRL-ESC [#1867](https://github.com/wez/wezterm/issues/1867) * macOS: CMD-. was treated as CTRL-ESC [#1867](https://github.com/wez/wezterm/issues/1867)
* `nf-mdi-contacts` nerdfont symbol treated as zero-width [#1864](https://github.com/wez/wezterm/issues/1864) * `nf-mdi-contacts` nerdfont symbol treated as zero-width [#1864](https://github.com/wez/wezterm/issues/1864)
* X11/Wayland: CTRL-i, CTRL-j, CTRL-m misinterpreted as CTRL-Tab, CTRL-Enter, CTRL-Return [#1851](https://github.com/wez/wezterm/issues/1851)
### 20220408-101518-b908e2dd ### 20220408-101518-b908e2dd

View File

@ -1041,7 +1041,7 @@ fn normalize_shift(key: KeyCode, modifiers: Modifiers) -> (KeyCode, Modifiers) {
fn normalize_ctrl(key: KeyCode, modifiers: Modifiers) -> (KeyCode, Modifiers) { fn normalize_ctrl(key: KeyCode, modifiers: Modifiers) -> (KeyCode, Modifiers) {
if modifiers.contains(Modifiers::CTRL) { if modifiers.contains(Modifiers::CTRL) {
if let KeyCode::Char(c) = key { if let KeyCode::Char(c) = key {
if c != '\t' && (c as u32) < 0x20 { if (c as u32) < 0x20 {
let de_ctrl = ((c as u8) | 0x40) as char; let de_ctrl = ((c as u8) | 0x40) as char;
return (KeyCode::Char(de_ctrl.to_ascii_lowercase()), modifiers); return (KeyCode::Char(de_ctrl.to_ascii_lowercase()), modifiers);
} }

View File

@ -107,7 +107,17 @@ impl Compose {
} }
ComposeStatus::Nothing => { ComposeStatus::Nothing => {
let utf8 = key_state.borrow().key_get_utf8(xcode); let utf8 = key_state.borrow().key_get_utf8(xcode);
FeedResult::Nothing(utf8, xsym) // CTRL-<ALPHA> is helpfully encoded in the form that we would
// send to the terminal, however, we do want the chance to
// distinguish between eg: CTRL-i and Tab, so if we ended up
// with a control code representation from the xkeyboard layer,
// discard it.
// <https://github.com/wez/wezterm/issues/1851>
if utf8.len() == 1 && utf8.as_bytes()[0] < 0x20 {
FeedResult::Nothing(String::new(), xsym)
} else {
FeedResult::Nothing(utf8, xsym)
}
} }
ComposeStatus::Cancelled => { ComposeStatus::Cancelled => {
self.state.reset(); self.state.reset();
@ -375,7 +385,6 @@ impl Keyboard {
key_is_down: pressed, key_is_down: pressed,
raw: Some(raw_key_event), raw: Some(raw_key_event),
} }
.normalize_ctrl()
.normalize_shift(); .normalize_shift();
if pressed && want_repeat { if pressed && want_repeat {