From cad2361bd11a0ae278e79547fb446dccf049e483 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Fri, 27 Nov 2026 00:03:00 -0500 Subject: [PATCH] fix(bottom): the Quick Access button still opens the menu on the top screen --- .../droiddeck/launcher/session/SteamQam.kt | 37 +++++++++++++++++-- .../launcher/ui/BottomSteamQamPanel.kt | 15 +++++--- .../launcher/session/SteamQamTest.kt | 14 +++++++ docs/development/bottom-screen.md | 1 + 4 files changed, 57 insertions(+), 10 deletions(-) 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 7aa52347a1..43c19f2f7a 100644 --- a/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt +++ b/app/src/main/java/com/droiddeck/launcher/session/SteamQam.kt @@ -25,7 +25,7 @@ object SteamQam { const nav = W.m_FocusNavContext; const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0"); const held = () => g.__ddQamUntil > Date.now(); - const ours = () => held() && m.m_eOpenSideMenu === QAM; + const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop; const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0; if (!c.__ddQam) { c.__ddQam = c.ComputeOverallMinimumRequestedComposition; @@ -34,7 +34,7 @@ object SteamQam { return v === 2 && ours() ? 1 : v; }; m.__ddQam = m.OnMenuDeactivated; - m.OnMenuDeactivated = function (d) { if (d === QAM && held()) return; return m.__ddQam.call(this, d); }; + m.OnMenuDeactivated = function (d) { if (d === QAM && held() && !g.__ddQamTop) return; return m.__ddQam.call(this, d); }; } const views = () => popup?.m_rgChildBrowserViews || []; const backdrop = (hide) => { @@ -63,6 +63,7 @@ object SteamQam { }; } if (!held()) { + g.__ddQamTop = false; if (!g.__ddQamOn) return; g.__ddQamOn = false; backdrop(false); @@ -70,6 +71,26 @@ object SteamQam { c.EnsureCorrectComposition?.(); return; } + // The Quick Access button shows the menu on the top screen as usual; closing it there parks it again. + const press = W.m_flLastQuickAccessPressMS || 0; + if (g.__ddQamPress === undefined) g.__ddQamPress = press; + if (press !== g.__ddQamPress) { + g.__ddQamPress = press; + g.__ddQamTop = !g.__ddQamTop; + if (!g.__ddQamTop) { if (m.m_eOpenSideMenu === QAM) m.CloseSideMenus(); return; } + backdrop(false); + if (m.m_eOpenSideMenu !== QAM) m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined); + for (const v of views()) if (v.__ddAsked?.[2] > 0) { v.__ddAt = v.__ddAsked[0]; v.__ddW = v.__ddAsked[2]; v.__ddQam.call(v, ...v.__ddAsked); } + c.EnsureCorrectComposition?.(); + return; + } + if (g.__ddQamTop) { + if (m.m_eOpenSideMenu === QAM) { + if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab; + return; + } + g.__ddQamTop = false; + } const decky = !!g.DeckyPluginLoader?.tabsHook?.qamBrowserViewPatch; // Decky hooks the menu after Steam starts; the menu has to unmount for its tab to appear, so reopen on the next tick. if (m.m_eOpenSideMenu === QAM && decky && !g.__ddQamDecky) { g.__ddQamDecky = true; m.CloseSideMenus(); return; } @@ -102,10 +123,18 @@ object SteamQam { if (!held() && !g.__ddQamOn) { clearInterval(g.__ddQamTimer); g.__ddQamTimer = 0; } }, 250); } - return m.m_eOpenSideMenu; + return JSON.stringify([m.m_eOpenSideMenu, g.__ddQamTop ? 1 : 0]); })()""" - fun hold(context: Context, aspect: Float): Int? = eval(context, script(true, aspect))?.toIntOrNull() + /** [open] is Steam's open side menu; [top] is true while the menu is shown on the top screen. */ + data class Hold(val open: Int, val top: Boolean) + + fun hold(context: Context, aspect: Float): Hold? = eval(context, script(true, aspect))?.let(::parseHold) + + internal fun parseHold(text: String): Hold? = runCatching { + val a = JSONArray(text) + Hold(a.getInt(0), a.getInt(1) == 1) + }.getOrNull() 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 e799659058..e4578d17bd 100644 --- a/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt +++ b/app/src/main/java/com/droiddeck/launcher/ui/BottomSteamQamPanel.kt @@ -76,6 +76,8 @@ internal class QamFrame(val image: ImageBitmap, val cssWidth: Float, val cssHeig } internal object QamLayout { + private const val WIDE_CSS = "div.BasicUI { width: 100% !important; } div[class*=\\\"tab_\\\"] { max-width: none !important; }" + /** Scale and left edge of the menu in a box; [align] -1, 0 or 1 places a narrower menu left, centred or right. */ fun fit(boxWidth: Float, boxHeight: Float, contentRight: Float, cssHeight: Float, align: Int = 0): Pair { val scale = min(boxWidth / contentRight, boxHeight / cssHeight) @@ -85,9 +87,10 @@ internal object QamLayout { fun toCss(x: Float, y: Float, scale: Float, left: Float): Pair = (x - left) / scale to y / scale /** Makes the menu follow the panel-shaped view (Steam sizes it once, on open) and lifts each tab's 300 px cap, then measures where the content ends. */ - const val CONTENT_SCRIPT = "(() => { let s = document.getElementById('dd-qam-wide'); " + + /** [wide] is false while the menu is shown on the top screen, where it keeps Steam's own layout. */ + fun contentScript(wide: Boolean): String = "(() => { let s = document.getElementById('dd-qam-wide'); " + "if (!s) { s = document.createElement('style'); s.id = 'dd-qam-wide'; document.head.appendChild(s); } " + - "const css = 'div.BasicUI { width: 100% !important; } div[class*=\"tab_\"] { max-width: none !important; }'; " + + "const css = '${if (wide) WIDE_CSS else ""}'; " + "if (s.textContent !== css) s.textContent = css; if (document.scrollingElement.scrollLeft) document.scrollingElement.scrollLeft = 0; " + "const w = innerWidth; let right = 0; for (const e of document.body.querySelectorAll('*')) { " + "const r = e.getBoundingClientRect(); const tab = /(^| )tab_/.test(String(e.className)); " + @@ -146,9 +149,9 @@ internal fun SteamQamPanel() { delay(FAST_TICK_MS) continue } - val open = SteamQam.hold(context, aspect[0]) - failed = open == null - if (open == SteamQam.QUICK_ACCESS) { + val held = SteamQam.hold(context, aspect[0]) + failed = held == null + if (held?.open == SteamQam.QUICK_ACCESS) { var page = holder[0] if (page == null || page.closed) { page?.close() @@ -174,7 +177,7 @@ internal fun SteamQamPanel() { page?.call("Page.captureScreenshot", JSONObject().put("format", "jpeg").put("quality", 85)) ?.optJSONObject("result")?.optString("data")?.let(::decodeFrame)?.let(show) } - (page?.evaluate(QamLayout.CONTENT_SCRIPT) as? String)?.let { text -> + (page?.evaluate(QamLayout.contentScript(wide = !held.top)) as? String)?.let { text -> runCatching { val a = JSONArray(text) val layout = floatArrayOf(a.getDouble(0).toFloat(), a.getDouble(1).toFloat(), a.getDouble(2).toFloat(), a.getDouble(3).toFloat()) 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 d4e6681a1d..59a6be351c 100644 --- a/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt +++ b/app/src/test/java/com/droiddeck/launcher/session/SteamQamTest.kt @@ -39,6 +39,20 @@ class SteamQamTest { assertTrue(SteamQam.script(false).contains("g.__ddQamUntil = 0;")) } + @Test fun readsWhetherTheMenuIsShownOnTheTopScreen() { + assertEquals(SteamQam.Hold(2, false), SteamQam.parseHold("[2,0]")) + assertEquals(SteamQam.Hold(2, true), SteamQam.parseHold("[2,1]")) + assertNull(SteamQam.parseHold("2")) + } + + @Test fun theQuickAccessButtonTogglesTheTopScreenAndTheWideLayoutFollows() { + val script = SteamQam.script(true) + assertTrue(script.contains("const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop;")) + assertTrue(script.contains("if (press !== g.__ddQamPress) {")) + assertTrue(QamLayout.contentScript(true).contains("max-width: none !important")) + assertFalse(QamLayout.contentScript(false).contains("max-width: none")) + } + @Test fun theMenuIsLaidOutAtThePanelsShapeOnlyWhileHeld() { assertTrue(SteamQam.script(true, 1.5f).contains("g.__ddQamAspect = 1.5;")) assertFalse(SteamQam.script(true).contains("g.__ddQamAspect =")) diff --git a/docs/development/bottom-screen.md b/docs/development/bottom-screen.md index a192567da5..62ec76215b 100644 --- a/docs/development/bottom-screen.md +++ b/docs/development/bottom-screen.md @@ -174,6 +174,7 @@ Plugin loaders expose Steam's CEF DevTools so the menu can be viewed in a deskto - 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`. If a Steam update brings back a narrow tab, 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. +- The Quick Access button still shows the menu on the top screen, in Steam's own layout and with the controller; closing it there (B or the button again) returns it to the bottom screen on the same tab. - Leaving the panel closes the menu and turns the patches off; the Steam button and the normal Quick Access button then work as before. Opening Steam's main menu replaces the Quick Access menu for as long as it is open, as on a Deck. Checked with Decky Loader 3.3.1 enabled: its tab renders and takes touch, and its store opens full screen on top with the controller, then returns to the Decky tab below. Decky hooks the menu after Steam starts, so the panel reopens it once when that happens.