From e9649dc25caad0a5fabd801541cd57b71f376206 Mon Sep 17 00:00:00 2001 From: Junkui Zhang <364772080@qq.com> Date: Wed, 21 May 2025 17:38:27 +0800 Subject: [PATCH] fix --- crates/gpui/src/platform/linux/platform.rs | 59 ------------------- .../gpui/src/platform/linux/wayland/client.rs | 9 ++- crates/gpui/src/platform/linux/x11/client.rs | 8 +-- 3 files changed, 10 insertions(+), 66 deletions(-) diff --git a/crates/gpui/src/platform/linux/platform.rs b/crates/gpui/src/platform/linux/platform.rs index c47e63f422a21f517219f8bc9d9dfd2daec97f6a..f257a065a7b852f60812951fb00806347a339c61 100644 --- a/crates/gpui/src/platform/linux/platform.rs +++ b/crates/gpui/src/platform/linux/platform.rs @@ -807,65 +807,6 @@ impl crate::Keystroke { key_char, } } - - /** - * Returns which symbol the dead key represents - * - */ - pub fn underlying_dead_key(keysym: Keysym) -> Option { - match keysym { - Keysym::dead_grave => Some("`".to_owned()), - Keysym::dead_acute => Some("´".to_owned()), - Keysym::dead_circumflex => Some("^".to_owned()), - Keysym::dead_tilde => Some("~".to_owned()), - Keysym::dead_macron => Some("¯".to_owned()), - Keysym::dead_breve => Some("˘".to_owned()), - Keysym::dead_abovedot => Some("˙".to_owned()), - Keysym::dead_diaeresis => Some("¨".to_owned()), - Keysym::dead_abovering => Some("˚".to_owned()), - Keysym::dead_doubleacute => Some("˝".to_owned()), - Keysym::dead_caron => Some("ˇ".to_owned()), - Keysym::dead_cedilla => Some("¸".to_owned()), - Keysym::dead_ogonek => Some("˛".to_owned()), - Keysym::dead_iota => Some("ͅ".to_owned()), - Keysym::dead_voiced_sound => Some("゙".to_owned()), - Keysym::dead_semivoiced_sound => Some("゚".to_owned()), - Keysym::dead_belowdot => Some("̣̣".to_owned()), - Keysym::dead_hook => Some("̡".to_owned()), - Keysym::dead_horn => Some("̛".to_owned()), - Keysym::dead_stroke => Some("̶̶".to_owned()), - Keysym::dead_abovecomma => Some("̓̓".to_owned()), - Keysym::dead_abovereversedcomma => Some("ʽ".to_owned()), - Keysym::dead_doublegrave => Some("̏".to_owned()), - Keysym::dead_belowring => Some("˳".to_owned()), - Keysym::dead_belowmacron => Some("̱".to_owned()), - Keysym::dead_belowcircumflex => Some("ꞈ".to_owned()), - Keysym::dead_belowtilde => Some("̰".to_owned()), - Keysym::dead_belowbreve => Some("̮".to_owned()), - Keysym::dead_belowdiaeresis => Some("̤".to_owned()), - Keysym::dead_invertedbreve => Some("̯".to_owned()), - Keysym::dead_belowcomma => Some("̦".to_owned()), - Keysym::dead_currency => None, - Keysym::dead_lowline => None, - Keysym::dead_aboveverticalline => None, - Keysym::dead_belowverticalline => None, - Keysym::dead_longsolidusoverlay => None, - Keysym::dead_a => None, - Keysym::dead_A => None, - Keysym::dead_e => None, - Keysym::dead_E => None, - Keysym::dead_i => None, - Keysym::dead_I => None, - Keysym::dead_o => None, - Keysym::dead_O => None, - Keysym::dead_u => None, - Keysym::dead_U => None, - Keysym::dead_small_schwa => Some("ə".to_owned()), - Keysym::dead_capital_schwa => Some("Ə".to_owned()), - Keysym::dead_greek => None, - _ => None, - } - } } #[cfg(any(feature = "wayland", feature = "x11"))] diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 0b88ee829a93a949c1b2f021e33943384c4d1613..ec696dd884d23cd29fda8f40746dfd2acb91ccd1 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -69,7 +69,6 @@ use super::{ window::{ImeInput, WaylandWindowStatePtr}, }; -use crate::platform::{PlatformWindow, blade::BladeContext}; use crate::{ AnyWindowHandle, Bounds, Capslock, CursorStyle, DOUBLE_CLICK_INTERVAL, DevicePixels, DisplayId, FileDropEvent, ForegroundExecutor, KeyDownEvent, KeyUpEvent, Keystroke, LinuxCommon, @@ -92,6 +91,10 @@ use crate::{ xdg_desktop_portal::{Event as XDPEvent, XDPEventSource}, }, }; +use crate::{ + platform::{PlatformWindow, blade::BladeContext}, + underlying_dead_key, +}; /// Used to convert evdev scancode to xkb scancode const MIN_KEYCODE: u32 = 8; @@ -1310,7 +1313,7 @@ impl Dispatch for WaylandClientStatePtr { xkb::Status::Composing => { keystroke.key_char = None; state.pre_edit_text = - compose.utf8().or(Keystroke::underlying_dead_key(keysym)); + compose.utf8().or(underlying_dead_key(keysym)); let pre_edit = state.pre_edit_text.clone().unwrap_or(String::default()); drop(state); @@ -1327,7 +1330,7 @@ impl Dispatch for WaylandClientStatePtr { } xkb::Status::Cancelled => { let pre_edit = state.pre_edit_text.take(); - let new_pre_edit = Keystroke::underlying_dead_key(keysym); + let new_pre_edit = underlying_dead_key(keysym); state.pre_edit_text = new_pre_edit.clone(); drop(state); if let Some(pre_edit) = pre_edit { diff --git a/crates/gpui/src/platform/linux/x11/client.rs b/crates/gpui/src/platform/linux/x11/client.rs index 269b7fe4436b79a4face12161098e6b8d1ebd43f..6e33dc02125e72fbb18139998a6b484f42ffe0ac 100644 --- a/crates/gpui/src/platform/linux/x11/client.rs +++ b/crates/gpui/src/platform/linux/x11/client.rs @@ -2,6 +2,7 @@ use crate::{ linux::KeyboardState, platform::{xcb_flush, Capslock}, scap_screen_capture::scap_screen_sources, + underlying_dead_key, }; use core::str; use std::{ @@ -1066,9 +1067,8 @@ impl X11Client { } xkbc::Status::Composing => { keystroke.key_char = None; - state.pre_edit_text = compose_state - .utf8() - .or(crate::Keystroke::underlying_dead_key(keysym)); + state.pre_edit_text = + compose_state.utf8().or(underlying_dead_key(keysym)); let pre_edit = state.pre_edit_text.clone().unwrap_or(String::default()); drop(state); @@ -1083,7 +1083,7 @@ impl X11Client { if let Some(pre_edit) = pre_edit { window.handle_ime_commit(pre_edit); } - if let Some(current_key) = Keystroke::underlying_dead_key(keysym) { + if let Some(current_key) = underlying_dead_key(keysym) { window.handle_ime_preedit(current_key); } state = self.0.borrow_mut();