Skip to content

Commit aa5b9ed

Browse files
authored
Remove ExperimentalComposeUiApi from keyboardModifiers (#818)
Fixes a CI fail: https://teamcity.jetbrains.com/buildConfiguration/JetBrainsPublicProjects_Compose_Publish_2_AllGitHubRelease/4313900?buildTab=dependencies&mode=list&state=failed&type=snapshot&hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildProblemsSection=true&showLog=4313895_245_235.297&logFilter=debug&logView=flowAware#4313895 As it was before #785 Also: - add default getters for source compatibility - add JvmDefaultWithCompatibility to keep binary compatibility on JVM ## Testing ``` import androidx.compose.ui.platform.LocalWindowInfo import androidx.compose.ui.window.singleWindowApplication fun main() = singleWindowApplication { val modifiers = LocalWindowInfo.current.keyboardModifiers } ``` This shouldn't require OptIn
1 parent 494405d commit aa5b9ed

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

compose/ui/ui/src/androidMain/kotlin/androidx/compose/ui/platform/WindowInfo.android.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import androidx.compose.ui.input.pointer.PointerKeyboardModifiers
2828
* Provides information about the Window that is hosting this compose hierarchy.
2929
*/
3030
@Stable
31+
@JvmDefaultWithCompatibility
3132
actual interface WindowInfo {
3233
/**
3334
* Indicates whether the window hosting this compose hierarchy is in focus.
@@ -41,8 +42,10 @@ actual interface WindowInfo {
4142
/**
4243
* Indicates the state of keyboard modifiers (pressed or not).
4344
*/
44-
@ExperimentalComposeUiApi
45+
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
46+
@get:ExperimentalComposeUiApi
4547
actual val keyboardModifiers: PointerKeyboardModifiers
48+
get() = WindowInfoImpl.GlobalKeyboardModifiers.value
4649
}
4750

4851
internal class WindowInfoImpl : WindowInfo {

compose/ui/ui/src/commonMain/kotlin/androidx/compose/ui/platform/WindowInfo.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ import androidx.compose.runtime.rememberUpdatedState
2323
import androidx.compose.runtime.snapshotFlow
2424
import androidx.compose.ui.ExperimentalComposeUiApi
2525
import androidx.compose.ui.input.pointer.PointerKeyboardModifiers
26+
import androidx.compose.ui.internal.JvmDefaultWithCompatibility
2627

2728
/**
2829
* Provides information about the Window that is hosting this compose hierarchy.
2930
*/
3031
@Stable
32+
@JvmDefaultWithCompatibility
3133
expect interface WindowInfo {
3234
/**
3335
* Indicates whether the window hosting this compose hierarchy is in focus.
@@ -41,8 +43,11 @@ expect interface WindowInfo {
4143
/**
4244
* Indicates the state of keyboard modifiers (pressed or not).
4345
*/
44-
@ExperimentalComposeUiApi
45-
val keyboardModifiers: PointerKeyboardModifiers
46+
// TODO(https://youtrack.jetbrains.com/issue/COMPOSE-412/Remove-getExperimentalComposeUiApi-from-val-keyboardModifiers)
47+
// remove get:ExperimentalComposeUiApi, as it actually isn't experimental
48+
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
49+
@get:ExperimentalComposeUiApi
50+
open val keyboardModifiers: PointerKeyboardModifiers
4651
}
4752

4853
@Composable

compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/platform/WindowInfo.skiko.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ import androidx.compose.runtime.setValue
2323
import androidx.compose.ui.ExperimentalComposeUiApi
2424
import androidx.compose.ui.input.pointer.EmptyPointerKeyboardModifiers
2525
import androidx.compose.ui.input.pointer.PointerKeyboardModifiers
26+
import androidx.compose.ui.internal.JvmDefaultWithCompatibility
2627
import androidx.compose.ui.unit.IntSize
2728

2829
/**
2930
* Provides information about the Window that is hosting this compose hierarchy.
3031
*/
3132
@Stable
33+
@JvmDefaultWithCompatibility
3234
actual interface WindowInfo {
3335
/**
3436
* Indicates whether the window hosting this compose hierarchy is in focus.
@@ -42,14 +44,16 @@ actual interface WindowInfo {
4244
/**
4345
* Indicates the state of keyboard modifiers (pressed or not).
4446
*/
45-
@ExperimentalComposeUiApi
47+
@Suppress("OPT_IN_MARKER_ON_WRONG_TARGET")
48+
@get:ExperimentalComposeUiApi
4649
actual val keyboardModifiers: PointerKeyboardModifiers
50+
get() = WindowInfoImpl.GlobalKeyboardModifiers.value
4751

4852
/**
4953
* Size of the window's content container in pixels.
5054
*/
5155
@ExperimentalComposeUiApi
52-
val containerSize: IntSize
56+
val containerSize: IntSize get() = IntSize.Zero
5357
}
5458

5559
internal class WindowInfoImpl : WindowInfo {

0 commit comments

Comments
 (0)