From a8fc93c445e00e947805147afb86065414697f5e Mon Sep 17 00:00:00 2001 From: realybin Date: Fri, 9 May 2025 16:32:27 +0800 Subject: [PATCH] Fix incorrect CandidateWindow position when using Pinyin IMEs in Windows (#18759) --- .../Avalonia.Win32/Input/Imm32InputMethod.cs | 29 +------------------ 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs b/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs index 914844d73f..65827607c1 100644 --- a/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs +++ b/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs @@ -208,27 +208,6 @@ namespace Avalonia.Win32.Input var s = _parent?.DesktopScaling ?? 1; var (x1, y1, x2, y2) = ((int) (p1.X * s), (int) (p1.Y * s), (int) (p2.X * s), (int) (p2.Y * s)); - if (!ShowCompositionWindow && _langId == LANG_ZH) - { - // Chinese IMEs ignore function calls to ::ImmSetCandidateWindow() - // when a user disables TSF (Text Service Framework) and CUAS (Cicero - // Unaware Application Support). - // On the other hand, when a user enables TSF and CUAS, Chinese IMEs - // ignore the position of the current system caret and uses the - // parameters given to ::ImmSetCandidateWindow() with its 'dwStyle' - // parameter CFS_CANDIDATEPOS. - // Therefore, we do not only call ::ImmSetCandidateWindow() but also - // set the positions of the temporary system caret. - var candidateForm = new CANDIDATEFORM - { - dwIndex = 0, - dwStyle = CFS_CANDIDATEPOS, - ptCurrentPos = new POINT {X = x2, Y = y2} - }; - - ImmSetCandidateWindow(himc, ref candidateForm); - } - _caretManager.TryMove(x2, y2); if (ShowCompositionWindow) @@ -247,14 +226,8 @@ namespace Avalonia.Win32.Input y2 += CaretMargin; } - // Need to return here since some Chinese IMEs would stuck if set - // candidate window position with CFS_EXCLUDE style. - if (_langId == LANG_ZH) - { - return; - } - // Japanese IMEs and Korean IMEs also use the rectangle given to + // Chinese, Japanese, and Korean(CJK) IMEs also use the rectangle given to // ::ImmSetCandidateWindow() with its 'dwStyle' parameter CFS_EXCLUDE // to move their candidate windows when a user disables TSF and CUAS. // Therefore, we also set this parameter here.