From bcf1e65903bcbdedc3b0f793ce405ed9a05611d5 Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Sat, 16 May 2026 21:19:35 +0530 Subject: [PATCH] fix: android not registering hold to change profile --- .../features/profiles/ProfileSwitcherTab.kt | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt index 3678398e..a399c822 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/profiles/ProfileSwitcherTab.kt @@ -56,7 +56,6 @@ import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.input.pointer.pointerInput import androidx.compose.ui.layout.LayoutCoordinates import androidx.compose.ui.layout.ContentScale -import androidx.compose.ui.layout.boundsInWindow import androidx.compose.ui.layout.onGloballyPositioned import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalHapticFeedback @@ -76,6 +75,8 @@ import kotlinx.coroutines.launch import nuvio.composeapp.generated.resources.* import org.jetbrains.compose.resources.getString import org.jetbrains.compose.resources.stringResource +import kotlin.math.max +import kotlin.math.min @Composable fun ProfileSwitcherTab( @@ -124,9 +125,9 @@ fun ProfileSwitcherTab( fun updateDragTarget(localPosition: Offset) { val trigger = triggerCoordinates ?: return - val windowPosition = trigger.localToWindow(localPosition) + val screenPosition = trigger.localToScreen(localPosition) val nextTargetProfileIndex = profileBubbleBounds.entries - .firstOrNull { (_, bounds) -> bounds.contains(windowPosition) } + .firstOrNull { (_, bounds) -> bounds.contains(screenPosition) } ?.key if (nextTargetProfileIndex != null && nextTargetProfileIndex != dragTargetProfileIndex) { performProfileHoverHaptic() @@ -450,7 +451,7 @@ private fun PopupProfileBubble( horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier .onGloballyPositioned { coordinates -> - onBoundsChanged(coordinates.boundsInWindow()) + onBoundsChanged(coordinates.boundsOnScreen()) } .graphicsLayer { alpha = itemAlpha.value @@ -565,6 +566,17 @@ private fun PopupProfileBubble( } } +private fun LayoutCoordinates.boundsOnScreen(): Rect { + val topLeft = localToScreen(Offset.Zero) + val bottomRight = localToScreen(Offset(size.width.toFloat(), size.height.toFloat())) + return Rect( + left = min(topLeft.x, bottomRight.x), + top = min(topLeft.y, bottomRight.y), + right = max(topLeft.x, bottomRight.x), + bottom = max(topLeft.y, bottomRight.y), + ) +} + /** * Compact inline PIN entry shown inside the popup when a PIN-protected * profile is tapped.