From 47c39e91a1274efa41e2b4fc870ebc9c6866fe85 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Tue, 31 Oct 2023 04:40:18 +0300 Subject: [PATCH] [X11] IME hack for fcitx4 (#13435) Co-authored-by: Max Katz --- src/Avalonia.X11/X11Window.Ime.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.X11/X11Window.Ime.cs b/src/Avalonia.X11/X11Window.Ime.cs index 7a9bfd254a..f27a33ec54 100644 --- a/src/Avalonia.X11/X11Window.Ime.cs +++ b/src/Avalonia.X11/X11Window.Ime.cs @@ -317,8 +317,25 @@ namespace Avalonia.X11 while (_imeQueue.Count != 0) { var ev = _imeQueue.Dequeue(); - if (_imeControl == null || !await _imeControl.HandleEventAsync(ev.args, ev.keyval, ev.keycode)) - ScheduleInput(ev.args); + if (_imeControl != null) + { + var handledByIme = await _imeControl.HandleEventAsync(ev.args, ev.keyval, ev.keycode); + if (handledByIme && ev.args is not + { + // We let filtered modifier-key KeyUp events through + // since some apps rely on the order of events to track individual (left/right) + // modifier keys states rather than relying on general key modifiers + Type: RawKeyEventType.KeyUp, + Key: Key.LeftCtrl or Key.RightCtrl or Key.LeftAlt + or Key.RightAlt or Key.LeftShift or Key.RightShift + or Key.LWin or Key.RWin + }) + continue; + + } + + ScheduleInput(ev.args); + } } finally