diff --git a/crates/gpui/src/platform/linux/wayland/client.rs b/crates/gpui/src/platform/linux/wayland/client.rs index 40ce50ecca2e76354364b33fb429ea8046401dfd..67cd1dcbd43b701c1dd5d69c17d960eb9e8227fd 100644 --- a/crates/gpui/src/platform/linux/wayland/client.rs +++ b/crates/gpui/src/platform/linux/wayland/client.rs @@ -194,6 +194,7 @@ pub(crate) struct WaylandClientState { primary_selection: Option, text_input: Option, pre_edit_text: Option, + ime_pre_edit: Option, composing: bool, // Surface to Window mapping windows: HashMap, @@ -315,7 +316,7 @@ impl WaylandClientStatePtr { pub fn update_ime_position(&self, bounds: Bounds) { let client = self.get_client(); let mut state = client.borrow_mut(); - if state.composing || state.text_input.is_none() { + if state.composing || state.text_input.is_none() || state.pre_edit_text.is_some() { return; } @@ -518,6 +519,7 @@ impl WaylandClient { primary_selection, text_input: None, pre_edit_text: None, + ime_pre_edit: None, composing: false, outputs: HashMap::default(), in_progress_outputs, @@ -1223,13 +1225,13 @@ impl Dispatch for WaylandClientStatePtr { } xkb::Status::Cancelled => { let pre_edit = state.pre_edit_text.take(); + let new_pre_edit = Keystroke::underlying_dead_key(keysym); + state.pre_edit_text = new_pre_edit.clone(); drop(state); if let Some(pre_edit) = pre_edit { focused_window.handle_ime(ImeInput::InsertText(pre_edit)); } - if let Some(current_key) = - Keystroke::underlying_dead_key(keysym) - { + if let Some(current_key) = new_pre_edit { focused_window .handle_ime(ImeInput::SetMarkedText(current_key)); } @@ -1347,7 +1349,7 @@ impl Dispatch for WaylandClientStatePtr { } zwp_text_input_v3::Event::PreeditString { text, .. } => { state.composing = true; - state.pre_edit_text = text; + state.ime_pre_edit = text; } zwp_text_input_v3::Event::Done { serial } => { let last_serial = state.serial_tracker.get(SerialKind::InputMethod); @@ -1356,7 +1358,7 @@ impl Dispatch for WaylandClientStatePtr { return; }; - if let Some(text) = state.pre_edit_text.take() { + if let Some(text) = state.ime_pre_edit.take() { drop(state); window.handle_ime(ImeInput::SetMarkedText(text)); if let Some(area) = window.get_ime_area() { diff --git a/crates/gpui/src/platform/linux/wayland/window.rs b/crates/gpui/src/platform/linux/wayland/window.rs index 28b3316c993a356181f09d635e70edab9894d31d..e2937ad45dcbbcbb37a6cabbbe21352c36dec357 100644 --- a/crates/gpui/src/platform/linux/wayland/window.rs +++ b/crates/gpui/src/platform/linux/wayland/window.rs @@ -1012,9 +1012,7 @@ impl PlatformWindow for WaylandWindow { fn update_ime_position(&self, bounds: Bounds) { let state = self.borrow(); - let client = state.client.clone(); - drop(state); - client.update_ime_position(bounds); + state.client.update_ime_position(bounds); } fn gpu_specs(&self) -> Option {