From ba4660dade0cb842ca18d2fddf763558cebec976 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Tue, 5 Mar 2024 18:19:39 +0400 Subject: [PATCH] fix(xkb): text not being None when composing When composing the text was not reset to `None` leading to input in some applications e.g. alacritty. Links: https://github.com/alacritty/alacritty/issues/7806 --- CHANGELOG.md | 1 + src/platform_impl/linux/common/xkb/mod.rs | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ca7100f7c..6f976fa594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Unreleased` header. # Unreleased +- On X11/Wayland, fix `text` and `text_with_all_modifiers` not being `None` during compose. - On Wayland, don't reapply cursor grab when unchanged. - On X11, fix a bug where some mouse events would be unexpectedly filtered out. diff --git a/src/platform_impl/linux/common/xkb/mod.rs b/src/platform_impl/linux/common/xkb/mod.rs index 93713d66c6..fe8bb93e72 100644 --- a/src/platform_impl/linux/common/xkb/mod.rs +++ b/src/platform_impl/linux/common/xkb/mod.rs @@ -373,10 +373,15 @@ impl<'a, 'b> KeyEventResults<'a, 'b> { fn composed_text(&mut self) -> Result, ()> { match self.compose { - ComposeStatus::Accepted(xkb_compose_status::XKB_COMPOSE_COMPOSED) => { - let state = self.context.compose_state1.as_mut().unwrap(); - Ok(state.get_string(self.context.scratch_buffer)) - } + ComposeStatus::Accepted(status) => match status { + xkb_compose_status::XKB_COMPOSE_COMPOSED => { + let state = self.context.compose_state1.as_mut().unwrap(); + Ok(state.get_string(self.context.scratch_buffer)) + } + xkb_compose_status::XKB_COMPOSE_COMPOSING + | xkb_compose_status::XKB_COMPOSE_CANCELLED => Ok(None), + xkb_compose_status::XKB_COMPOSE_NOTHING => Err(()), + }, _ => Err(()), } }