Commit text composition on focus changes #2026
Open
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.
There is a difference in behavior of CInputMethod in JBR and Corretto (and possibly other JREs).
JBR ignores calls to
setAWTFocussedComponent
with anull
component, which allowsendComposition
to work after a component loses focus. This is exactly what happens in the two linked issues; however in one of them it causes a bug while in the other it works around a different bug.This PR fixes these two issues by:
endComposition
whenever Compose gains focus. Note that this also happens when focus switches inside Compose, due toDesktopPlatformComponent
callingresetFocus
.InputMethodEvent
that asks us to commit the composition when we receive it as the first event in a text editing session inDesktopTextInputService2
.Fixes https://youtrack.jetbrains.com/issue/CMP-7976
Fixes https://youtrack.jetbrains.com/issue/CMP-7989
Testing
Tested manually on:
The following tests were performed using 2-Set Korean input in 8 configurations.
The configurations are the combinations of:
WindowSkiaLayerComponent
(via regularsingleWindowApplication
) orSwingSkiaLayerComponent
withcompose.swing.render.on.graphics=true
(viaComposePanel
in aJFrame
).This should be tested by QA.
It's also a good idea to test whether everything works as before on Windows/Linux.
I discovered an additional bug, only in Corretto:
If, during a composition in a textfield, you switch away from the window and then back, the system completely stops sending mouse-press events to the window. Typing something seems to "shake" the system back into behaving normally. This seems to be caused by the
endComposition
call on focus-gain inCInputMethodWorkaround
, but it's also present in pure Java (but to trigger it, you have to first press e.g. backspace after switching back to the window).Release Notes
Fixes - Desktop