From 5502164f96e284395d5cf1d5bb96f3772d2789f1 Mon Sep 17 00:00:00 2001 From: Marsel Nenaj <201385099+marselnenaj@users.noreply.github.com> Date: Sun, 8 Nov 2026 12:27:52 +0100 Subject: [PATCH] omamobile-shell 0.2.102: keep the shade viewport stable while sliding Calculate notification capacity from the sheet's resting position instead of its animated position. The shade still follows sheet movement, while expansion and screen geometry continue to update its available room. Exercise the production geometry expressions under real Qt bindings. The baseline changes room and height during reveal; the candidate keeps both stable and preserves final portrait, landscape and short-screen geometry. A control restoring the old calculation fails the assertions. Keep the change independent of host interfaces, safe-area extensions, backend scheduling and hardware support. The package increment is proposed from the current public main and can be adjusted by the maintainer at merge. No phone frame-rate or runtime qualification is claimed. Co-Authored-By: Codex --- .../omamobile.quicksettings/QuickSettings.qml | 5 +- packages/omamobile-shell/test/all | 13 ++ .../test/quicksettings-shade-layout.py | 100 +++++++++++++ .../test/quicksettings-shade-layout.qml.in | 136 ++++++++++++++++++ packages/omamobile-shell/version | 2 +- 5 files changed, 254 insertions(+), 2 deletions(-) create mode 100644 packages/omamobile-shell/test/quicksettings-shade-layout.py create mode 100644 packages/omamobile-shell/test/quicksettings-shade-layout.qml.in diff --git a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml index 23c455ebd..d342f858a 100644 --- a/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml +++ b/packages/omamobile-shell/plugins/omamobile.quicksettings/QuickSettings.qml @@ -1926,7 +1926,10 @@ Item { // Not "top": every Item already has a FINAL top anchor line, and // Qt 6.12 refuses to load a file that redeclares it. readonly property real shadeTop: root.wide ? sheet.y : sheet.y + sheet.height + Style.spacing.lg - readonly property real room: window.height - shadeTop - Style.gapsOut + // Sliding changes position, not the settled notification viewport. + // Expansion still updates the available room through sheet.height. + readonly property real restingTop: root.wide ? Style.gapsOut : Style.gapsOut + sheet.height + Style.spacing.lg + readonly property real room: window.height - restingTop - Style.gapsOut readonly property real insets: shade.contentTopInset + shade.contentBottomInset readonly property real listHeight: root.notifications.length > 0 ? shadeList.contentHeight : shadeEmpty.implicitHeight // The media card and the gap under it, when a player is up. diff --git a/packages/omamobile-shell/test/all b/packages/omamobile-shell/test/all index 4a242065b..2676f16e3 100755 --- a/packages/omamobile-shell/test/all +++ b/packages/omamobile-shell/test/all @@ -685,6 +685,19 @@ elif [[ $rc != 0 ]]; then else pass "the shade under touch: a swipe forgets one, a short one springs back, a tap taps, a drag scrolls" fi +# The notification viewport keeps its settled height during sheet motion. +rc=0 +out=$(python3 -B test/quicksettings-shade-layout.py \ + plugins/omamobile.quicksettings/QuickSettings.qml 2>&1) || rc=$? +if [[ $rc == 77 ]]; then + pass "stable notification viewport # SKIP no qmltestrunner" +elif [[ $rc != 0 ]]; then + printf '%s\n' "$out" >&2 + fail "stable notification viewport (test/quicksettings-shade-layout.py)" +else + pass "notification viewport stays stable while sliding and follows expansion" +fi + # The shade's media card (MPRIS): which player shows, what each control # calls, the seek bar, the card's tap. test/media-touch drives it; the art # rule and the order are in test/media-model.js; test/quicksettings-render diff --git a/packages/omamobile-shell/test/quicksettings-shade-layout.py b/packages/omamobile-shell/test/quicksettings-shade-layout.py new file mode 100644 index 000000000..ca228bff5 --- /dev/null +++ b/packages/omamobile-shell/test/quicksettings-shade-layout.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: MIT +"""Exercise actual QuickSettings geometry expressions under real Qt bindings.""" + +import argparse +import os +from pathlib import Path +import re +import shutil +import subprocess +import tempfile + + +def expression(section, name): + pattern = r"^ readonly property real " + name + r": (.+)$" + match = re.search(pattern, section, re.MULTILINE) + if not match: + raise RuntimeError("Missing production property " + name) + return match[1].replace("Style.", "style.") + + +def fixture(source, baseline): + section = source[source.index(" // ---------- The notification shade:"):] + position = re.search(r"^ y: (Style.gapsOut.+)$", source, re.MULTILINE) + if not position: + raise RuntimeError("Missing production sheet position") + + if baseline: + resting = ( + "root.wide ? style.gapsOut : " + "style.gapsOut + sheet.height + style.spacing.lg" + ) + churn = "verify(root.roomChanges > 3);\n verify(root.heightChanges > 3);" + drag = "compare(shade.height, before + 50);" + else: + resting = expression(section, "restingTop") + churn = "compare(root.roomChanges, 0);\n compare(root.heightChanges, 0);" + drag = "compare(shade.height, before);" + + replacements = { + "POSITION": position[1].replace("Style.", "style."), + "SHADETOP": expression(section, "shadeTop"), + "RESTING": resting, + "ROOM": expression(section, "room"), + "CHURN": churn, + "DRAG": drag, + } + template = Path(__file__).with_name("quicksettings-shade-layout.qml.in").read_text() + for placeholder, value in replacements.items(): + if template.count(placeholder) != 1: + raise RuntimeError("Unexpected template placeholder " + placeholder) + template = template.replace(placeholder, value) + return template + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("source", type=Path) + parser.add_argument("--baseline", action="store_true") + args = parser.parse_args() + runner = ( + shutil.which("qmltestrunner6") + or shutil.which("/usr/lib/qt6/bin/qmltestrunner") + or shutil.which("qmltestrunner") + ) + if not runner: + print("quicksettings-shade-layout: no qmltestrunner") + return 77 + qml = fixture(args.source.read_text(), args.baseline) + + with tempfile.TemporaryDirectory(prefix="public-shade-") as directory: + root = Path(directory) + runtime = root / "runtime" + runtime.mkdir(mode=0o700) + test = root / "tst_shade.qml" + test.write_text(qml) + + environment = os.environ.copy() + environment.update( + QT_QPA_PLATFORM="offscreen", + QT_QUICK_BACKEND="software", + QT_QPA_PLATFORMTHEME="generic", + GSETTINGS_BACKEND="memory", + XDG_RUNTIME_DIR=str(runtime), + ) + environment.pop("QT_QPA_GENERIC_PLUGINS", None) + environment.pop("QT_PLUGIN_PATH", None) + result = subprocess.run( + [runner, "-input", str(test)], + env=environment, + capture_output=True, + text=True, + timeout=5, + ) + print(result.stdout + result.stderr, end="") + return result.returncode + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/packages/omamobile-shell/test/quicksettings-shade-layout.qml.in b/packages/omamobile-shell/test/quicksettings-shade-layout.qml.in new file mode 100644 index 000000000..f3f4703c2 --- /dev/null +++ b/packages/omamobile-shell/test/quicksettings-shade-layout.qml.in @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: MIT +import QtQuick +import QtTest + +TestCase { + id: test + name: "PublicShadeViewport" + when: windowShown + visible: true + width: 120 + height: 120 + QtObject { + id: style + readonly property real gapsOut: 24 + readonly property var spacing: ({ + lg: 20 + }) + } + QtObject { + id: window + property real height: 935 + } + Item { + id: root + property bool wide: false + property bool editing: false + property real reveal: 0 + property real baseHeight: 400 + property int roomChanges: 0 + property int heightChanges: 0 + QtObject { + id: drag + property real offset: 0 + } + Item { + id: sheet + height: root.baseHeight + y: POSITION + } + Item { + id: shade + readonly property real shadeTop: SHADETOP + readonly property real restingTop: RESTING + readonly property real room: ROOM + property real natural: 900 + y: shadeTop + height: Math.min(natural, room) + onRoomChanged: root.roomChanges++ + onHeightChanged: root.heightChanges++ + } + NumberAnimation { + id: slide + target: root + property: "reveal" + from: 0 + to: 1 + duration: 220 + } + } + function init() { + slide.stop(); + root.wide = false; + window.height = 935; + root.baseHeight = 400; + drag.offset = 0; + root.reveal = 0; + shade.natural = 900; + wait(10); + root.roomChanges = 0; + root.heightChanges = 0; + } + function test_animationLayoutChurn() { + slide.start(); + tryVerify(function () { + return !slide.running; + }, 600); + console.log("REVEAL_GEOMETRY_UPDATES", root.roomChanges, root.heightChanges); + CHURN; + compare(shade.room, window.height - style.gapsOut - sheet.height - style.spacing.lg - style.gapsOut); + } + function test_endStateAndExpansion() { + root.reveal = 1; + var cases = [ + { + wide: false, + h: 935, + sheet: 400, + n: 100 + }, + { + wide: false, + h: 935, + sheet: 400, + n: 900 + }, + { + wide: true, + h: 420, + sheet: 320, + n: 900 + }, + { + wide: false, + h: 300, + sheet: 280, + n: 900 + } + ]; + for (var i = 0; i < cases.length; i++) { + var v = cases[i]; + root.wide = v.wide; + window.height = v.h; + root.baseHeight = v.sheet; + shade.natural = v.n; + var room = v.h - (v.wide ? style.gapsOut : style.gapsOut + v.sheet + style.spacing.lg) - style.gapsOut; + compare(shade.room, room); + compare(shade.height, Math.min(v.n, room)); + compare(shade.y, v.wide ? style.gapsOut : style.gapsOut + v.sheet + style.spacing.lg); + } + root.wide = false; + window.height = 935; + root.baseHeight = 400; + shade.natural = 900; + var old = shade.height; + root.baseHeight = 500; + verify(shade.height < old); + } + function test_dragKeepsLayout() { + root.reveal = 1; + var before = shade.height; + var y = shade.y; + drag.offset = -50; + compare(shade.y, y - 50); + DRAG; + } +} diff --git a/packages/omamobile-shell/version b/packages/omamobile-shell/version index d8a838a1f..e0fe248e3 100644 --- a/packages/omamobile-shell/version +++ b/packages/omamobile-shell/version @@ -1 +1 @@ -0.2.101 +0.2.102