diff --git a/device/bluejay/NOTES.md b/device/bluejay/NOTES.md index 99ba6a42c..df85e7ede 100644 --- a/device/bluejay/NOTES.md +++ b/device/bluejay/NOTES.md @@ -50,6 +50,14 @@ keeps manual GS101 success marking on hold and requires a known-good image flash before the boot that would spend B's final try. This note changes no tool, guard, package or runbook and performs no phone operation. +## 2026-11-11: physical Back gestures + +On November 11, both edges went back one page in Chromium on the Pixel 6a. +With the keyboard open, the first Back hid it and left the page in place. +A Qt dialog closed on Escape delivered through `wtype`. The phone ran +`omamobile-shell 0.2.119-1` from the combined build at `83326ed6`. +The revised package still needs its own handset run. + ## 2026-11-09: review split and slot-success audit (offline) The development source remains inspectable in [#543](https://github.com/derekross/omarchy-mobile/pull/543). diff --git a/docs/TOUCH-PLAN.md b/docs/TOUCH-PLAN.md index 38ad3136e..d351bf1c4 100644 --- a/docs/TOUCH-PLAN.md +++ b/docs/TOUCH-PLAN.md @@ -96,6 +96,14 @@ Hyprland transform 1 or 3 gives a 1040x480 logical px output (portrait is 480x10 **What remains after batch 4:** 1.11 (gum prompts as sheets: onboarding, PIN setup), 1.12's Nightlight and Reminder tiles, 2.1's per-token font seeds (the 12 px floor is in; the overrides need a theme-change check), 2.7 contrast (4.5:1 for placeholder and secondary text), 3.1 per-site web-app flags, 3.3's upstreamable `menu.d` patch (the rows are hidden by `omamobile-setup-user` for now), 3.6 haptics, 3.7 polish, and the Omarchy patches 3-6 below. +## Browser history after native Back (1.2) + +On November 11, both edges went back one page in Chromium on the Pixel 6a. +With the keyboard open, the first Back hid it and left the page in place. +A Qt dialog closed on Escape delivered through `wtype`. The phone ran +`omamobile-shell 0.2.119-1` from the combined build at `83326ed6`. +The revised package still needs its own handset run. + ## Suggested order 1. Phase 0 (one `omamobile-omarchy` and firstboot release, plus a `phone-smoke` lock check). diff --git a/packages/omamobile-shell/plugins/README.md b/packages/omamobile-shell/plugins/README.md index 6209a381d..c3c8f8abe 100644 --- a/packages/omamobile-shell/plugins/README.md +++ b/packages/omamobile-shell/plugins/README.md @@ -1205,3 +1205,10 @@ What upstream needs instead, smallest first: `omarchy.notifications` only to full bars. Quick settings calls the `notifications` IPC target on its own shell instance (`qs ipc -p Quickshell.shellDir`) instead. + +Browser history follows the native Back handlers. Both edges use Alt+Left for +an activated Chrome/Chromium window whose current Wayland and Hyprland handles +agree with the window captured at gesture start. Modal, changed or uncertain +focus uses the existing Escape/Home path. Quick settings, drawer and recents +register active handlers with BackLink so navigation stays in their topmost +surface. diff --git a/packages/omamobile-shell/plugins/omamobile.back/Back.qml b/packages/omamobile-shell/plugins/omamobile.back/Back.qml index ddb68fcc4..4c0804861 100644 --- a/packages/omamobile-shell/plugins/omamobile.back/Back.qml +++ b/packages/omamobile-shell/plugins/omamobile.back/Back.qml @@ -5,14 +5,15 @@ import Quickshell.Hyprland import Quickshell.Wayland import qs.Commons import qs.Commons as Commons -import "BackModel.js" as BackModel import "BackLink.js" as BackLink +import "BackModel.js" as BackModel // The back gesture, as on Android (TOUCH-PLAN 1.2): swipe in from the left // or right edge of the screen and let go to go back. "Back" is Escape, sent // to whatever has the keyboard focus (BackModel.js has how): it closes app // dialogs, menus and popovers that have no other way out on a touch screen, -// and the shell's own sheets and drawer, which all close on Escape. An app +// and the shell's own sheets and drawer. After native handling, an activated +// Chrome/Chromium window goes back in browser history from either edge. An app // goes back one level on it, and at its top level asks for the home screen // (omamobile-home), as Back at an app's first screen does on Android. // @@ -42,14 +43,21 @@ Item { // `shell call omamobile.back back ''`: the same as the gesture. One Back // does one thing (BackLink.js): the on-screen keyboard is put away, or // else the topmost shell surface that registered closes, or else Escape - // goes to the focused window. Returns what used it. - function back() { + // goes to the focused window, with history Back for a coherent browser. + // Returns what used it. + function back(payloadJson, startedToplevel) { var used = BackLink.back() if (used !== "") { console.log("omamobile-back:", used) return used } - Quickshell.execDetached(BackModel.ESCAPE_ARGV) + var active = ToplevelManager.activeToplevel + var started = startedToplevel === undefined ? active : startedToplevel + var hypr = Hyprland.activeToplevel + var browser = !!active && active === started + && active.activated === true && !active.parent + && !!hypr && hypr.wayland === active && BackModel.isBrowser(active.appId) + Quickshell.execDetached(browser ? BackModel.BROWSER_BACK_ARGV : BackModel.ESCAPE_ARGV) return "ok" } @@ -170,6 +178,7 @@ Item { readonly property bool armed: BackModel.fires(inward, across, BackModel.THRESHOLD) property real atY: 0 property bool wasArmed: false + property var startedToplevel: null onCentroidChanged: if (active) atY = centroid.position.y // One threshold tick per gesture, even if the finger crosses back. property bool feedbackSent: false @@ -182,9 +191,9 @@ Item { } } onActiveChanged: { - if (active) { atY = centroid.position.y; wasArmed = false; feedbackSent = false; return } + if (active) { startedToplevel = ToplevelManager.activeToplevel; atY = centroid.position.y; wasArmed = false; feedbackSent = false; return } console.log("omamobile-back: swipe", win.rightEdge ? "right" : "left", wasArmed ? "back" : "") - if (wasArmed) root.back() + if (wasArmed) root.back("", startedToplevel) } } } diff --git a/packages/omamobile-shell/plugins/omamobile.back/BackModel.js b/packages/omamobile-shell/plugins/omamobile.back/BackModel.js index 2fc787fa0..2f32e0d43 100644 --- a/packages/omamobile-shell/plugins/omamobile.back/BackModel.js +++ b/packages/omamobile-shell/plugins/omamobile.back/BackModel.js @@ -47,6 +47,20 @@ var ESCAPE_ARGV = ["sh", "-c", // asks. `shell call omamobile.back home ''` runs it too. var HOME_ARGV = ["omamobile-home"] +// Browser history is chosen in QML after native Back handlers. Use the same +// virtual keyboard as Escape; retain the ordered dispatch pair as fallback. +var BROWSER_BACK_ARGV = ["sh", "-c", + 'if command -v wtype >/dev/null 2>&1; then exec wtype -M alt -k Left -m alt; fi; ' + + 'hyprctl dispatch "$1" >/dev/null; sleep 0.05; hyprctl dispatch "$2" >/dev/null', "sh", + 'hl.dsp.send_key_state({ mods = "ALT", key = "code:113", state = "down" })', + 'hl.dsp.send_key_state({ mods = "ALT", key = "code:113", state = "up" })'] + +function isBrowser(appId) { + var id = String(appId || "") + return ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser", "org.chromium.Chromium", "com.google.Chrome"].indexOf(id) !== -1 + || /^chrome-.+-(?:Default|Profile(?:_\d+)?)$/.test(id) +} + // How far the finger has to come in from the edge (logical px), and how far // a swipe may wander along the edge for each pixel it comes in: a mostly // vertical drag that starts on the strip is not a back. @@ -73,7 +87,7 @@ function inwardFor(rightEdge, translationX) { } if (typeof module !== "undefined") { - module.exports = { TERMINALS: TERMINALS, isTerminal: isTerminal, + module.exports = { BROWSER_BACK_ARGV: BROWSER_BACK_ARGV, isBrowser: isBrowser, TERMINALS: TERMINALS, isTerminal: isTerminal, ESCAPE_DOWN: ESCAPE_DOWN, ESCAPE_UP: ESCAPE_UP, ESCAPE_ARGV: ESCAPE_ARGV, HOME_ARGV: HOME_ARGV, THRESHOLD: THRESHOLD, progress: progress, fires: fires, inwardFor: inwardFor } diff --git a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml index 8ccbb3505..a1685085c 100644 --- a/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.launcher/Launcher.qml @@ -51,6 +51,23 @@ Item { // `opened` is the drawer; the dock is always on screen. property bool opened: false + + Loader { + source: Qt.resolvedUrl("../omamobile.back/BackLinkClient.qml") + onLoaded: { + item.name = "app drawer" + item.handler = function() { return root.navigationBack() } + item.active = Qt.binding(function() { return root.opened }) + } + } + + function navigationBack() { + if (!opened) return false + if (input.activeFocus && query) query = "" + else dismiss(0) + return true + } + property string query: "" property var apps: [] property int appsRevision: 0 diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml index a7e21db5e..02a085290 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml @@ -52,6 +52,36 @@ Item { property var manifest: null property bool opened: false + + Loader { + source: Qt.resolvedUrl("../omamobile.back/BackLinkClient.qml") + onLoaded: { + item.name = "quick settings" + item.handler = function() { return root.navigationBack() } + item.active = Qt.binding(function() { return root.navigationOpen }) + } + } + + readonly property bool navigationOpen: opened || wifiPicker.opened || bluetoothPanelItem.opened || recordPanelItem.opened + + function navigationBack() { + if (wifiPicker.opened) { + if (wifiPicker.sheet) wifiPicker.cancelSheet() + else wifiPicker.backRequested() + return true + } + if (bluetoothPanelItem.opened) { + if (bluetoothPanelItem.activeSheet) bluetoothPanelItem.cancelSheet() + else bluetoothPanelItem.backRequested() + return true + } + if (recordPanelItem.opened) { recordPanelItem.backRequested(); return true } + if (!opened) return false + if (editing) finishEditing() + else dismiss() + return true + } + readonly property string pluginId: (manifest && manifest.id) || "omamobile.quicksettings" // ---------------------------------------------------------------- lifecycle diff --git a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml index 7a48e2565..293f8f3da 100644 --- a/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml +++ b/packages/omamobile-shell/plugins/omamobile.switcher/Switcher.qml @@ -42,6 +42,24 @@ Item { property bool opened: false + Loader { + source: Qt.resolvedUrl("../omamobile.back/BackLinkClient.qml") + onLoaded: { + item.name = "recent apps" + item.handler = function() { return root.navigationBack() } + item.active = Qt.binding(function() { return root.opened }) + } + } + + function navigationBack() { + if (!opened) return false + if (actionsOpen && actionPage === "pick") actionPage = "menu" + else if (actionsOpen) closeActions() + else dismiss() + return true + } + + // Newest first, like Android's recents. readonly property var windows: { var list = ToplevelManager.toplevels.values.slice() diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index d6efa4d36..4450f3d5a 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -97,7 +97,7 @@ for sc in 3 '8 \/ 3'; do t=$(printf 'local omarchy_monitor_scale = 2\n' | sed "s/^local omarchy_monitor_scale = .*/local omarchy_monitor_scale = $sc/") [[ $t == 'local omarchy_monitor_scale = 3' || $t == 'local omarchy_monitor_scale = 8 / 3' ]] || fail "the seeded scale line ($t)" done -grep -c 'Quickshell.execDetached(BackModel.ESCAPE_ARGV)' "$b" >/dev/null || fail "back sends Escape through BackModel" +grep -c 'Quickshell.execDetached(browser ? BackModel.BROWSER_BACK_ARGV : BackModel.ESCAPE_ARGV)' "$b" >/dev/null || fail "back sends Escape through BackModel" grep -c 'WlrLayershell.namespace: "omamobile-back"' "$b" >/dev/null || fail "back strips' namespace" grep -c 'mask: Region { item: strip }' "$b" >/dev/null || fail "only the edge strip takes touches" grep -c 'exclusionMode: ExclusionMode.Normal' "$b" >/dev/null || fail "back strips stay clear of the bar and the keyboard" @@ -1262,3 +1262,11 @@ else pass "Back threshold feedback: once per gesture, both edges and retreat" fi env -u OMAMOBILE_POWER_KEY_ANDROID bash test/power-overlap.sh || fail "overlapping power-key presses" +rc=0; out=$(python3 -B test/back-navigation.py 2>&1) || rc=$? +if [[ $rc == 77 ]]; then + pass "Back navigation # SKIP no qmltestrunner" +elif [[ $rc != 0 ]]; then + printf '%s\n' "$out" >&2; fail "Back navigation" +else + pass "Back navigation" +fi diff --git a/packages/omamobile-shell/test/back-haptic.py b/packages/omamobile-shell/test/back-haptic.py index 594c3eb1a..a11979953 100644 --- a/packages/omamobile-shell/test/back-haptic.py +++ b/packages/omamobile-shell/test/back-haptic.py @@ -28,7 +28,7 @@ def handler(name): raise AssertionError("unterminated handler") -h = {"armed": handler("onArmedChanged"), "active": handler("onActiveChanged")} +h = {"armed": handler("onArmedChanged"), "active": handler("onActiveChanged").replace("ToplevelManager.activeToplevel", "manager.activeToplevel")} if args.negative: h["armed"] = h["armed"].replace("armed && !feedbackSent", "armed") @@ -40,6 +40,7 @@ def handler(name): property int backs:0 function haptic(){ticks++} function back(){backs++} + QtObject {id:manager;property var activeToplevel:null} QtObject {id:win;property bool rightEdge:false} QtObject {id:centroid;property point position:Qt.point(0,20)} QtObject { @@ -48,6 +49,7 @@ def handler(name): property bool armed:false property bool wasArmed:false property bool feedbackSent:false + property var startedToplevel:null property real atY:0 onArmedChanged: ARMED onActiveChanged: ACTIVE diff --git a/packages/omamobile-shell/test/back-model.js b/packages/omamobile-shell/test/back-model.js index 975f7366b..bb59d7be6 100644 --- a/packages/omamobile-shell/test/back-model.js +++ b/packages/omamobile-shell/test/back-model.js @@ -58,6 +58,44 @@ test("a terminal gets no Escape: Back goes home; every other window gets the vir assert.ok(M.isTerminal("foot") && M.isTerminal("org.omarchy.terminal") && !M.isTerminal("") && !M.isTerminal("Foot")) }) +test("browser history uses the virtual keyboard with the ordered Alt+Left dispatch fallback", () => { + const [sh, c, script, name, down, up] = M.BROWSER_BACK_ARGV + assert.deepStrictEqual([sh, c, name], ["sh", "-c", "sh"]) + assert.strictEqual(down, 'hl.dsp.send_key_state({ mods = "ALT", key = "code:113", state = "down" })') + assert.strictEqual(up, down.replace('"down"', '"up"')) + assert.ok(script.indexOf("exec wtype -M alt -k Left -m alt") < script.indexOf('hyprctl dispatch "$1"')) + assert.ok(script.indexOf('hyprctl dispatch "$1"') < script.indexOf("sleep 0.05")) + assert.ok(script.indexOf("sleep 0.05") < script.indexOf('hyprctl dispatch "$2"')) +}) + +test("browser Back releases Alt and runs only the selected key path", () => { + const fs = require("fs"), os = require("os"), cp = require("child_process") + const dir = fs.mkdtempSync(path.join(os.tmpdir(), "back-browser-")) + const log = path.join(dir, "log") + const stub = (name, body) => fs.writeFileSync(path.join(dir, name), "#!/bin/sh\n" + body + "\n", { mode: 0o755 }) + try { + const sleep = cp.execSync("command -v sleep", { shell: "/bin/sh" }).toString().trim() + fs.symlinkSync(sleep, path.join(dir, "sleep")) + stub("hyprctl", 'echo "hyprctl $*" >> "$LOG"') + stub("wtype", 'echo "wtype $*" >> "$LOG"') + const run = () => { + fs.writeFileSync(log, "") + cp.execFileSync("/bin/sh", M.BROWSER_BACK_ARGV.slice(1), { env: { PATH: dir, LOG: log } }) + return fs.readFileSync(log, "utf8").trim().split("\n") + } + assert.deepStrictEqual(run(), ["wtype -M alt -k Left -m alt"]) + fs.rmSync(path.join(dir, "wtype")) + assert.deepStrictEqual(run(), ["hyprctl dispatch " + M.BROWSER_BACK_ARGV[4], "hyprctl dispatch " + M.BROWSER_BACK_ARGV[5]]) + } finally { fs.rmSync(dir, { recursive: true, force: true }) } +}) + +test("browser matching includes installed apps without matching helpers or prompts", () => { + for (const id of ["google-chrome", "chromium", "chromium-browser", "chrome-mail.google.com__-Default", "chrome-abcdef-Profile_1"]) + assert.ok(M.isBrowser(id), id) + for (const id of [null, "", "foot", "polkit", "chrome-password-dialog", "chromium-prompt", "google-chrome-helper"]) + assert.ok(!M.isBrowser(id), id) +}) + test("home is the shell's one command, with nothing of Hyprland in it", () => { assert.deepStrictEqual(M.HOME_ARGV, ["omamobile-home"]) }) diff --git a/packages/omamobile-shell/test/back-navigation.py b/packages/omamobile-shell/test/back-navigation.py new file mode 100644 index 000000000..8e6739c9c --- /dev/null +++ b/packages/omamobile-shell/test/back-navigation.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Run candidate routing and panel callbacks in Qt, with key injection stubbed.""" +import os +from pathlib import Path +import shutil +import subprocess +import tempfile + +pkg = Path(__file__).resolve().parents[1] + + +def function(path, name): + source = path.read_text() + start = source.index(" function " + name + "(") + brace = source.index("{", start) + depth = 0 + for end in range(brace, len(source)): + if source[end] == "{": + depth += 1 + elif source[end] == "}": + depth -= 1 + if depth == 0: + return source[start:end + 1] + raise AssertionError("unterminated function") + + +back = function(pkg / "plugins/omamobile.back/Back.qml", "back") +back = back.replace("ToplevelManager.activeToplevel", "manager.activeToplevel").replace("Hyprland.activeToplevel", "hyprSource.activeToplevel").replace("Quickshell.execDetached", "root.record") +quick = function(pkg / "plugins/omamobile.quicksettings/QuickSettings.qml", "navigationBack").replace("function navigationBack", "function quickBack") +drawer = function(pkg / "plugins/omamobile.launcher/Launcher.qml", "navigationBack").replace("function navigationBack", "function drawerBack") +recents = function(pkg / "plugins/omamobile.switcher/Switcher.qml", "navigationBack").replace("function navigationBack", "function recentsBack") +qml = r'''import QtQuick +import QtTest +import "BackLink.js" as BackLink +import "BackModel.js" as BackModel +TestCase { + id: root; name: "BrowserBackRouting"; when: windowShown + property var calls: [] + property bool opened: false + property bool editing: false + property string query: "" + property bool actionsOpen: false + property string actionPage: "" + property int dismissals: 0 + property int returns: 0 + QtObject { id: manager; property var activeToplevel: null } + QtObject { id: hyprSource; property var activeToplevel: null } + QtObject { id: input; property bool activeFocus: false } + QtObject { id: wifiPicker; property bool opened: false; property string sheet: ""; function cancelSheet(){sheet=""} function backRequested(){opened=false; root.opened=true; root.returns++} } + QtObject { id: bluetoothPanelItem; property bool opened: false; property string activeSheet: ""; function cancelSheet(){activeSheet=""} function backRequested(){opened=false; root.opened=true; root.returns++} } + QtObject { id: recordPanelItem; property bool opened: false; function backRequested(){opened=false; root.opened=true; root.returns++} } + function record(argv) { calls.push(argv) } + function dismiss(speed) { opened=false; dismissals++ } + function finishEditing() { editing=false } + function closeActions() { actionsOpen=false } + BACK + QUICK + DRAWER + RECENTS + function browser() { var w={appId:"chromium",activated:true,parent:null}; manager.activeToplevel=w; hyprSource.activeToplevel={wayland:w}; return w } + function init() { + BackLink.clear(); calls=[]; opened=false; editing=false; query=""; input.activeFocus=false; actionsOpen=false; actionPage=""; dismissals=0; returns=0 + wifiPicker.opened=false; wifiPicker.sheet=""; bluetoothPanelItem.opened=false; bluetoothPanelItem.activeSheet=""; recordPanelItem.opened=false; browser() + } + function history() { compare(calls.length,1); compare(JSON.stringify(calls[0]),JSON.stringify(BackModel.BROWSER_BACK_ARGV)) } + function fallback() { compare(calls.length,1); compare(JSON.stringify(calls[0]),JSON.stringify(BackModel.ESCAPE_ARGV)) } + function test_bothEdgesBack() { var w=browser(); back("left",w); history(); calls=[]; back("right",w); history() } + function test_changedAndUnknownFocus() { var w=browser(); browser(); back("",w); fallback(); calls=[]; manager.activeToplevel=null; back(); fallback() } + function test_modalAndInactiveBrowser() { manager.activeToplevel.parent={}; back(); fallback(); calls=[]; browser().activated=false; back(); fallback() } + function test_otherAppAndDisagreement() { manager.activeToplevel.appId="foot"; back(); fallback(); calls=[]; browser(); hyprSource.activeToplevel=null; back(); fallback() } + Window { id: shellWindow; visible:true; width:20; height:20 } + function test_staleApplicationActiveDoesNotBlockBrowser() { shellWindow.requestActivate(); tryCompare(Qt.application,"state",Qt.ApplicationActive); browser(); back(); history() } + function test_keyboardBeforePanelBeforeHistory() { + var keyboard={}, panel={}; var hidden=0,closed=0 + BackLink.register(panel,function(){closed++;BackLink.unregister(panel);return true},"surface","panel") + BackLink.register(keyboard,function(){hidden++;BackLink.unregister(keyboard);return true},"keyboard","keyboard") + compare(back(),"keyboard"); compare(hidden,1); compare(closed,0); compare(calls.length,0) + compare(back(),"panel"); compare(closed,1); compare(calls.length,0) + back(); history() + } + function test_quickSettingsNestedWifi() { + wifiPicker.opened=true; wifiPicker.sheet="password" + BackLink.register(root,root.quickBack,"surface","quick settings") + back(); compare(wifiPicker.sheet,""); verify(wifiPicker.opened); compare(calls.length,0) + back(); verify(!wifiPicker.opened); verify(opened); compare(returns,1) + back(); compare(dismissals,1); compare(calls.length,0) + } + function test_quickSettingsBluetoothRecordAndEditing() { + bluetoothPanelItem.opened=true; bluetoothPanelItem.activeSheet="confirm" + BackLink.register(root,root.quickBack,"surface","quick settings") + back(); compare(bluetoothPanelItem.activeSheet,""); back(); compare(returns,1) + opened=false; recordPanelItem.opened=true; back(); compare(returns,2) + editing=true; back(); verify(!editing); verify(opened); compare(calls.length,0) + } + function test_drawerSearchThenDismiss() { + opened=true; query="apps"; input.activeFocus=true + BackLink.register(root,root.drawerBack,"surface","app drawer") + back(); compare(query,""); verify(opened); back(); verify(!opened); compare(dismissals,1); compare(calls.length,0) + } + function test_recentsPickThenMenuThenDismiss() { + opened=true; actionsOpen=true; actionPage="pick" + BackLink.register(root,root.recentsBack,"surface","recent apps") + back(); compare(actionPage,"menu"); verify(actionsOpen) + back(); verify(!actionsOpen); verify(opened) + back(); verify(!opened); compare(dismissals,1); compare(calls.length,0) + } + function test_closedOrFailingHandlerUsesUpstreamFallbackOrder() { + BackLink.register({},function(){return false},"surface","closed") + BackLink.register({},function(){throw new Error("failed handler")},"surface","failed") + back(); history() + } +} +'''.replace("\n BACK\n", "\n" + back + "\n").replace("\n QUICK\n", "\n" + quick + "\n").replace("\n DRAWER\n", "\n" + drawer + "\n").replace("\n RECENTS\n", "\n" + recents + "\n") +runner = shutil.which("qmltestrunner6") or shutil.which("/usr/lib/qt6/bin/qmltestrunner") +if not runner: + raise SystemExit(77) +with tempfile.TemporaryDirectory(prefix="browser-back-") as temporary: + directory = Path(temporary) + (directory / "runtime").mkdir(mode=0o700) + source = directory / "omamobile.back" + source.mkdir() + for name in ("BackLink.js", "BackModel.js"): + shutil.copyfile(pkg / "plugins/omamobile.back" / name, source / name) + (source / "tst_back.qml").write_text(qml) + env = os.environ.copy() + env.update(QT_QPA_PLATFORM="offscreen", QT_QUICK_BACKEND="software", QT_QPA_PLATFORMTHEME="generic", XDG_RUNTIME_DIR=str(directory / "runtime")) + env.pop("QT_PLUGIN_PATH", None) + env.pop("QT_QPA_GENERIC_PLUGINS", None) + result = subprocess.run([runner, "-input", str(source / "tst_back.qml")], env=env) + raise SystemExit(result.returncode) diff --git a/packages/omamobile-shell/test/back-surfaces.py b/packages/omamobile-shell/test/back-surfaces.py index 39258735e..b71f5404f 100755 --- a/packages/omamobile-shell/test/back-surfaces.py +++ b/packages/omamobile-shell/test/back-surfaces.py @@ -31,6 +31,9 @@ "omamobile.voice/Voice.qml": ["voice settings", "voice result"], "omamobile.home/Home.qml": ["home screen"], "omamobile.home/OwlCell.qml": ["widget screen"], + "omamobile.quicksettings/QuickSettings.qml": ["quick settings"], + "omamobile.launcher/Launcher.qml": ["app drawer"], + "omamobile.switcher/Switcher.qml": ["recent apps"], } @@ -86,6 +89,7 @@ def body_of(text, head): property bool oskOpen: false property bool languagesOpen: false property bool opened: false + property bool navigationOpen: false property bool screenOpen: false property bool authPending: false property string phase: "idle" @@ -94,6 +98,7 @@ def body_of(text, head): property var layersOver: ({}) property var calls: [] function note(n) { calls = calls.concat([n]) } + function navigationBack() { note("navigationBack"); opened = false; navigationOpen = false; return true } function hideKeyboard() { note("hideKeyboard"); oskOpen = false } function closeLanguages() { note("closeLanguages"); languagesOpen = false } function back() { note("back"); opened = false; screenOpen = false; return true } @@ -119,7 +124,8 @@ def body_of(text, head): ''' back_source = (plugins / "omamobile.back/Back.qml").read_text() -back_fn = body_of(back_source, " function back() {") +back_fn = body_of(back_source, " function back(payloadJson, startedToplevel) {") +back_fn = back_fn.replace("ToplevelManager.activeToplevel", "manager.activeToplevel").replace("Hyprland.activeToplevel", "hyprSource.activeToplevel") TEST = r'''import QtQuick import QtTest @@ -133,7 +139,9 @@ def body_of(text, head): name: "BackSurfaces" // Back.qml's own back(), as written. - function back() BACK_FN + function back(payloadJson, startedToplevel) BACK_FN + QtObject { id: manager; property var activeToplevel: null } + QtObject { id: hyprSource; property var activeToplevel: null } function names() { return BackLink.names().join(",") } function sent() { return Quickshell.executed.length } @@ -147,6 +155,9 @@ def body_of(text, head): Component { id: home; SurfHomeScreen {} } Component { id: wscreen; SurfWidgetScreen {} } Component { id: plain; BackLinkClient {} } + Component { id: quick; SurfQuickSettings {} } + Component { id: drawer; SurfAppDrawer {} } + Component { id: recents; SurfRecentApps {} } function init() { BackLink.clear(); Quickshell.executed = [] } @@ -167,6 +178,9 @@ def body_of(text, head): compare(JSON.stringify(Quickshell.executed[0]), JSON.stringify(BackModel.ESCAPE_ARGV)) } + function test_quickSettings() { alone(make(quick), "quick settings", function(o) { o.fake.navigationOpen = true }, "navigationBack") } + function test_appDrawer() { alone(make(drawer), "app drawer", function(o) { o.fake.opened = true }, "navigationBack") } + function test_recentApps() { alone(make(recents), "recent apps", function(o) { o.fake.opened = true }, "navigationBack") } function test_keyboard() { alone(make(kb), "keyboard", function(o) { o.fake.oskOpen = true }, "hideKeyboard") } function test_permissionSheet() { alone(make(perm), "permission sheet", function(o) { o.fake.opened = true }, "back") } function test_fingerprintSetup() { alone(make(finger), "fingerprint setup", function(o) { o.fake.screenOpen = true }, "back") }