From 19ab1eb79258759e3ee0fef7017d259345b912e6 Mon Sep 17 00:00:00 2001 From: Sergei Surovtsev <97428129+stillonearth@users.noreply.github.com> Date: Tue, 22 Jul 2025 02:16:44 +0300 Subject: [PATCH] Fix an issue where xkb defined hotkeys for arrows would not work (#34823) Addresses https://github.com/zed-industries/zed/pull/34053#issuecomment-3096447601 where custom-defined arrows would stop working in Zed. How to reproduce: 1. Define custom keyboard layout ```bash cd /usr/share/X11/xkb/symbols/ sudo nano mykbd ``` ``` default partial alphanumeric_keys xkb_symbols "custom" { name[Group1]= "Custom Layout"; key { [ q, Q, Escape, Escape ] }; key { [ w, W, Home, Home ] }; key { [ e, E, Up, Up ] }; key { [ r, R, End, End ] }; key { [ t, T, Tab, Tab ] }; key { [ a, A, Return, Return ] }; key { [ s, S, Left, Left ] }; key { [ d, D, Down, Down ] }; key { [ f, F, Right, Right ] }; key { [ g, G, BackSpace, BackSpace ] }; // include a base layout to inherit the rest include "us(basic)" }; ``` 2. Activate custom layout with win-key as AltGr ```bash setxkbmap mykbd -variant custom -option lv3:win_switch ``` 3. Now Win-S should produce left arrow, Win-F right arrow 4. Test whether it works in Zed Release Notes: - linux: xkb-defined hotkeys for arrow keys should behave as expected. --------- Co-authored-by: Conrad Irwin --- crates/gpui/src/platform/linux/platform.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index a52841e1af..d65118e994 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -828,6 +828,13 @@ impl crate::Keystroke { Keysym::Delete => "delete".to_owned(), Keysym::Escape => "escape".to_owned(), + Keysym::Left => "left".to_owned(), + Keysym::Right => "right".to_owned(), + Keysym::Up => "up".to_owned(), + Keysym::Down => "down".to_owned(), + Keysym::Home => "home".to_owned(), + Keysym::End => "end".to_owned(), + _ => { let name = xkb::keysym_get_name(key_sym).to_lowercase(); if key_sym.is_keypad_key() {