diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarAppStage.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarAppStage.kt index 8b71012..85ffcfc 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarAppStage.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/CarAppStage.kt @@ -102,10 +102,18 @@ private fun AppSurface( // changing size moves the visible area even though the surface itself hasn't changed. val (width, height) = size val measured = bounds?.takeIf { width > 0 && height > 0 }?.let { cover?.visibleWithin(it, width, height) } - LaunchedEffect(template, size, measured) { + // The card column moves the map's centre but isn't taken out of the stable area: apps size + // their own overlays from it, and Vela's speedometer shrank to fit the strip right of the cards. + val measuredStable = bounds?.takeIf { width > 0 && height > 0 }?.let { cover?.visibleWithin(it, width, height, skip = CoverEdge.START) } + LaunchedEffect(template, size, measured, measuredStable) { if (width > 0 && height > 0) { val visible = visibleAreaFor(template, width, height, measured) - connection.reportAreas(visible = visible, stable = visible) + val stable = if (template is androidx.car.app.navigation.model.NavigationTemplate) { + visibleAreaFor(template, width, height, measuredStable) + } else { + visible + } + connection.reportAreas(visible = visible, stable = stable) } } diff --git a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateChrome.kt b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateChrome.kt index 67ad48d..70881c6 100644 --- a/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateChrome.kt +++ b/gearslip/src/main/java/app/seb3thehacker/gearslip/car/TemplateChrome.kt @@ -129,12 +129,13 @@ internal class ChromeCover { } /** What is left of a [width] x [height] surface at [surface] (window pixels), in surface pixels. */ - fun visibleWithin(surface: ComposeRect, width: Int, height: Int): Rect { + fun visibleWithin(surface: ComposeRect, width: Int, height: Int, skip: CoverEdge? = null): Rect { var left = 0f var top = 0f var right = width.toFloat() var bottom = height.toFloat() pieces.values.forEach { (edge, b) -> + if (edge == skip) return@forEach when (edge) { CoverEdge.TOP -> top = maxOf(top, b.bottom - surface.top) CoverEdge.BOTTOM -> bottom = minOf(bottom, b.top - surface.top)