diff --git a/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt index 3b01e0c8d5..ef2f23ce57 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt @@ -17,7 +17,8 @@ object SteamQam { private const val TAG = "SteamQam" private const val EVAL_MS = 6_000L - internal fun script(on: Boolean): String = """(() => { + /** [aspect] is the panel's width over height: the menu is laid out at that shape so every tab shows at one scale. */ + internal fun script(on: Boolean, aspect: Float = 0f): String = """(() => { const g = globalThis, QAM = 2; const W = SteamUIStore.WindowStore.SteamUIWindows[0]; const m = W.MenuStore, c = W.m_CompositionStateStore; @@ -25,6 +26,7 @@ object SteamQam { const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0"); const held = () => g.__ddQamUntil > Date.now(); const ours = () => held() && m.m_eOpenSideMenu === QAM; + const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0; if (!c.__ddQam) { c.__ddQam = c.ComputeOverallMinimumRequestedComposition; c.ComputeOverallMinimumRequestedComposition = function (...a) { @@ -54,8 +56,9 @@ object SteamQam { v.__ddQam = v.SetBounds; v.SetBounds = function (x, y, w, h, ...r) { v.__ddAsked = [x, y, w, h]; - if (w > 0 && ours()) x = popup.m_popup.innerWidth + 64; + if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; } v.__ddAt = x; + v.__ddW = w; return v.__ddQam.call(this, x, y, w, h, ...r); }; } @@ -80,15 +83,17 @@ object SteamQam { for (const v of views()) { if (!v.__ddAsked) { const b = v.GetBounds?.(); - if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; } + if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; v.__ddW = b.width; } } - if (v.__ddAsked?.[2] > 0 && v.__ddAt < popup.m_popup.innerWidth) v.SetBounds(...v.__ddAsked); + const a = v.__ddAsked; + if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || (width(a[3]) && v.__ddW !== width(a[3])))) v.SetBounds(...a); } const main = nav?.m_rgGamepadNavigationTrees?.find(t => t.m_ID === "GamepadUI_Full_Root"); if (main && nav.m_LastActiveNavTree?.m_ID?.startsWith("QuickAccess")) nav.SetActiveNavTree(main); backdrop(true); }; g.__ddQamUntil = ${if (on) "Date.now() + $LEASE_MS" else "0"}; + ${if (on && aspect > 0f) "g.__ddQamAspect = $aspect;" else ""} keep(); if (held() && !g.__ddQamTimer) { g.__ddQamTimer = setInterval(() => { @@ -99,7 +104,7 @@ object SteamQam { return m.m_eOpenSideMenu; })()""" - fun hold(context: Context): Int? = eval(context, script(true))?.toIntOrNull() + fun hold(context: Context, aspect: Float): Int? = eval(context, script(true, aspect))?.toIntOrNull() fun release(context: Context, relayPort: Int) { eval(context, script(false)) diff --git a/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt index 5a1887766a..c94b8b3a28 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt @@ -38,6 +38,7 @@ import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.input.pointer.PointerEventType import androidx.compose.ui.input.pointer.pointerInput +import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag @@ -112,6 +113,8 @@ internal fun SteamQamPanel() { val holder = remember { arrayOfNulls(1) } val relay = remember { intArrayOf(0) } val live = remember { java.util.concurrent.atomic.AtomicBoolean(false) } + val aspect = remember { floatArrayOf(0f) } + val measure = Modifier.fillMaxSize().onSizeChanged { if (it.height > 0) aspect[0] = it.width.toFloat() / it.height } val show = { frame: ImageBitmap -> image = frame; QamCache.image = frame; live.set(true) } DisposableEffect(Unit) { onDispose { @@ -133,7 +136,11 @@ internal fun SteamQamPanel() { delay(FAST_TICK_MS) continue } - val open = SteamQam.hold(context) + if (aspect[0] == 0f) { + delay(FAST_TICK_MS) + continue + } + val open = SteamQam.hold(context, aspect[0]) failed = open == null if (open == SteamQam.QUICK_ACCESS) { var page = holder[0] @@ -179,10 +186,12 @@ internal fun SteamQamPanel() { if (img != null && l != null && l[0] > 0f) QamFrame(img, l[0], l[1], l[3].coerceIn(l[0] * 0.25f, l[0])) else null } if (f == null) { - if (slow) PanelNote(stringResource(if (failed) R.string.bottom_qam_unavailable else R.string.achievements_reading)) + Box(measure) { + if (slow) PanelNote(stringResource(if (failed) R.string.bottom_qam_unavailable else R.string.achievements_reading)) + } return } - BoxWithConstraints(Modifier.fillMaxSize().background(f.fill)) { + BoxWithConstraints(measure.background(f.fill)) { val density = LocalDensity.current val boxW = with(density) { maxWidth.toPx() } val boxH = with(density) { maxHeight.toPx() } diff --git a/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt b/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt index ee57cc5905..d4e6681a1d 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt @@ -2,6 +2,7 @@ package com.droiddeck.launcher.session import com.droiddeck.launcher.ui.QamLayout import org.junit.Assert.assertEquals +import org.junit.Assert.assertFalse import org.junit.Assert.assertNull import org.junit.Assert.assertTrue import org.junit.Test @@ -38,10 +39,16 @@ class SteamQamTest { assertTrue(SteamQam.script(false).contains("g.__ddQamUntil = 0;")) } + @Test fun theMenuIsLaidOutAtThePanelsShapeOnlyWhileHeld() { + assertTrue(SteamQam.script(true, 1.5f).contains("g.__ddQamAspect = 1.5;")) + assertFalse(SteamQam.script(true).contains("g.__ddQamAspect =")) + assertFalse(SteamQam.script(false, 1.5f).contains("g.__ddQamAspect =")) + } + @Test fun whileHeldTheMenuStaysOffTheTopScreenAndOutOfTheGamesWay() { val script = SteamQam.script(true) assertTrue(script.contains("return v === 2 && ours() ? 1 : v;")) - assertTrue(script.contains("if (w > 0 && ours()) x = popup.m_popup.innerWidth + 64;")) + assertTrue(script.contains("if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; }")) assertTrue(script.contains("nav.m_LastActiveNavTree?.m_ID?.startsWith(\"QuickAccess\")")) assertTrue(script.contains("if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus();")) } diff --git a/docs/development/bottom-screen.md b/docs/development/bottom-screen.md index f2ce6d49d5..95de9b45dd 100644 --- a/docs/development/bottom-screen.md +++ b/docs/development/bottom-screen.md @@ -170,7 +170,7 @@ Details: [bottom-screen-companion-api.md](bottom-screen-companion-api.md). Plugin loaders expose Steam's CEF DevTools so the menu can be viewed in a desktop browser, but it renders only while it is open on the main screen. The panel keeps it open without covering the top screen: - Steam's UI is told to open the menu and keep it open: its composition request is capped at "notification" while the menu is ours, so gamescope keeps focus on the game, and losing focus no longer closes it. Gamepad focus moves from the menu back to the main UI only when the menu took it, so Steam's own popups keep the controller. The blurred backdrop is hidden. -- The menu's browser view is placed just outside the Big Picture window through its own `SetBounds`, so it keeps rendering but never shows on top, including while Steam slides it wider for Friends and chat. +- The menu's browser view is placed just outside the Big Picture window through its own `SetBounds`, so it keeps rendering but never shows on top, including while Steam slides it wider for Friends and chat. The view is also given the panel's shape (about 712 × 463 instead of Steam's 856 × 463), so every tab shows at the same scale: Friends uses its compact list until a chat is opened, and the list with the chat then fills the panel. - A timer inside Steam keeps this state every 250 ms, so the menu comes back, on the tab it was showing, as soon as Steam's main menu or a full-screen page such as Decky's store closes. It runs on a 5 s lease that the panel renews each second: if the app stops, Steam returns to normal by itself. - The hold starts only once the session is ready: holding the menu before Steam's first frame kept gamescope from presenting anything. - `droiddeck-qam-relay` relays the app to the DevTools port, which only answers clients inside the guest. The panel streams the menu with `Page.startScreencast`, scales its content to the panel and fills the rest with the menu's own background, and forwards touches on the menu with `Input.dispatchTouchEvent`. When the menu is narrower than the panel, a chevron in the free space on each side steps it left, centre or right; the choice is kept. Returning to the panel shows the last frame at once while the stream reconnects, and the first frame after a cold start takes about 1.4 s. diff --git a/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png b/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png index 25ce2514cf..bb98a6b719 100644 Binary files a/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png and b/docs/development/evidence/bottom-screen-qam-friends-2026-11-27.png differ