[Win32] Fixes improper IME composition ignorance #14664
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
When focusing on an input element, it goes through a series of calls, ultimately reaching the
Imm32InputMethod.Reset
method viaTextInputMethodManager.TryFindAndApplyClient
. Within this method, a task submitted to the UI thread sets_ignoreComposition
totrue
, ignoring the first typed character or the first selected candidate word to be submitted at the end of string composition.This incorrect behavior was introduced in #11723, resolving issue #11292. However, the current solution introduces another problem, as described in #14663.
What is the current behavior?
When the focus changes,
_ignoreComposition
is set totrue
as described above, and is reset tofalse
when handling the next composition message.Avalonia/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs
Line 130 in a33b39e
Avalonia/src/Windows/Avalonia.Win32/Input/Imm32InputMethod.cs
Lines 352 to 357 in a33b39e
However, if there is no unfinished composition when switching focus,
_ignoreComposition
remainstrue
, causing the next composition message to be unexpectedly ignored.What is the updated/expected behavior with this PR?
_ignoreComposition
should not be kepttrue
when no uncompleted string compositions exist, so that the next string composition message can be handled well.How was the solution implemented (if it's not obvious)?
The current merge request introduces a condition before setting
_ignoreComposition
to true. It only sets_ignoreComposition
totrue
when there is ongoing input method string composition, namelyIsComposing
istrue
. This prevents_ignoreComposition
from being inadvertently retained, addressing issue #14663.Checklist
Breaking changes
None.
Obsoletions / Deprecations
None.
Fixed issues
Fixes #14663
Fixes #13881