diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index fe995a22427c35478ad92fb20f295846f966374a..423e13b52073b75b8fc91e744aafbf5feda1d851 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -61,9 +61,7 @@ use wayland_protocols::xdg::decoration::zv1::client::{ }; use wayland_protocols::xdg::shell::client::{xdg_surface, xdg_toplevel, xdg_wm_base}; use wayland_protocols_plasma::blur::client::{org_kde_kwin_blur, org_kde_kwin_blur_manager}; -use xkbcommon::xkb::{ - self, KEYMAP_COMPILE_NO_FLAGS, Keycode, State, ffi::XKB_KEYMAP_FORMAT_TEXT_V1, -}; +use xkbcommon::xkb::{self, KEYMAP_COMPILE_NO_FLAGS, ffi::XKB_KEYMAP_FORMAT_TEXT_V1}; use super::{ display::WaylandDisplay, @@ -76,8 +74,7 @@ use crate::{ LinuxKeyboardLayout, LinuxKeyboardMapper, Modifiers, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseExitEvent, MouseMoveEvent, MouseUpEvent, NavigationDirection, Pixels, PlatformDisplay, PlatformInput, PlatformKeyboardLayout, Point, SCROLL_LINES, ScaledPixels, - ScrollDelta, ScrollWheelEvent, Size, TouchPhase, WindowParams, point, px, - size, + ScrollDelta, ScrollWheelEvent, Size, TouchPhase, WindowParams, point, px, size, }; use crate::{ SharedString, @@ -213,7 +210,7 @@ pub(crate) struct WaylandClientState { // Output to scale mapping outputs: HashMap, in_progress_outputs: HashMap, - keymap_state: Option, + keymap_state: Option, compose_state: Option, keyboard_layout: LinuxKeyboardLayout, keyboard_mapper: Option>, @@ -347,7 +344,7 @@ impl WaylandClientStatePtr { text_input.commit(); } - pub fn handle_keyboard_layout_change(&self) { + pub fn handle_keyboard_layout_change(&self, locked_group: u32) { let client = self.get_client(); let mut state = client.borrow_mut(); let changed = if let Some(keymap_state) = &state.keymap_state { @@ -360,7 +357,12 @@ impl WaylandClientStatePtr { let mapper = state .keyboard_mapper_cache .entry(layout_name.to_string()) - .or_insert(Rc::new(LinuxKeyboardMapper::new(&keymap, 0, 0, 0))) + .or_insert(Rc::new(LinuxKeyboardMapper::new( + &keymap, + 0, + 0, + locked_group, + ))) .clone(); state.keyboard_mapper = Some(mapper); } @@ -1230,7 +1232,7 @@ impl Dispatch for WaylandClientStatePtr { state.compose_state = get_xkb_compose_state(&xkb_context); drop(state); - this.handle_keyboard_layout_change(); + this.handle_keyboard_layout_change(0); } wl_keyboard::Event::Enter { surface, .. } => { state.keyboard_focused_window = get_window(&mut state, &surface.id()); @@ -1286,7 +1288,7 @@ impl Dispatch for WaylandClientStatePtr { } if group != old_layout { - this.handle_keyboard_layout_change(); + this.handle_keyboard_layout_change(group); } } wl_keyboard::Event::Key { @@ -1305,7 +1307,7 @@ impl Dispatch for WaylandClientStatePtr { let keymap_state = state.keymap_state.as_ref().unwrap(); let keyboard_mapper = state.keyboard_mapper.as_ref().unwrap(); - let keycode = Keycode::from(key + MIN_KEYCODE); + let keycode = xkb::Keycode::from(key + MIN_KEYCODE); let keysym = keymap_state.key_get_one_sym(keycode); match key_state { diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 827cb0eb7003d99f32bd91aa9e2a9703e68572b8..b958eeebf8c170e242e1ee40dd74d64f6d1a6879 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -1,8 +1,3 @@ -use crate::{ - LinuxKeyboardMapper, - platform::{Capslock, xcb_flush}, - underlying_dead_key, -}; use core::str; use std::{ cell::RefCell, @@ -42,7 +37,7 @@ use x11rb::{ }; use xim::{AttributeName, Client, InputStyle, x11rb::X11rbClient}; use xkbc::x11::ffi::{XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION}; -use xkbcommon::xkb::{self as xkbc, LayoutIndex, ModMask, STATE_LAYOUT_EFFECTIVE, State}; +use xkbcommon::xkb::{self as xkbc, LayoutIndex, ModMask, STATE_LAYOUT_EFFECTIVE}; use super::{ ButtonOrScroll, ScrollDirection, X11Display, X11WindowStatePtr, XcbAtoms, XimCallbackEvent, @@ -53,7 +48,7 @@ use super::{ }; use crate::platform::{ - LinuxCommon, PlatformWindow, + Capslock, LinuxCommon, PlatformWindow, blade::BladeContext, linux::{ DEFAULT_CURSOR_ICON_NAME, LinuxClient, get_xkb_compose_state, is_within_click_distance, @@ -62,13 +57,14 @@ use crate::platform::{ reveal_path_internal, xdg_desktop_portal::{Event as XDPEvent, XDPEventSource}, }, + xcb_flush, }; use crate::{ AnyWindowHandle, Bounds, ClipboardItem, CursorStyle, DisplayId, FileDropEvent, Keystroke, - LinuxKeyboardLayout, Modifiers, ModifiersChangedEvent, MouseButton, Pixels, Platform, - PlatformDisplay, PlatformInput, PlatformKeyboardLayout, Point, RequestFrameOptions, - ScaledPixels, ScrollDelta, Size, TouchPhase, WindowParams, X11Window, - modifiers_from_xinput_info, point, px, + LinuxKeyboardLayout, LinuxKeyboardMapper, Modifiers, ModifiersChangedEvent, MouseButton, + Pixels, Platform, PlatformDisplay, PlatformInput, PlatformKeyboardLayout, Point, + RequestFrameOptions, ScaledPixels, ScrollDelta, Size, TouchPhase, WindowParams, X11Window, + modifiers_from_xinput_info, point, px, underlying_dead_key, }; /// Value for DeviceId parameters which selects all devices.