mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Keep the session's output size across a Surface recreation
gamescope's display is sized once when the session starts and cannot change, but the size was recomputed on every surfaceCreated. A foldable recreates the Surface on the other panel, so a session started on the 21:9 outer screen and opened onto the square inner one told the compositor its 21:9 buffer was 16:9 and the picture came back squashed sideways. While a session runs its size is kept; the compositor letterboxes it onto whatever panel is current. Also the Compose build: BoxWithConstraints' maxWidth read outside its scope.
This commit is contained in:
1 parent
aa7c71bfb6
commit
3877d0696f
2 files changed
+8
-3
No files matched your search
@@ -200,9 +200,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
val turnip = TurnipDriver(this)
|
||||
val driverId = if (CompositorHost.isStarted) null else turnip.install()
|
||||
|
||||
val size = outputSize()
|
||||
// The output size belongs to the session, not to the Surface: gamescope's display is
|
||||
// sized once when the session starts and cannot change. A foldable recreates the Surface
|
||||
// on the other panel, and recomputing the size there told the compositor a 21:9 buffer
|
||||
// was 16:9 — the picture came back squashed sideways. While a session runs, keep its size.
|
||||
val size = if (SessionState.running) SessionState.outputSize else outputSize()
|
||||
SessionState.outputSize = size
|
||||
SessionState.refreshHz = refreshHz()
|
||||
if (!SessionState.running) SessionState.refreshHz = refreshHz()
|
||||
// Letterbox, never stretch or crop: the output can be a different shape from the panel,
|
||||
// and a game's picture must keep its proportions with bars, not lose its edges.
|
||||
WaylandCompositor.nativeSetScaleMode(SCALE_FIT, ALIGN_CENTER)
|
||||
|
||||
@@ -61,6 +61,7 @@ fun MainScreen(
|
||||
.background(MaterialTheme.colorScheme.background),
|
||||
contentAlignment = Alignment.TopCenter,
|
||||
) {
|
||||
val wide = maxWidth > 600.dp
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
@@ -76,7 +77,7 @@ fun MainScreen(
|
||||
Image(
|
||||
painter = painterResource(R.drawable.logo),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(if (maxWidth > 600.dp) 88.dp else 72.dp),
|
||||
modifier = Modifier.size(if (wide) 88.dp else 72.dp),
|
||||
)
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text("SteamDeck", style = MaterialTheme.typography.headlineSmall, color = MaterialTheme.colorScheme.onBackground)
|
||||
|
||||
Reference in new issue
Block a user