Display shape: the panel's own or a fixed 16:9, defaulting to 16:9 on a foldable

gamescope's display cannot change size once the session is up, so a foldable
that starts on one panel and opens onto the other can only be letterboxed
differently, never re-shaped. A fixed 16:9 sits with modest bars on either
panel; the panel's own shape fits one and leaves a strip on the other. A device
with a hinge sensor defaults to 16:9; the drawer toggles it for the next
session.
This commit is contained in:
The412Banner committed 2026-09-19 15:54:25 -04:00
1 parent d2ea9b898a
commit 18364845ad
6 files changed
+43 -2

No files matched your search

@@ -181,7 +181,8 @@ class SessionActivity : Activity(), SurfaceHolder.Callback {
// (FlatOut on a Fold lost the edges of its own menus). Wider than 16:9 is fine — games and
// the client cope with a phone's 20:9 — so the panel's aspect is kept above that and the
// compositor letterboxes the 16:9 picture onto a squarer panel.
val aspect = maxOf(panelW / panelH, 16f / 9f)
val aspect = if (SessionPrefs.shapeMode(this) == SessionPrefs.SHAPE_WIDE) 16f / 9f
else maxOf(panelW / panelH, 16f / 9f)
// 1080 tall at most: the client's CEF is the heaviest thing in the session, and above
// 1080p it costs frames for nothing anyone can see on a handheld panel.
val height = minOf(panelH, 1080f).toInt()
@@ -25,6 +25,7 @@ class SessionDrawer(
private val hud = root.findViewById<Switch>(R.id.drawer_hud)
private val frameGen = root.findViewById<Button>(R.id.drawer_frame_gen)
private val osc = root.findViewById<Button>(R.id.drawer_osc)
private val shape = root.findViewById<Button>(R.id.drawer_shape)
init {
root.visibility = View.GONE
@@ -52,6 +53,12 @@ class SessionDrawer(
refresh()
onOscChanged()
}
shape.setOnClickListener {
val next = if (SessionPrefs.shapeMode(activity) == SessionPrefs.SHAPE_WIDE) SessionPrefs.SHAPE_AUTO
else SessionPrefs.SHAPE_WIDE
SessionPrefs.setShapeMode(activity, next)
refresh()
}
root.findViewById<View>(R.id.drawer_background).setOnClickListener {
close()
onBackground()
@@ -85,5 +92,8 @@ class SessionDrawer(
else -> activity.getString(R.string.osc_auto)
}
osc.text = activity.getString(R.string.drawer_osc, mode)
shape.text = activity.getString(R.string.drawer_shape,
if (SessionPrefs.shapeMode(activity) == SessionPrefs.SHAPE_WIDE) activity.getString(R.string.shape_wide)
else activity.getString(R.string.shape_auto))
}
}
@@ -16,6 +16,23 @@ object SessionPrefs {
prefs(context).edit().putBoolean("hud", on).apply()
}
const val SHAPE_AUTO = "auto"
const val SHAPE_WIDE = "16:9"
/**
* The shape of the display the session presents: the panel's own (never narrower than 16:9)
* or a fixed 16:9. A foldable defaults to 16:9, which sits with modest bars on either of its
* panels; the panel's own shape would fit one and leave a strip on the other, and gamescope's
* display cannot change size once the session is up.
*/
fun shapeMode(context: Context): String =
prefs(context).getString("shape", null)
?: if (context.packageManager.hasSystemFeature("android.hardware.sensor.hinge_angle")) SHAPE_WIDE else SHAPE_AUTO
fun setShapeMode(context: Context, mode: String) {
prefs(context).edit().putString("shape", mode).apply()
}
fun oscMode(context: Context): String = prefs(context).getString("osc", OSC_AUTO) ?: OSC_AUTO
fun setOscMode(context: Context, mode: String) {