Skip to content

Commit 4ee90e3

Browse files
committed
Add documentation to InputMethodEndCompositionWorkaround.
1 parent 0597a7d commit 4ee90e3

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/scene/skia/InputMethodEndCompositionWorkaround.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,26 @@ import java.awt.im.InputContext
2323
import java.util.*
2424
import org.jetbrains.skiko.OS
2525
import org.jetbrains.skiko.hostOs
26+
import org.jetbrains.skiko.SkiaLayer
2627

28+
/**
29+
* The interface for a workaround applied to [SkiaLayer] that commits the input method composition
30+
* on focus changes.
31+
*
32+
* See https://github.com/JetBrains/compose-multiplatform-core/pull/2026 for a discussion of the
33+
* issue(s) and the fix.
34+
*/
2735
internal interface InputMethodEndCompositionWorkaround {
2836

37+
/**
38+
* The [InputContext] that [SkiaLayer.getInputContext] should return; `null` if it should return
39+
* the default one.
40+
*/
2941
val inputContext: InputContext?
3042

43+
/**
44+
* An implementation of the workaround for [sun.lwawt.macosx.CInputMethod].
45+
*/
3146
class CInputMethodWorkaround(
3247
val componentInputContext: () -> InputContext?
3348
) : InputMethodEndCompositionWorkaround {
@@ -55,6 +70,12 @@ internal interface InputMethodEndCompositionWorkaround {
5570
}
5671

5772
companion object {
73+
/**
74+
* Returns the workaround for the current JVM/OS.
75+
*
76+
* @param componentInputContext A function that returns the [SkiaLayer]s original
77+
* [InputContext]
78+
*/
5879
fun forCurrentEnvironment(
5980
componentInputContext: () -> InputContext?
6081
): InputMethodEndCompositionWorkaround? = when (hostOs) {
@@ -64,6 +85,9 @@ internal interface InputMethodEndCompositionWorkaround {
6485
}
6586
}
6687

88+
/**
89+
* An [InputContext] that redirects all calls to [delegate].
90+
*/
6791
private abstract class DelegatingInputContext(
6892
val delegate: () -> InputContext?,
6993
) : InputContext() {

0 commit comments

Comments
 (0)