@@ -23,11 +23,26 @@ import java.awt.im.InputContext
23
23
import java.util.*
24
24
import org.jetbrains.skiko.OS
25
25
import org.jetbrains.skiko.hostOs
26
+ import org.jetbrains.skiko.SkiaLayer
26
27
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
+ */
27
35
internal interface InputMethodEndCompositionWorkaround {
28
36
37
+ /* *
38
+ * The [InputContext] that [SkiaLayer.getInputContext] should return; `null` if it should return
39
+ * the default one.
40
+ */
29
41
val inputContext: InputContext ?
30
42
43
+ /* *
44
+ * An implementation of the workaround for [sun.lwawt.macosx.CInputMethod].
45
+ */
31
46
class CInputMethodWorkaround (
32
47
val componentInputContext : () -> InputContext ?
33
48
) : InputMethodEndCompositionWorkaround {
@@ -55,6 +70,12 @@ internal interface InputMethodEndCompositionWorkaround {
55
70
}
56
71
57
72
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
+ */
58
79
fun forCurrentEnvironment (
59
80
componentInputContext : () -> InputContext ?
60
81
): InputMethodEndCompositionWorkaround ? = when (hostOs) {
@@ -64,6 +85,9 @@ internal interface InputMethodEndCompositionWorkaround {
64
85
}
65
86
}
66
87
88
+ /* *
89
+ * An [InputContext] that redirects all calls to [delegate].
90
+ */
67
91
private abstract class DelegatingInputContext (
68
92
val delegate : () -> InputContext ? ,
69
93
) : InputContext() {
0 commit comments