From 2976b99b149e8f15e52d96b0540ed154dc33cd41 Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Thu, 22 May 2025 14:37:06 +0800 Subject: [PATCH] update group --- 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(-) diff --git a/crates/gpui/src/platform/linux/keyboard.rs b/crates/gpui/src/platform/linux/keyboard.rs index 45041c69723fde6d2d3bc1d815c5ecfca53c581e..990967f6c59d6922f4f40e697e4d54b9c52926a6 100644 --- a/crates/gpui/src/platform/linux/keyboard.rs +++ b/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) -> 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; diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 32b4f1bbeb87365a4a8239baf46252346c1bfffd..78ac8ae79b84c1b488967534e953523f207b9f02 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -1220,7 +1220,7 @@ impl Dispatch 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(); diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index a01df9da6735fb5e871f61a63c4c6ab0a4c40432..5f971eeecf8d2e730e3cda8160e8702670446132 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/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