-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only use positionOnScreen on Android (#503)
This is a speculative fix for #502
- Loading branch information
1 parent
46f74ca
commit 9831637
Showing
5 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
haze/src/androidMain/kotlin/dev/chrisbanes/haze/Utils.android.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Copyright 2025, Christopher Banes and the Haze project contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package dev.chrisbanes.haze | ||
|
||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.layout.LayoutCoordinates | ||
import androidx.compose.ui.layout.positionOnScreen | ||
|
||
/** | ||
* We use positionOnScreen on Android, to support dialogs, popup windows, etc. | ||
*/ | ||
internal actual fun LayoutCoordinates.positionForHaze(): Offset = positionOnScreen() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
haze/src/skikoMain/kotlin/dev/chrisbanes/haze/Utils.skiko.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2025, Christopher Banes and the Haze project contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package dev.chrisbanes.haze | ||
|
||
import androidx.compose.ui.geometry.Offset | ||
import androidx.compose.ui.layout.LayoutCoordinates | ||
import androidx.compose.ui.layout.positionInWindow | ||
|
||
/** | ||
* We only look at window coordinates on Desktop. There's currently no external windows used | ||
* on Skiko platforms (AFAIK), so there's no need to look at screen coordinates. | ||
*/ | ||
internal actual fun LayoutCoordinates.positionForHaze(): Offset = try { | ||
positionInWindow() | ||
} catch (t: Throwable) { | ||
Offset.Unspecified | ||
} |