Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 52d763fa authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move the window inset out of composition for the tooltip positioning" into main

parents 2c7b8298 a3baad21
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -178,13 +178,9 @@ private fun rememberTooltipPositionProvider(
    windowInsets: WindowInsets,
    spacingBetweenTooltipAndAnchor: Dp = SpacingBetweenTooltipAndAnchor,
): PopupPositionProvider {
    // We grab the top window inset and remove it manually from the position as it is not consumed
    // in the QS panel (b/424438896)
    val topInset = windowInsets.getTop(LocalDensity.current)

    val tooltipAnchorSpacing =
        with(LocalDensity.current) { spacingBetweenTooltipAndAnchor.roundToPx() }
    return remember(tooltipAnchorSpacing, topInset) {
    val density = LocalDensity.current
    val tooltipAnchorSpacing = with(density) { spacingBetweenTooltipAndAnchor.roundToPx() }
    return remember(tooltipAnchorSpacing, windowInsets, density) {
        object : PopupPositionProvider {
            override fun calculatePosition(
                anchorBounds: IntRect,
@@ -208,6 +204,11 @@ private fun rememberTooltipPositionProvider(
                    x = anchorBounds.right - popupContentSize.width
                }

                // We grab the top window inset and remove it manually from the position as it is
                // not consumed
                // in the QS panel (b/424438896)
                val topInset = windowInsets.getTop(density)

                // Tooltip prefers to be below the anchor,
                // but if this causes the tooltip to be outside the window
                // then we place it above the anchor