update group

Junkui Zhang created

Change summary

crates/gpui/src/platform/linux/keyboard.rs       | 11 ++++++++---
crates/gpui/src/platform/linux/wayland/client.rs |  2 +-
crates/gpui/src/platform/linux/x11/client.rs     |  2 +-
3 files changed, 10 insertions(+), 5 deletions(-)

Detailed changes

crates/gpui/src/platform/linux/keyboard.rs 🔗

@@ -49,7 +49,7 @@ pub(crate) struct LinuxKeyboardMapper {
 
 #[cfg(any(feature = "wayland", feature = "x11"))]
 impl LinuxKeyboardMapper {
-    pub(crate) fn new() -> Self {
+    pub(crate) fn new(group: Option<u32>) -> Self {
         let _ = XCB_CONNECTION
             .xkb_use_extension(XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION)
             .unwrap()
@@ -57,7 +57,7 @@ impl LinuxKeyboardMapper {
             .unwrap();
         let xkb_context = xkbcommon::xkb::Context::new(xkbcommon::xkb::CONTEXT_NO_FLAGS);
         let xkb_device_id = xkbcommon::xkb::x11::get_core_keyboard_device_id(&*XCB_CONNECTION);
-        let xkb_state = {
+        let mut xkb_state = {
             let xkb_keymap = xkbcommon::xkb::x11::keymap_new_from_device(
                 &xkb_context,
                 &*XCB_CONNECTION,
@@ -78,6 +78,11 @@ impl LinuxKeyboardMapper {
         let shift_mask = 1 << shift_mod;
         shifted_state.update_mask(shift_mask, 0, 0, 0, 0, 0);
 
+        if let Some(group) = group {
+            xkb_state.update_mask(0, 0, 0, 0, 0, group);
+            shifted_state.update_mask(0, 0, 0, 0, 0, group);
+        }
+
         for scan_code in LinuxScanCodes::iter() {
             let keycode = Keycode::new(scan_code as u32);
 
@@ -445,7 +450,7 @@ mod tests {
 
     #[test]
     fn test_us_layout_mapper() {
-        let mapper = LinuxKeyboardMapper::new();
+        let mapper = LinuxKeyboardMapper::new(None);
         for scan_code in super::LinuxScanCodes::iter() {
             if scan_code == LinuxScanCodes::IntlBackslash || scan_code == LinuxScanCodes::IntlRo {
                 continue;

crates/gpui/src/platform/linux/wayland/client.rs 🔗

@@ -1220,7 +1220,7 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for WaylandClientStatePtr {
                 };
                 state.keymap_state = Some(xkb::State::new(&keymap));
                 state.compose_state = get_xkb_compose_state(&xkb_context);
-                state.keyboard_mapper = Some(LinuxKeyboardMapper::new());
+                state.keyboard_mapper = Some(LinuxKeyboardMapper::new(None));
                 drop(state);
 
                 this.handle_keyboard_layout_change();

crates/gpui/src/platform/linux/x11/client.rs 🔗

@@ -982,7 +982,7 @@ impl X11Client {
                 state.xkb = xkb_state;
                 drop(state);
                 self.handle_keyboard_layout_change();
-                state.keyboard_mapper = LinuxKeyboardMapper::new();
+                state.keyboard_mapper = LinuxKeyboardMapper::new(None);
                 let layout_idx = state.xkb.serialize_layout(STATE_LAYOUT_EFFECTIVE);
                 let layout = LinuxKeyboardLayout::new(
                     state