Skip to content

Commit d0f6910

Browse files
committed
Address PR feedback
1 parent c4cfd04 commit d0f6910

9 files changed

Lines changed: 73 additions & 99 deletions

File tree

compose/ui/ui/api/ui.klib.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4079,6 +4079,7 @@ final val androidx.compose.ui.semantics/androidx_compose_ui_semantics_SemanticsO
40794079
final val androidx.compose.ui.semantics/androidx_compose_ui_semantics_SemanticsProperties$stableprop // androidx.compose.ui.semantics/androidx_compose_ui_semantics_SemanticsProperties$stableprop|#static{}androidx_compose_ui_semantics_SemanticsProperties$stableprop[0]
40804080
final val androidx.compose.ui.semantics/androidx_compose_ui_semantics_SemanticsPropertyKey$stableprop // androidx.compose.ui.semantics/androidx_compose_ui_semantics_SemanticsPropertyKey$stableprop|#static{}androidx_compose_ui_semantics_SemanticsPropertyKey$stableprop[0]
40814081
final val androidx.compose.ui.spatial/androidx_compose_ui_spatial_RelativeLayoutBounds$stableprop // androidx.compose.ui.spatial/androidx_compose_ui_spatial_RelativeLayoutBounds$stableprop|#static{}androidx_compose_ui_spatial_RelativeLayoutBounds$stableprop[0]
4082+
final val androidx.compose.ui.unit/androidx_compose_ui_unit_DpInsets$stableprop // androidx.compose.ui.unit/androidx_compose_ui_unit_DpInsets$stableprop|#static{}androidx_compose_ui_unit_DpInsets$stableprop[0]
40824083
final val androidx.compose.ui.window/androidx_compose_ui_window_DialogProperties$stableprop // androidx.compose.ui.window/androidx_compose_ui_window_DialogProperties$stableprop|#static{}androidx_compose_ui_window_DialogProperties$stableprop[0]
40834084
final val androidx.compose.ui.window/androidx_compose_ui_window_PopupProperties$stableprop // androidx.compose.ui.window/androidx_compose_ui_window_PopupProperties$stableprop|#static{}androidx_compose_ui_window_PopupProperties$stableprop[0]
40844085
final val androidx.compose.ui/LocalUiMediaScope // androidx.compose.ui/LocalUiMediaScope|{}LocalUiMediaScope[0]
@@ -4552,6 +4553,7 @@ final fun androidx.compose.ui.semantics/androidx_compose_ui_semantics_SemanticsP
45524553
final fun androidx.compose.ui.spatial/androidx_compose_ui_spatial_RelativeLayoutBounds$stableprop_getter(): kotlin/Int // androidx.compose.ui.spatial/androidx_compose_ui_spatial_RelativeLayoutBounds$stableprop_getter|androidx_compose_ui_spatial_RelativeLayoutBounds$stableprop_getter(){}[0]
45534554
final fun androidx.compose.ui.state/ToggleableState(kotlin/Boolean): androidx.compose.ui.state/ToggleableState // androidx.compose.ui.state/ToggleableState|ToggleableState(kotlin.Boolean){}[0]
45544555
final fun androidx.compose.ui.text/rememberTextMeasurer(kotlin/Int, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int): androidx.compose.ui.text/TextMeasurer // androidx.compose.ui.text/rememberTextMeasurer|rememberTextMeasurer(kotlin.Int;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
4556+
final fun androidx.compose.ui.unit/androidx_compose_ui_unit_DpInsets$stableprop_getter(): kotlin/Int // androidx.compose.ui.unit/androidx_compose_ui_unit_DpInsets$stableprop_getter|androidx_compose_ui_unit_DpInsets$stableprop_getter(){}[0]
45554557
final fun androidx.compose.ui.window/Dialog(kotlin/Function0<kotlin/Unit>, androidx.compose.ui.window/DialogProperties?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // androidx.compose.ui.window/Dialog|Dialog(kotlin.Function0<kotlin.Unit>;androidx.compose.ui.window.DialogProperties?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
45564558
final fun androidx.compose.ui.window/Popup(androidx.compose.ui.window/PopupPositionProvider, kotlin/Function0<kotlin/Unit>?, androidx.compose.ui.window/PopupProperties?, kotlin/Function1<androidx.compose.ui.input.key/KeyEvent, kotlin/Boolean>?, kotlin/Function1<androidx.compose.ui.input.key/KeyEvent, kotlin/Boolean>?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // androidx.compose.ui.window/Popup|Popup(androidx.compose.ui.window.PopupPositionProvider;kotlin.Function0<kotlin.Unit>?;androidx.compose.ui.window.PopupProperties?;kotlin.Function1<androidx.compose.ui.input.key.KeyEvent,kotlin.Boolean>?;kotlin.Function1<androidx.compose.ui.input.key.KeyEvent,kotlin.Boolean>?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]
45574559
final fun androidx.compose.ui.window/Popup(androidx.compose.ui.window/PopupPositionProvider, kotlin/Function0<kotlin/Unit>?, androidx.compose.ui.window/PopupProperties?, kotlin/Function2<androidx.compose.runtime/Composer, kotlin/Int, kotlin/Unit>, androidx.compose.runtime/Composer?, kotlin/Int, kotlin/Int) // androidx.compose.ui.window/Popup|Popup(androidx.compose.ui.window.PopupPositionProvider;kotlin.Function0<kotlin.Unit>?;androidx.compose.ui.window.PopupProperties?;kotlin.Function2<androidx.compose.runtime.Composer,kotlin.Int,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int;kotlin.Int){}[0]

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/Utils.desktop.kt

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ import androidx.compose.ui.geometry.Rect
2020
import androidx.compose.ui.graphics.Color
2121
import androidx.compose.ui.unit.Density
2222
import androidx.compose.ui.unit.DpRect
23-
import androidx.compose.ui.unit.IntOffset
2423
import androidx.compose.ui.unit.IntRect
25-
import androidx.compose.ui.unit.IntSize
26-
import androidx.compose.ui.unit.dp
2724
import androidx.compose.ui.util.fastRoundToInt
2825
import java.awt.Component
2926
import java.awt.EventQueue
3027
import java.awt.Graphics
31-
import java.awt.Point
3228
import java.awt.Rectangle
3329
import java.util.concurrent.atomic.AtomicBoolean
3430
import javax.swing.JComponent
@@ -75,10 +71,6 @@ internal fun IntRect.toAwtRectangle(density: Density) = toAwtRectangle(
7571
density = density.density
7672
)
7773

78-
internal fun Point.toIntOffset(): IntOffset = IntOffset(x, y)
79-
80-
internal fun IntRect.toDpRect(): DpRect = DpRect(left.dp, top.dp, right.dp, bottom.dp)
81-
8274
internal fun DpRect.toAwtRectangleRounded(): Rectangle {
8375
val left = this.left.value.fastRoundToInt()
8476
val top = this.top.value.fastRoundToInt()
@@ -193,25 +185,4 @@ internal class DebouncingEdtExecutor {
193185
}
194186
}
195187
}
196-
}
197-
198-
/**
199-
* Creates a copy of this [IntRect], with the specified size, preserving the top-left position.
200-
*/
201-
internal fun IntRect.copy(size: IntSize) =
202-
IntRect(
203-
left = left,
204-
top = top,
205-
right = size.width,
206-
bottom = size.height
207-
)
208-
209-
/**
210-
* Creates a copy of this [IntRect], with the specified position, preserving the size.
211-
*/
212-
internal fun IntRect.copy(topLeft: IntOffset) = IntRect(
213-
left = topLeft.x,
214-
top = topLeft.y,
215-
right = topLeft.x + right,
216-
bottom = topLeft.y + bottom
217-
)
188+
}

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/awt/v2/SwingWindow.desktop.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 The Android Open Source Project
2+
* Copyright 2026 The Android Open Source Project
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@ import androidx.compose.ui.graphics.painter.Painter
3333
import androidx.compose.ui.input.key.KeyEvent
3434
import androidx.compose.ui.unit.DpRect
3535
import androidx.compose.ui.unit.dp
36+
import androidx.compose.ui.unit.requireReal
3637
import androidx.compose.ui.util.ComponentUpdater
3738
import androidx.compose.ui.util.componentListenerRef
3839
import androidx.compose.ui.util.setIcon
@@ -46,9 +47,9 @@ import androidx.compose.ui.window.WindowDecoration
4647
import androidx.compose.ui.window.WindowLocationTracker
4748
import androidx.compose.ui.window.WindowPlacement
4849
import androidx.compose.ui.window.density
49-
import androidx.compose.ui.window.requireReal
5050
import androidx.compose.ui.window.resizerThickness
5151
import androidx.compose.ui.window.roundToDimensionOrNull
52+
import androidx.compose.ui.window.toDpInsets
5253
import androidx.compose.ui.window.v2.Screen
5354
import androidx.compose.ui.window.v2.Window
5455
import androidx.compose.ui.window.v2.WindowBoundsProvider
@@ -58,7 +59,6 @@ import androidx.compose.ui.window.v2.WindowScreenProviderScope
5859
import androidx.compose.ui.window.v2.WindowSizeLimits
5960
import androidx.compose.ui.window.v2.WindowState
6061
import androidx.compose.ui.window.v2.rememberWindowState
61-
import androidx.compose.ui.window.v2.toDpInsets
6262
import java.awt.GraphicsDevice
6363
import java.awt.GraphicsEnvironment
6464
import java.awt.Window

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/Geometry.desktop.kt

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
package androidx.compose.ui.window
1818

19-
import androidx.compose.ui.unit.Dp
19+
import androidx.compose.ui.unit.DpInsets
2020
import androidx.compose.ui.unit.DpOffset
2121
import androidx.compose.ui.unit.DpRect
2222
import androidx.compose.ui.unit.DpSize
23-
import androidx.compose.ui.unit.IntSize
2423
import androidx.compose.ui.unit.dp
25-
import androidx.compose.ui.unit.isFinite
2624
import androidx.compose.ui.unit.isSpecified
2725
import java.awt.Dimension
26+
import java.awt.Insets
2827
import java.awt.Point
2928
import java.awt.Rectangle
3029
import kotlin.math.roundToInt
@@ -51,40 +50,13 @@ internal fun DpSize.roundToDimension() = Dimension(
5150
)
5251
internal fun DpSize.roundToDimensionOrNull() =
5352
if (isSpecified) roundToDimension() else null
54-
internal fun DpSize.roundToIntSize() = IntSize(
55-
width = width.value.roundToInt(),
56-
height = height.value.roundToInt()
57-
)
58-
59-
internal val DpRect.topLeft: DpOffset get() = DpOffset(left, top)
60-
internal operator fun DpRect.plus(offset: DpOffset): DpRect =
61-
DpRect(left + offset.x, top + offset.y, right + offset.x, bottom + offset.y)
62-
63-
internal val Dp.isReal
64-
get() = isSpecified && isFinite
65-
66-
internal fun Dp.requireReal(propertyName: String) =
67-
require(isReal) { "$propertyName must be specified and finite"}
68-
69-
internal fun DpRect.requireReal(): DpRect {
70-
left.requireReal("left")
71-
top.requireReal("top")
72-
right.requireReal("right")
73-
bottom.requireReal("bottom")
74-
return this
75-
}
76-
77-
internal fun DpSize.requireReal(): DpSize {
78-
require(isSpecified) { "size must be specified" }
79-
width.requireReal("width")
80-
height.requireReal("height")
81-
return this
82-
}
83-
84-
internal fun DpOffset.requireReal(): DpOffset {
85-
require(isSpecified) { "offset must be specified" }
86-
x.requireReal("x")
87-
y.requireReal("y")
88-
return this
89-
}
9053

54+
/**
55+
* Converts AWT [Insets] to [DpInsets].
56+
*/
57+
internal fun Insets.toDpInsets() = DpInsets(
58+
top = top.dp,
59+
left = left.dp,
60+
bottom = bottom.dp,
61+
right = right.dp
62+
)

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v2/Screen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
package androidx.compose.ui.window.v2
1818

1919
import androidx.compose.ui.ExperimentalComposeUiApi
20+
import androidx.compose.ui.unit.DpInsets
2021
import androidx.compose.ui.unit.DpRect
22+
import androidx.compose.ui.unit.minus
23+
import androidx.compose.ui.window.toDpInsets
2124
import androidx.compose.ui.window.toDpRect
2225
import java.awt.GraphicsDevice
2326
import java.awt.Toolkit

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v2/WindowGeometryProviders.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.compose.ui.scene.MeasuredSceneContent
2222
import androidx.compose.ui.unit.Constraints
2323
import androidx.compose.ui.unit.Density
2424
import androidx.compose.ui.unit.Dp
25+
import androidx.compose.ui.unit.DpInsets
2526
import androidx.compose.ui.unit.isSpecified
2627
import androidx.compose.ui.unit.isFinite
2728
import androidx.compose.ui.unit.DpOffset
@@ -30,11 +31,12 @@ import androidx.compose.ui.unit.DpSize
3031
import androidx.compose.ui.unit.LayoutDirection
3132
import androidx.compose.ui.unit.coerceAtMost
3233
import androidx.compose.ui.unit.dp
34+
import androidx.compose.ui.unit.plus
35+
import androidx.compose.ui.unit.requireReal
36+
import androidx.compose.ui.unit.roundToIntSize
3337
import androidx.compose.ui.unit.size
3438
import androidx.compose.ui.window.WindowLocationTracker
35-
import androidx.compose.ui.window.requireReal
3639
import androidx.compose.ui.window.roundToDimension
37-
import androidx.compose.ui.window.roundToIntSize
3840
import androidx.compose.ui.window.toDpOffset
3941
import java.awt.GraphicsDevice
4042

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v2/WindowState.desktop.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ import androidx.compose.ui.unit.isFinite
3232
import androidx.compose.ui.unit.DpOffset
3333
import androidx.compose.ui.unit.DpRect
3434
import androidx.compose.ui.unit.DpSize
35+
import androidx.compose.ui.unit.requireReal
3536
import androidx.compose.ui.window.WindowPlacement
36-
import androidx.compose.ui.window.requireReal
3737
import java.awt.Rectangle
3838
import kotlinx.coroutines.channels.Channel
3939

@@ -148,12 +148,6 @@ fun WindowState(
148148
/**
149149
* A state object that can be hoisted to control and observe window attributes
150150
* (size/position/state).
151-
*
152-
* @param isInitialized the initial value for [WindowState.isInitialized]
153-
* @param screenId the initial value for [WindowState._screenId]
154-
* @param placement the initial value for [WindowState._placement]
155-
* @param isMinimized the initial value for [WindowState._isMinimized]
156-
* @param bounds the initial value for [WindowState._bounds]
157151
*/
158152
@Stable
159153
@ExperimentalComposeUiApi

compose/ui/ui/src/desktopMain/kotlin/androidx/compose/ui/window/v2/DpInsets.kt renamed to compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/unit/DpInsets.kt

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package androidx.compose.ui.window.v2
17+
package androidx.compose.ui.unit
1818

1919
import androidx.compose.runtime.Immutable
2020
import androidx.compose.ui.ExperimentalComposeUiApi
21-
import androidx.compose.ui.unit.Dp
22-
import androidx.compose.ui.unit.DpRect
23-
import androidx.compose.ui.unit.DpSize
24-
import androidx.compose.ui.unit.dp
25-
import java.awt.Insets
2621

2722

2823
/**
2924
* Represents a set of insets in [Dp] units.
30-
*
31-
* @see Screen.insets
3225
*/
3326
@ExperimentalComposeUiApi
3427
@Immutable
@@ -91,13 +84,3 @@ operator fun DpSize.plus(insets: DpInsets): DpSize =
9184
width = width + insets.left + insets.right,
9285
height = height + insets.top + insets.bottom
9386
)
94-
95-
/**
96-
* Converts AWT [Insets] to [DpInsets].
97-
*/
98-
internal fun Insets.toDpInsets() = DpInsets(
99-
top = top.dp,
100-
left = left.dp,
101-
bottom = bottom.dp,
102-
right = right.dp
103-
)

compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/unit/Geometry.skiko.kt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import androidx.compose.ui.geometry.Offset
2323
import androidx.compose.ui.geometry.Rect
2424
import androidx.compose.ui.geometry.Size
2525
import androidx.compose.ui.geometry.isSpecified
26+
import kotlin.math.roundToInt
2627

2728
/**
2829
* Convert a [Offset] to a [DpOffset].
@@ -96,3 +97,49 @@ internal inline fun DpSize.coerceAtMost(size: DpSize): DpSize =
9697
@Stable
9798
internal inline fun IntSize.toRect(): Rect =
9899
Rect(0f, 0f, width.toFloat(), height.toFloat())
100+
101+
@Stable
102+
internal fun DpSize.roundToIntSize() = IntSize(
103+
width = width.value.roundToInt(),
104+
height = height.value.roundToInt()
105+
)
106+
107+
@Stable
108+
internal val DpRect.topLeft: DpOffset get() = DpOffset(left, top)
109+
110+
@Stable
111+
internal operator fun DpRect.plus(offset: DpOffset): DpRect =
112+
DpRect(left + offset.x, top + offset.y, right + offset.x, bottom + offset.y)
113+
114+
@Stable
115+
internal val Dp.isReal
116+
get() = isSpecified && isFinite
117+
118+
@Stable
119+
internal fun Dp.requireReal(propertyName: String) =
120+
require(isReal) { "$propertyName must be specified and finite"}
121+
122+
@Stable
123+
internal fun DpRect.requireReal(): DpRect {
124+
left.requireReal("left")
125+
top.requireReal("top")
126+
right.requireReal("right")
127+
bottom.requireReal("bottom")
128+
return this
129+
}
130+
131+
@Stable
132+
internal fun DpSize.requireReal(): DpSize {
133+
require(isSpecified) { "size must be specified" }
134+
width.requireReal("width")
135+
height.requireReal("height")
136+
return this
137+
}
138+
139+
@Stable
140+
internal fun DpOffset.requireReal(): DpOffset {
141+
require(isSpecified) { "offset must be specified" }
142+
x.requireReal("x")
143+
y.requireReal("y")
144+
return this
145+
}

0 commit comments

Comments
 (0)