feat(session): add an Avoid notch toggle to the Steam display options

Keeps the Steam session picture, controls and overlays inside the display cutout's safe area so the notch no longer covers part of the image, in landscape or portrait. Off by default.
This commit is contained in:
FX192 committed 2026-11-21 17:08:27 +03:00
1 parent 64b7339da9
commit c0cc3b46a0
40 files changed
+142 -1

No files matched your search

@@ -194,6 +194,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
private var picturePosition by mutableStateOf("center")
private var integerScaling by mutableStateOf(false)
private var stretch16x9 by mutableStateOf(false)
private var avoidNotch by mutableStateOf(false)
private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM)
@@ -2607,6 +2608,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
picturePosition = if (mode == SessionService.MODE_STEAM) picturePosition else null,
integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null,
stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null,
avoidNotch = if (mode == SessionService.MODE_STEAM) avoidNotch else null,
mic = if (mode == SessionService.MODE_STEAM) mic else null,
gameStorage = if (mode == SessionService.MODE_STEAM) gameStorage else null,
storageOptions = storageOptions,
@@ -2675,6 +2677,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
onPicturePosition = { value -> SessionPrefs.setPicturePosition(this, value); picturePosition = value },
onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on },
onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on },
onAvoidNotch = { on -> SessionPrefs.setAvoidNotch(this, on); avoidNotch = on },
onMic = { on ->
SessionPrefs.setMicEnabled(this, on)
mic = on
@@ -3009,6 +3012,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
picturePosition = SessionPrefs.picturePosition(this)
integerScaling = SessionPrefs.integerScaling(this)
stretch16x9 = SessionPrefs.stretch16x9(this)
avoidNotch = SessionPrefs.avoidNotch(this)
mic = SessionPrefs.micEnabled(this)
refreshWifiDiscovery()
gameStorage = SessionPrefs.gameStorage(this)
@@ -177,6 +177,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private var quickButtons by mutableStateOf<Map<InputCommand, Boolean>>(emptyMap())
private var picturePosition by mutableStateOf("center")
private var integerScaling by mutableStateOf(false)
private var avoidNotch = false
private fun applyNotchInset(insets: android.view.WindowInsets? = window.decorView.rootWindowInsets) {
if (!::sessionRoot.isInitialized) return
val cutout = if (avoidNotch && Build.VERSION.SDK_INT >= 28 && SessionState.mode == SessionService.MODE_STEAM &&
!pipUi && !isInPictureInPictureMode && glassesScreen == null && bottomGame == null && !cardboard.enabled)
insets?.displayCutout else null
val left = cutout?.safeInsetLeft ?: 0
val top = cutout?.safeInsetTop ?: 0
val right = cutout?.safeInsetRight ?: 0
val bottom = cutout?.safeInsetBottom ?: 0
if (sessionRoot.paddingLeft == left && sessionRoot.paddingTop == top &&
sessionRoot.paddingRight == right && sessionRoot.paddingBottom == bottom) return
sessionRoot.setPadding(left, top, right, bottom)
}
private fun applyGameAlignment() {
if (!CompositorHost.isStarted) return
@@ -863,6 +878,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
else super.onResolvePointerIcon(event, pointerIndex)
}
sessionRoot = root
window.decorView.setOnApplyWindowInsetsListener { view, insets ->
applyNotchInset(insets)
view.onApplyWindowInsets(insets)
}
surfaceView = SurfaceView(this)
surfaceView.holder.addCallback(this)
root.addView(surfaceView)
@@ -2538,6 +2557,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
picturePosition = SessionPrefs.picturePosition(this)
integerScaling = SessionPrefs.integerScaling(this)
avoidNotch = SessionPrefs.avoidNotch(this)
applyNotchInset()
hudOn = SessionPrefs.hudEnabled(this)
gpuClockPin = gpuClockHeld()
blackFrameInsertion = SessionPrefs.blackFrameInsertion(this)
@@ -2942,6 +2963,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
cancelTouchGestures()
applyFollowOrientation(newConfig)
applyNotchInset()
applyUnfoldedControls()
resizeOutputForWindow(surfaceW, surfaceH)
}
@@ -289,6 +289,7 @@ object DeviceReport {
k("Guest host name", SessionPrefs.guestHostname(context))
k("DirectAudio for games", SessionPrefs.directAudio(context))
k("Stretch 16:9 to panel", SessionPrefs.stretch16x9(context))
k("Avoid notch", SessionPrefs.avoidNotch(context))
k("Return to launcher after a game", SessionPrefs.returnAfterGame(context))
k("Microphone", SessionPrefs.micEnabled(context))
k("On-screen controls", SessionPrefs.oscMode(context))
@@ -835,6 +835,12 @@ object SessionPrefs {
prefs(context).edit().putBoolean("stretch16x9", on).apply()
}
fun avoidNotch(context: Context): Boolean = prefs(context).getBoolean("avoidNotch", false)
fun setAvoidNotch(context: Context, on: Boolean) {
prefs(context).edit().putBoolean("avoidNotch", on).apply()
}
fun directAudio(context: Context): Boolean = prefs(context).getBoolean("directAudio", true)
@@ -18,7 +18,7 @@ object SettingsReset {
"storesInstallLanguage",
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores",
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
@@ -87,6 +87,7 @@ class ModeSettings(
val picturePosition: String? = null,
val integerScaling: Boolean? = null,
val stretch16x9: Boolean? = null,
val avoidNotch: Boolean? = null,
val steamClientArch: String? = null,
val returnAfterGame: Boolean? = null,
val shaderPrecache: Boolean? = null,
@@ -145,6 +146,7 @@ class ModeSettingsActions(
val onPicturePosition: (String) -> Unit = {},
val onIntegerScaling: (Boolean) -> Unit = {},
val onStretch16x9: (Boolean) -> Unit = {},
val onAvoidNotch: (Boolean) -> Unit = {},
val onSteamRepair: () -> Unit = {},
val onSteamClientArch: (String) -> Unit = {},
val onMangoapp: (Boolean) -> Unit = {},
@@ -253,6 +255,10 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
listOf(false to stringResource(R.string.display_preserve), true to stringResource(R.string.display_stretch)),
s.stretch16x9 && canStretch, enabled = canStretch, onPick = a.onStretch16x9)
}
s.avoidNotch?.let { enabled ->
ToggleRow(host, "avoid-notch", stringResource(R.string.display_avoid_notch),
stringResource(R.string.display_avoid_notch_hint), checked = enabled, onChange = a.onAvoidNotch)
}
ToggleRow(host, "zero-copy", stringResource(R.string.display_zero_copy), null, checked = s.zeroCopy, onChange = a.onZeroCopy)
}
SettingsGroup(stringResource(R.string.display_image_scaling)) {