fix: PiP scales the full-size output instead of shrinking it (#2174)

* fix: PiP scales the full-size output instead of shrinking it

* fix: hide the performance HUD as PiP starts so it does not flash at full size
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-06 13:24:37 -05:00
1 parent 69c6c14f3f
commit 1001bc00af
3 files changed
+2 -17

No files matched your search

@@ -2284,9 +2284,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
}
private fun windowOutputSize(width: Int, height: Int): Pair<Int, Int>? {
if (width <= 0 || height <= 0) return null
if (isInPictureInPictureMode) return com.droiddeck.launcher.session.PipPolicy.outputSize(
width, height, SessionState.outputSize.first, SessionState.outputSize.second)
if (width <= 0 || height <= 0 || isInPictureInPictureMode) return null
if (bottomGame != null) return when {
SessionState.followScreen ->
com.droiddeck.launcher.session.SessionDisplay.followSize(width, height, false, SessionState.followScale)
@@ -4384,6 +4382,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private fun showPipUi(show: Boolean) {
pipUi = show
if (show) {
if (::hud.isInitialized) hud.setHidden(true)
drawerOpen = false
pcKeyboardOpen = false
achievementsOpen = false
@@ -11,12 +11,4 @@ object PipPolicy {
height.toDouble() / width > 2.39 -> 100 to 239
else -> width to height
}
fun outputSize(width: Int, height: Int, outputWidth: Int, outputHeight: Int): Pair<Int, Int>? {
if (width <= 0 || height <= 0 || outputWidth <= 0 || outputHeight <= 0) return null
val scale = minOf(width.toFloat() / outputWidth, height.toFloat() / outputHeight)
val fittedWidth = ((outputWidth * scale).toInt() and 1.inv()).coerceAtLeast(2)
val fittedHeight = ((outputHeight * scale).toInt() and 1.inv()).coerceAtLeast(2)
return fittedWidth to fittedHeight
}
}
@@ -24,10 +24,4 @@ class PipPolicyTest {
assertEquals(100 to 239, PipPolicy.aspect(1080, 5760))
assertEquals(16 to 9, PipPolicy.aspect(0, 0))
}
@Test fun pipOutputFitsTheResizedSurfaceWithoutChangingAspectRatio() {
assertEquals(640 to 360, PipPolicy.outputSize(640, 480, 1920, 1080))
assertEquals(480 to 270, PipPolicy.outputSize(480, 270, 1920, 1080))
assertNull(PipPolicy.outputSize(0, 270, 1920, 1080))
}
}