mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
feat(session): split the display resolution into landscape and portrait (#2990)
## Summary Splits the session resolution setting into two: **Landscape resolution** and **Portrait resolution**. Each has the same options as the old Resolution row, plus a Follow option so one orientation can mirror the other. ## Why A single resolution has to serve both orientations. Presets and Match screen flip automatically in portrait, but a custom size is used exactly as typed, so a landscape size in a portrait session is wrong. Users who play in both orientations couldn't pick a good size for each. ## Behavior - The Display tab shows **Landscape resolution** and, underneath it, **Portrait resolution**. Both offer the full existing list: presets, Match screen, Follow screen, scaled follow options and Custom. - Each row has an extra option at the top. **Follow portrait** (on the landscape row) and **Follow landscape** (on the portrait row) use the other orientation's choice, so someone can set one resolution and let the other mirror it. The label shows the size it resolves to. - A session picks the landscape or portrait choice from its orientation. This uses the same orientation check as the output size, so the unfolded-controls layout still counts as landscape. - Custom WxH sizes are flipped to match the target orientation when followed, e.g. portrait following 1280x720 uses 720x1280. - If both rows would follow each other, the other row is set to the concrete size it currently resolves to, so there is never a loop and nothing visibly changes. - The glasses output keeps using the landscape resolution. - Applies to the Steam and Desktop Display tabs, which share the same row. ## Compatibility - The existing saved choice (`displayResolution.<mode>`) is now the landscape resolution, so existing users keep their setting. - The portrait choice is stored as `displayResolution.portrait.<mode>` and defaults to Follow landscape, so portrait sessions behave as before until it is changed. The settings reset covers it through the existing `displayResolution.` prefix. - One visible difference: a typed landscape custom size, used as typed in portrait before, now flips to portrait while portrait follows landscape. ## Known limitation "Follow screen" is still decided once when the session starts, not on every rotation. Re-evaluating it on rotation could make the window orientation flip repeatedly when no orientation is pinned. ## Changes - `SessionDisplay`: `LINK_LANDSCAPE` / `LINK_PORTRAIT`, `isLink`, `orientCustom`, `effectiveChoice` - `SessionPrefs`: `resolutionStored` (raw value per orientation), `resolutionChoice(..., portrait)`, `setResolutionChoice(..., portrait)` with the loop guard, `resolutionChosen(..., portrait)` - `SessionActivity`: `portraitOutput()` drives the output size, follow-screen choice and follow scale; the Match-screen default for programs that draw at the panel size checks the matching orientation - `ResolutionRow`, `ModeSettingsDialog`, `FrontEndActivity`: two rows, the Follow option, state and actions - `DeviceReport`: logs landscape and portrait separately - Strings: `display_resolution_landscape`, `display_resolution_portrait`, `display_follow_landscape`, `display_follow_portrait` in all 33 locales; the unused `display_resolution` is removed - Tests: `PortraitResolutionTest` ## Testing - Unit tests added for the preference logic, follow resolution, loop guard and reset.
This commit is contained in:
42 files changed
+388
-103
No files matched your search
@@ -2958,16 +2958,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
WaylandCompositor.nativeResizeOutput(size.first, size.second)
|
||||
}
|
||||
|
||||
private fun followPortrait(): Boolean = glassesScreen == null && SessionPrefs.portrait(this)
|
||||
|
||||
private fun followScale(): Float {
|
||||
val mode = displayMode()
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait())
|
||||
return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f
|
||||
}
|
||||
|
||||
private fun followChoice(): Boolean {
|
||||
val mode = displayMode()
|
||||
return com.droiddeck.launcher.session.SessionDisplay.isFollow(
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this)))
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), followPortrait()))
|
||||
}
|
||||
|
||||
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||
@@ -3033,17 +3035,19 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun displayMode(): String = SessionPrefs.displayMode(this,
|
||||
intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM, intent.getStringExtra(SessionService.EXTRA_PROGRAM))
|
||||
|
||||
private fun portraitOutput(): Boolean = SessionPrefs.portrait(this) && !controlsBelowWanted()
|
||||
|
||||
private fun outputSize(): Pair<Int, Int> =
|
||||
com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||
resolutionChoice(), SessionPrefs.portrait(this) && !controlsBelowWanted())
|
||||
resolutionChoice(), portraitOutput())
|
||||
|
||||
private fun resolutionChoice(): String {
|
||||
private fun resolutionChoice(portrait: Boolean = SessionPrefs.portrait(this)): String {
|
||||
val mode = displayMode()
|
||||
val program = intent.getStringExtra(SessionService.EXTRA_PROGRAM)
|
||||
return if (intent.getStringExtra(SessionService.EXTRA_MODE) == SessionService.MODE_RUN &&
|
||||
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode))
|
||||
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode, portrait))
|
||||
com.droiddeck.launcher.session.SessionDisplay.MATCH_SCREEN
|
||||
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portrait)
|
||||
}
|
||||
|
||||
private fun refreshHz(): Float = refreshHz(null)
|
||||
@@ -4622,7 +4626,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val tabRow = unfoldedColumn?.getChildAt(0)?.height?.let {
|
||||
it - (com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt()
|
||||
} ?: 0
|
||||
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow)
|
||||
val outputAspect = if (!wanted || SessionState.followScreen) 0f
|
||||
else outputSize().let { it.first.toFloat() / it.second.coerceAtLeast(1) }
|
||||
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow, outputAspect)
|
||||
else FrameLayout.LayoutParams.MATCH_PARENT
|
||||
val params = surfaceView.layoutParams as FrameLayout.LayoutParams
|
||||
if (params.height != gameHeight) {
|
||||
|
||||
Reference in new issue
Block a user