From a9ccedb3a39459d32a1127ce86f07411768cd203 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Sat, 14 Nov 2026 06:28:45 +0100 Subject: [PATCH 1/2] hyprland 0.57.0-3.4: a turned screen configures its lock surface (#522) A phone locked on its side, or turned as it locked, kept a squeezed lock screen until it was unlocked: the clock narrow and tall, touch off its targets. omamobile-autorotate turns a locked screen back to portrait within its one-second poll, after the lock surface exists, and the lock surface never heard of that turn. Hyprland 0.57 applies a monitor rule that differs from the active one only in the transform through CMonitor::applyMonitorRuleSoft(), which resizes the monitor without emitting modeChanged, and a session-lock surface was sent a configure on that event alone. 0003 has the lock surface follow the monitor layout as well, as xdg_output does, and send a configure when the monitor's size is no longer the one it last sent. pkgrel 3.4. tools/lock-turn-test checks it on a phone: a bare lock client, a quarter turn and back with a transform-only rule change, the lock surface's size against the monitor's. It needs no root, the client opens by itself, and the monitor is turned back on exit. Tested: lock-turn-test fails on a Pixel 9a with 0.57.0-3.3 (monitor 909x405, lock surface 405x909) and passes three times with 0.57.0-3.4; the same in a VM with the 9a's packages (3.1 fails, 3.4 passes, also with OMAMOBILE_ROTATION_HOLD=1). Omarchy's lock on the 9a with 3.4, locked in landscape and turned to portrait, is drawn at 405x909 (read back with kmsgrab). All six patches apply with --fuzz=0. Not run on the Pixel 7 Pro or the Pixel 7. Co-Authored-By: Claude Fable 5.2 --- AGENTS.md | 2 + ...configure-the-lock-surface-on-a-turn.patch | 87 +++++++ packages/hyprland/PKGBUILD | 19 +- packages/hyprland/README.md | 57 ++++- tools/lock-turn-test | 233 ++++++++++++++++++ 5 files changed, 390 insertions(+), 8 deletions(-) create mode 100644 packages/hyprland/0003-session-lock-configure-the-lock-surface-on-a-turn.patch create mode 100755 tools/lock-turn-test diff --git a/AGENTS.md b/AGENTS.md index 6f834cfbe..a2b66bb6c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,6 +86,7 @@ tools/phone-ssh CMD -> run anything; stream files with ssh 'cat > f' < f | `tools/wifi-w1-capture`, `acpm-stage`, `aoc-stage`, `fingerprint-capture` | Staged bring-up: kmsg streamed to `logs/` first, optional `--watchdog` feeder, `--pstore` afterwards | | `tools/usbc-deadman` (+ `usbc-deadman-phone`) | USB-C/charger steps under a dead-man switch; `dump` is read-only | | `tools/display-hz` | Read-only refresh-rate measurement from DECON's frame counter | +| `tools/lock-turn-test` | On-phone check that a locked screen follows a turn of the monitor (`packages/hyprland` 0003): run as the session's user, it locks for about five seconds with a bare lock client of its own, turns the monitor a quarter and back with a transform-only rule change, and compares the lock surface's size with the monitor's. No root; the client opens by itself after 20 s and the monitor is turned back on exit (`--unlock` opens a lock a killed run left). Takes over the screen: announce it | | `tools/power-ab` | On-phone A/B battery-drain test (runs detached; the cable is out) | | `tools/bt-uart-test`, `cs35l41-id`, `ff-rumble`, `usf.py` | On-phone probes, streamed with `tools/phone-ssh python3 - < tool` | | `tools/aoc-audio-diag` | On-phone AoC playback diagnosis (`tools/phone-ssh 'EP=6 MODES=copy bash -s' < tools/aoc-audio-diag`): plays a short tone under `timeout`, snapshots mailbox IRQs, ring counters, CS35L41 registers and DAPM. `EP=` entry point, `MODES=` copy/mmap, `AOCLOG=1` records the AoC firmware log, `SETUP2=0/1` sets `ep_setup2` | @@ -150,6 +151,7 @@ Each entry gives the gotcha, then the reason or the fix. Details are in the link - **Hyprland refused DPMS commits while a flip was in flight,** and gave up after one retry. Our `packages/hyprland` patch keeps retrying. [packages/hyprland/README.md](packages/hyprland/README.md) - **With the panel really off (gs-decon `screen_off=2`), Omarchy's key handling broke:** `key_press_enables_dpms` lit the screen on the power key's press, so its release turned it off again, and Omarchy's lock waits for a lit screen, so locking after power-off lit the PIN pad. `omamobile-shell` 0.1.20 wakes only through `omamobile-keys` (and touch), and locks behind a zero backlight before powering the panel off. - **Hyprland 0.56 on Omarchy uses the Lua config,** so dispatchers take Lua syntax: `hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })'` (or `"enable"`), not `dpms off`. +- **A monitor rule that only turns the screen sends no `modeChanged` in Hyprland 0.57** (`applyMonitorRuleSoft()`), and a session-lock surface was configured only on that event: a phone turned back to portrait after it locked on its side kept a landscape-sized lock screen, drawn stretched, until it was unlocked (#522). Our `packages/hyprland` 0003 configures the lock surface on a layout change too, and `tools/lock-turn-test` checks it on a phone. A rule whose scale is written differently from the active one (`2.66667` against `2.6666667`) takes the full path and hides the gap, so a test must change the transform alone. And while the display is off Hyprland applies no rule change until the next wake. [packages/hyprland/README.md](packages/hyprland/README.md) ### Buses and drivers diff --git a/packages/hyprland/0003-session-lock-configure-the-lock-surface-on-a-turn.patch b/packages/hyprland/0003-session-lock-configure-the-lock-surface-on-a-turn.patch new file mode 100644 index 000000000..6b2401771 --- /dev/null +++ b/packages/hyprland/0003-session-lock-configure-the-lock-surface-on-a-turn.patch @@ -0,0 +1,87 @@ +Subject: [PATCH] session-lock: configure the lock surface when the monitor is turned + +Against Hyprland v0.57.0 (src/protocols/SessionLock.cpp, SessionLock.hpp). + +A lock surface gets its size in ext_session_lock_surface_v1.configure, and +CSessionLockSurface sends one whenever its monitor emits modeChanged. Since +the monitor rules are split into hard and soft properties, a rule change +that only differs in the transform is applied by +CMonitor::applyMonitorRuleSoft(): it gives the monitor its turned size, the +layout is arranged again (layer surfaces are configured, xdg_output sends +the new logical size), but modeChanged is not emitted. So a lock surface is +never told about a quarter turn: the client keeps drawing at the size the +surface was made with, and the renderer draws that buffer stretched over +the turned output until the session is unlocked. Touch no longer lines up +with what is drawn either. + +Seen on a phone whose screen follows the accelerometer: locked on its side, +the screen is turned back to portrait a moment after the lock surface is +made, and the lock screen stays squeezed. With WAYLAND_DEBUG on a lock +client (1080x2424 at scale 8/3): ext_session_lock_surface_v1.configure(405, +909) at the lock, then none for four quarter turns, while +zxdg_output_v1.logical_size went to 909x405 and back each time. + +Have the lock surface follow the monitor layout as well, as xdg_output +does, and send a configure when the monitor's size is no longer the one it +last sent. + +diff --git i/src/protocols/SessionLock.cpp w/src/protocols/SessionLock.cpp +--- i/src/protocols/SessionLock.cpp ++++ w/src/protocols/SessionLock.cpp +@@ -7,6 +7,7 @@ + #include "../output/Monitor.hpp" + #include "../render/Renderer.hpp" + #include "../desktop/state/FocusState.hpp" ++#include "../event/EventBus.hpp" + + CSessionLockSurface::CSessionLockSurface(SP resource_, SP surface_, PHLMONITOR pMonitor_, WP owner_) : + m_resource(resource_), m_sessionLock(owner_), m_surface(surface_), m_monitor(pMonitor_) { +@@ -68,6 +69,15 @@ + m_surface->enter(m_monitor.lock()); + + m_listeners.monitorMode = m_monitor->m_events.modeChanged.listen([this] { sendConfigure(); }); ++ ++ // A rule change that only turns the monitor goes through applyMonitorRuleSoft(), ++ // which gives it its new size without modeChanged. Follow the layout as well, or ++ // the lock surface keeps the size it was made with and is drawn stretched over ++ // the turned output until the session is unlocked. ++ m_listeners.monitorLayout = Event::bus()->m_events.monitor.layoutChanged.listen([this] { ++ if (m_monitor && m_monitor->m_size != m_configuredSize) ++ sendConfigure(); ++ }); + } + + sendConfigure(); +@@ -88,6 +98,7 @@ + } + + const auto SERIAL = g_pSeatManager->nextSerial(g_pSeatManager->seatResourceForClient(m_resource->client())); ++ m_configuredSize = m_monitor->m_size; + m_resource->sendConfigure(SERIAL, m_monitor->m_size.x, m_monitor->m_size.y); + } + +diff --git i/src/protocols/SessionLock.hpp w/src/protocols/SessionLock.hpp +--- i/src/protocols/SessionLock.hpp ++++ w/src/protocols/SessionLock.hpp +@@ -5,6 +5,7 @@ + #include "WaylandProtocol.hpp" + #include "ext-session-lock-v1.hpp" + #include "../helpers/signal/Signal.hpp" ++#include "../helpers/math/Math.hpp" + + class CSessionLock; + class CWLSurfaceResource; +@@ -33,11 +34,13 @@ + + bool m_ackdConfigure = false; + bool m_committed = false; ++ Vector2D m_configuredSize; + + void sendConfigure(); + + struct { + CHyprSignalListener monitorMode; ++ CHyprSignalListener monitorLayout; + CHyprSignalListener surfaceCommit; + CHyprSignalListener surfaceDestroy; + } m_listeners; diff --git a/packages/hyprland/PKGBUILD b/packages/hyprland/PKGBUILD index 7a08299e2..27906e052 100644 --- a/packages/hyprland/PKGBUILD +++ b/packages/hyprland/PKGBUILD @@ -26,6 +26,13 @@ # [extra] in pacman.conf, so pacman takes this build either way. # - pkgrel 3.3: the rotation hold's half turn over Android's 383 ms and the # old frame faded out on Android's alpha-out curve (3.2 is published). +# - 0003-session-lock-configure-the-lock-surface-on-a-turn.patch: a rule +# change that only turns the monitor (what omamobile-autorotate sends) +# is applied without modeChanged, the one event a lock surface was +# configured on. A phone locked on its side, or turned as it locked, kept +# a lock screen of the old size, drawn stretched over the turned output +# until it was unlocked (#522). The lock surface now follows the monitor +# layout too. pkgrel 3.4 (3.3 is published). # - arch=(aarch64) only. # - build() runs the two cmake steps of `make release` itself, with # CMAKE_SKIP_RPATH (Arch's Makefile sed) and the job count from MAKEFLAGS @@ -36,8 +43,8 @@ pkgname=(hyprland hyprpm) pkgver=0.57.0 -pkgrel=3.3 -pkgdesc='a highly customizable dynamic tiling Wayland compositor (Omarchy Mobile: DPMS retry, rotation hold)' +pkgrel=3.4 +pkgdesc='a highly customizable dynamic tiling Wayland compositor (Omarchy Mobile: DPMS retry, rotation hold, lock surface follows a turn)' arch=(aarch64) url="https://github.com/hyprwm/Hyprland" license=(BSD-3-Clause) @@ -104,13 +111,15 @@ source=("$_archive.tar.gz::$url/releases/download/v$pkgver/source-v$pkgver.tar.g wl-output-global-grace.patch monitor-rule-vrr.patch 0001-dpms-keep-retrying-a-refused-dpms-commit.patch - 0002-render-hold-the-last-frame-across-a-rotation.patch) + 0002-render-hold-the-last-frame-across-a-rotation.patch + 0003-session-lock-configure-the-lock-surface-on-a-turn.patch) sha256sums=('82d006ba9264fe67266c7d583c16f1a6c64d51424dbdc472c3e9c9d5ddfcd559' '26d62139b8ae55e286bcdff1838a6bc01a021d8f1039b40b8fa523df83f61610' '8fa0f57dc1b3246ab4e30ae81419150f4af7767fb31e739e36c824c6d99fab73' 'c14fb0ec02d97100bcfa4e5c8daaf524972fa5c665e04960619744ba01c73c39' 'a5670d9a6cdee3f3990a81cdecfd5e1f95771ebd1d7b1e2622ac7187684b8836' - 'c69e64fe55a25a7baa2751ff795ae1f8a1ddfc1d162b9b35f9d821675be02bb7') + 'c69e64fe55a25a7baa2751ff795ae1f8a1ddfc1d162b9b35f9d821675be02bb7' + '3849c832de8fbbacf344bcb1601f2d25789c2f4e87e44f12a6f88f74dafd482b') prepare() { ln -sf hyprland-source "$_archive" @@ -125,6 +134,8 @@ prepare() { patch -Np1 --fuzz=0 -i "$srcdir/0001-dpms-keep-retrying-a-refused-dpms-commit.patch" # Omarchy Mobile: hold the last frame across a rotation until the layers have drawn, then turn it in as Android does patch -Np1 --fuzz=0 -i "$srcdir/0002-render-hold-the-last-frame-across-a-rotation.patch" + # Omarchy Mobile: a monitor that is only turned configures its lock surface again + patch -Np1 --fuzz=0 -i "$srcdir/0003-session-lock-configure-the-lock-surface-on-a-turn.patch" sed -i -e '/find_package.glaze/s/7...<8 //' {.,hyprpm,start}/CMakeLists.txt } diff --git a/packages/hyprland/README.md b/packages/hyprland/README.md index deb85aed9..9d3ff97dc 100644 --- a/packages/hyprland/README.md +++ b/packages/hyprland/README.md @@ -2,7 +2,7 @@ # hyprland (Omarchy Mobile build) This is Omarchy's Hyprland 0.57.0-2 recipe (`hyprland` and `hyprpm`), built -for aarch64 with two changes. Hyprland gave up on a refused DPMS commit after +for aarch64 with three changes. Hyprland gave up on a refused DPMS commit after a single retry, and aquamarine refuses commits while a page flip is in flight. So when a client kept rendering, DPMS off was lost: Hyprland reported the screen off, but the CRTC never turned off. See @@ -14,6 +14,7 @@ reported the screen off, but the CRTC never turned off. See | `nvidia-egl-teardown.patch`, `wl-output-global-grace.patch`, `monitor-rule-vrr.patch` | Omarchy's patches from the same commit, unchanged (what they fix: their comments in `prepare()`) | | `0001-dpms-keep-retrying-a-refused-dpms-commit.patch` | The Omarchy Mobile change to `src/output/Monitor.cpp` | | `0002-render-hold-the-last-frame-across-a-rotation.patch` | The Omarchy Mobile change to `src/render/Renderer.cpp` and `src/render/OpenGL.cpp` (the rotation hold, below) | +| `0003-session-lock-configure-the-lock-surface-on-a-turn.patch` | The Omarchy Mobile change to `src/protocols/SessionLock.cpp` and `SessionLock.hpp` (a turned monitor configures its lock surface, below) | ## What differs from Omarchy's `hyprland` 0.57.0-2 @@ -32,11 +33,27 @@ reported the screen off, but the CRTC never turned off. See Hyprland's environment (read once at startup): `omamobile-device-panther` sets it in `environment.d`, and the other phones rotate as before until it has run on them. -- `pkgrel=3.3`: the higher of Omarchy's (0.57.0-2) and Arch Linux ARM's +- The lock surface follows a turn (0003). Hyprland 0.57 applies a monitor + rule that differs from the active one only in "soft" properties, the + transform among them, through `CMonitor::applyMonitorRuleSoft()`: the + monitor gets its turned size and the layout is arranged again, but + `modeChanged` isn't emitted, and that event is the only one on which a + session-lock surface is sent a new `configure`. omamobile-autorotate's + rule change is exactly that, so a phone locked on its side, or turned as + it locked, kept a lock screen of the size it was made with after + autorotate turned the locked screen back to portrait: drawn stretched + over the turned output, with touch off its targets, until it was unlocked + (#522). The lock surface now also follows the monitor layout, as + `xdg_output` does, and is sent a `configure` when the monitor's size is + no longer the one it was last told. A turn made while the display is off + is applied by Hyprland at the next wake, and the lock surface is + configured then. Hyprland's main branch had the same gap on 2026-11-13. +- `pkgrel=3.4`: the higher of Omarchy's (0.57.0-2) and Arch Linux ARM's (`extra/hyprland` 0.57.0-3, a rebuild for aquamarine 0.16.0 and hyprgraphics 0.6.0) release, plus `.1`, so it sorts above both; `.2` for the rotation hold, since 3.1 is published; `.3` for the half turn's - 383 ms and the alpha-out curve, since 3.2 is published. + 383 ms and the alpha-out curve, since 3.2 is published; `.4` for the + lock surface, since 3.3 is published. - `arch=(aarch64)` only. - `build()` runs the two cmake steps of `make release` itself: - with Arch's `-DCMAKE_SKIP_RPATH=ON` (Arch's PKGBUILD seds it into the @@ -55,6 +72,36 @@ Omarchy dropped the patch, so it is gone here too. ## Status +**0.57.0-3.4 (0003, the lock surface follows a turn), built on 2026-11-13 +and running on a Pixel 9a since 2026-11-14.** Built from this PKGBUILD in +an Arch Linux ARM container on an aarch64 host (`-j8`, 6 min), against +`extra`'s aquamarine 0.16.0, hyprgraphics 0.6.0 and hyprutils 0.14.3, the +versions the phone runs; all six patches apply with `--fuzz=0`. +`tools/lock-turn-test` locks with a bare lock client, turns the monitor a +quarter and back with a rule change in which only the transform differs, +and compares the lock surface's size with the monitor's: + +| Where | hyprland | A quarter turn | +| --- | --- | --- | +| Pixel 9a | 0.57.0-3.3 | not ok: the monitor is 909x405, the lock surface 405x909 | +| A VM with the 9a's packages and phone session (vkms, 1080x2424 at 8/3) | 0.57.0-3.1 | not ok, the same sizes | +| The same VM | 0.57.0-3.4 | ok, three runs; ok twice more with `OMAMOBILE_ROTATION_HOLD=1` | +| Pixel 9a | 0.57.0-3.4 | ok, three runs | + +With `WAYLAND_DEBUG=1` on a lock client in the VM, 0.57.0-3.1 sent one +`ext_session_lock_surface_v1.configure(405, 909)` at the lock and none for +four quarter turns, while `zxdg_output_v1.logical_size` followed each; +0.57.0-3.4 sends a configure with the new size after each quarter turn. +Omarchy's own lock, read back from the scanout buffer (`ffmpeg -f +kmsgrab`): on the 9a with 0.57.0-3.3, turned to landscape and back while +locked, it stayed 909x405 and was drawn squeezed into the portrait screen; +with 0.57.0-3.4, locked in landscape and then turned to portrait, it is +drawn at 405x909. In the VM with 0.57.0-3.4 it also came out right after a +turn made while the display was off (applied at the wake). + +Not tested: the Pixel 7 Pro and the Pixel 7 (the rotation hold was only +run in the VM), and an external monitor. + **0.57.0-3.1, built natively on the phone (2026-11-02), not installed yet.** Arch Linux ARM moved `extra` to aquamarine 0.16.0 (`libaquamarine.so=15`) and hyprgraphics 0.6.0 (`libhyprgraphics.so=5`) and dropped the old @@ -204,7 +251,9 @@ rebuilds: hyprgraphics, hyprutils, ...), even with no new Hyprland: our build pins the old one, and `extra` drops it. -Drop the DPMS patch once upstream retries refused DPMS commits. +Drop the DPMS patch once upstream retries refused DPMS commits, and 0003 +once upstream configures a lock surface when its monitor is only turned +(`tools/lock-turn-test` passes without it then). **`tools/repo-build`:** - Packages are listed explicitly, so add `packages/hyprland` only when it diff --git a/tools/lock-turn-test b/tools/lock-turn-test new file mode 100755 index 000000000..8ed0609fb --- /dev/null +++ b/tools/lock-turn-test @@ -0,0 +1,233 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT +# On-phone check that a locked screen follows a turn of the monitor +# (packages/hyprland, patch 0003). Run it on the phone, in a terminal of +# the session or over SSH as the session's user: +# +# tools/lock-turn-test lock, turn a quarter and back, report +# tools/lock-turn-test --monitor NAME another output than the first +# tools/lock-turn-test --unlock only open a lock that a killed run +# left behind +# +# It locks the session for about five seconds with a lock client of its own +# (Quickshell, ext-session-lock-v1: one bare surface per output that reports +# its size), turns the monitor a quarter and back with a rule change in +# which only the transform differs, as omamobile-autorotate's does, and +# checks after each turn that the lock surface has the monitor's new size. +# Hyprland applies such a change without a mode change, and a compositor +# that doesn't tell a lock surface about it fails the two turn checks: the +# surface keeps the size it was made with, and the lock screen is drawn +# stretched over the turned output until it is unlocked. +# +# It takes over the screen while it runs, so announce it, and leave the +# phone lying still: a turn by the accelerometer in between spoils the run +# (reported as "not run"). The screen must be on and the phone unlocked. +# Nothing needs root. The lock client opens by itself after 20 s whatever +# happens to this script, the monitor is turned back on exit, also after +# Ctrl-C or a hang-up, and --unlock opens a lock whose client was killed +# (Omarchy's Hyprland lets a new client take such a lock over). +# +# Each check prints ok or not ok. The exit status is 0 when all passed, 1 +# when one failed, and 2 when the check could not run. +set -u + +me=${0##*/} +monitor="" unlock_only=0 +while (($#)); do + case $1 in + --monitor) monitor=${2:?--monitor NAME}; shift ;; + --unlock) unlock_only=1 ;; + -h|--help) awk 'NR > 2 && !/^#/ { exit } NR > 2' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;; + *) echo "$me: unknown option $1" >&2; exit 2 ;; + esac + shift +done + +die() { echo "$me: $*" >&2; exit 2; } +for c in hyprctl jq qs; do + command -v "$c" >/dev/null 2>&1 || die "$c not found" +done + +# The session's sockets: a terminal in the session has them, a login over +# SSH takes them from the user's systemd manager. +if [[ -z ${HYPRLAND_INSTANCE_SIGNATURE:-} || -z ${WAYLAND_DISPLAY:-} ]]; then + export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/$(id -u)} + while IFS='=' read -r k v; do + case $k in HYPRLAND_INSTANCE_SIGNATURE|WAYLAND_DISPLAY) export "$k=$v" ;; esac + done < <(systemctl --user show-environment 2>/dev/null) +fi +[[ -n ${HYPRLAND_INSTANCE_SIGNATURE:-} && -n ${WAYLAND_DISPLAY:-} ]] || + die "no Hyprland session found: run it as the user of the session" + +dir=$(mktemp -d "${XDG_RUNTIME_DIR:-/tmp}/lock-turn-test.XXXXXX") || die "no temporary directory" +pid="" turned="" t0="" + +# The lock client: one surface per output that says how large it is, each +# time that changes. It opens when asked to (IPC) and after LOCKTURN_HOLD_MS +# on its own; with 0 it opens as soon as it holds the lock (--unlock). +cat >"$dir/shell.qml" <<'QML' +import QtQuick +import Quickshell +import Quickshell.Io +import Quickshell.Wayland + +ShellRoot { + id: root + readonly property int holdMs: Number(Quickshell.env("LOCKTURN_HOLD_MS") || 20000) + function say(what) { console.log("LOCKTURN " + what) } + function open() { lock.locked = false; quit.start() } + + WlSessionLock { + id: lock + locked: true + onSecureStateChanged: { + root.say("secure " + secure) + if (secure && root.holdMs === 0) root.open() + } + + WlSessionLockSurface { + id: surface + color: "#1e1e2e" + function report() { + if (width > 0 && height > 0) root.say("size " + (screen ? screen.name : "?") + " " + width + "x" + height) + } + onWidthChanged: report() + onHeightChanged: report() + + Text { + anchors.centerIn: parent + color: "#cdd6f4" + font.pixelSize: 20 + horizontalAlignment: Text.AlignHCenter + text: "lock-turn-test\n" + surface.width + " x " + surface.height + "\nopens by itself" + } + } + } + + IpcHandler { + target: "lockturn" + function unlock(): void { root.open() } + } + + Timer { interval: Math.max(root.holdMs, 1); running: root.holdMs > 0; onTriggered: root.open() } + Timer { id: quit; interval: 500; onTriggered: Qt.quit() } +} +QML + +client() { # hold in ms; nohup, so a hang-up here can't kill a client that holds the lock + LOCKTURN_HOLD_MS=$1 nohup qs -p "$dir/shell.qml" >"$dir/log" 2>&1 & + pid=$! +} +alive() { [[ -n $pid ]] && kill -0 "$pid" 2>/dev/null; } +said() { grep -a -c -- "LOCKTURN $1" "$dir/log" >/dev/null 2>&1; } +# wait_for SECONDS COMMAND...: true as soon as the command is +wait_for() { + local n=$(($1 * 10)); shift + while ((n-- > 0)); do + "$@" && return 0 + sleep 0.1 + done + "$@" +} +gone() { ! alive; } + +# Ask the client to open; never kill one that may hold the lock, it opens by +# itself when its time is up. +open_lock() { + alive || return 0 + qs ipc --pid "$pid" call lockturn unlock >/dev/null 2>&1 + wait_for 5 gone || echo "$me: the lock client is still up; it opens by itself within 20 s (or: $me --unlock)" >&2 +} + +cleanup() { + trap - EXIT + open_lock + [[ -n $turned && -n $t0 ]] && turn "$t0" + rm -rf "$dir" +} +trap cleanup EXIT +trap 'exit 130' INT +trap 'exit 129' HUP +trap 'exit 143' TERM + +if ((unlock_only)); then + client 0 + if wait_for 10 gone; then + echo "ok - took the lock over and opened it" + exit 0 + fi + echo "not ok - the lock client did not get the lock and open it:" + grep -a -i -m 5 -E 'lock|error|fail' "$dir/log" + exit 1 +fi + +# The monitor as it is now. +m=$(hyprctl -j monitors 2>/dev/null | + jq -c --arg n "$monitor" '[.[] | select($n == "" or .name == $n)][0] // empty' 2>/dev/null) +[[ -n $m ]] || die "no monitor${monitor:+ named $monitor}" +read -r mon scale t0 dpms pw ph rate px py < <(jq -r \ + '"\(.name) \(.scale) \(.transform) \(.dpmsStatus) \(.width) \(.height) \(.refreshRate) \(.x) \(.y)"' <<<"$m") +[[ $dpms == true ]] || die "the screen is off: turn it on first" +if command -v omarchy-shell >/dev/null 2>&1 && [[ $(omarchy-shell lock isLocked 2>/dev/null) == true ]]; then + die "the phone is locked: unlock it first" +fi + +# The size Hyprland gives the monitor for a transform, rounded as it rounds. +logical() { + jq -rn --argjson w "$pw" --argjson h "$ph" --argjson s "$scale" --argjson t "$1" \ + 'if $t % 2 == 1 then [$h, $w] else [$w, $h] end | map(. / $s | round) | "\(.[0])x\(.[1])"' +} +# The monitor's rule as it stands, with the transform given: mode, position +# and scale are what Hyprland reports, so only the transform ever changes, +# and the touchscreen turns with the monitor, as omamobile-autorotate has it. +turn() { + hyprctl eval "hl.monitor({ output = \"$mon\", mode = \"${pw}x${ph}@${rate}\", position = \"${px}x${py}\", scale = $scale, transform = $1 }); hl.config({ input = { touchdevice = { transform = $1, output = \"$mon\" } } })" >/dev/null 2>&1 +} +transform_is() { [[ $(hyprctl -j monitors 2>/dev/null | jq -r --arg n "$mon" '.[] | select(.name == $n) | .transform') == "$1" ]]; } +surface_size() { grep -a -o "LOCKTURN size $mon [0-9]*x[0-9]*" "$dir/log" 2>/dev/null | tail -n 1 | awk '{ print $NF }'; } +surface_is() { [[ $(surface_size) == "$1" ]]; } + +echo "# $me: $mon ${pw}x${ph} at scale $scale, transform $t0; the screen is locked for about five seconds" +fail=0 +ok() { echo "ok - $*"; } +not_ok() { echo "not ok - $*"; fail=1; } + +# The rule as this script writes it, before the lock: from here on a turn +# differs from the active rule in its transform alone. +turned=1 +turn "$t0" +sleep 0.3 +transform_is "$t0" || die "not run: the monitor did not keep transform $t0" + +client 20000 +if ! wait_for 8 said "secure true"; then + echo "$me: the lock client did not get the lock:" >&2 + grep -a -i -m 5 -E 'lock|error|fail' "$dir/log" >&2 + exit 2 +fi + +want=$(logical "$t0") +if wait_for 3 surface_is "$want"; then + ok "the lock surface is made at the monitor's size, $want" +else + not_ok "the lock surface is made at $(surface_size), the monitor is $want" +fi + +# check_turn TRANSFORM WHAT +check_turn() { + local want + want=$(logical "$1") + turn "$1" + wait_for 2 transform_is "$1" || { echo "$me: not run: the monitor did not turn to transform $1" >&2; exit 2; } + if wait_for 3 surface_is "$want"; then + ok "$2 (transform $1): the lock surface is $want, as the monitor" + else + not_ok "$2 (transform $1): the monitor is $want, the lock surface $(surface_size)" + fi + transform_is "$1" || { echo "$me: not run: something else turned the monitor meanwhile" >&2; exit 2; } +} +check_turn $(((t0 + 1) % 4)) "a quarter turn" +check_turn "$t0" "turned back" + +open_lock +exit "$fail" From 92575f8a3b4b425192294b2bb314fd48b3bab9c4 Mon Sep 17 00:00:00 2001 From: den-kloot <1522975+den-kloot@users.noreply.github.com> Date: Sun, 15 Nov 2026 08:21:02 +0100 Subject: [PATCH 2/2] hyprland: the display-off note is from a VM; the README points at #785's patch Review of #753: the AGENTS.md gotcha's last sentence (no rule change applies while the display is off) was only seen in the VM, and says so now. The README's note on dropping 0003 names #785's wl_output patch, the same cause one protocol over, so the two are looked at together once upstream fixes it. Co-Authored-By: Claude Fable 5.2 --- AGENTS.md | 2 +- packages/hyprland/README.md | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index a2b66bb6c..4605fb04a 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -151,7 +151,7 @@ Each entry gives the gotcha, then the reason or the fix. Details are in the link - **Hyprland refused DPMS commits while a flip was in flight,** and gave up after one retry. Our `packages/hyprland` patch keeps retrying. [packages/hyprland/README.md](packages/hyprland/README.md) - **With the panel really off (gs-decon `screen_off=2`), Omarchy's key handling broke:** `key_press_enables_dpms` lit the screen on the power key's press, so its release turned it off again, and Omarchy's lock waits for a lit screen, so locking after power-off lit the PIN pad. `omamobile-shell` 0.1.20 wakes only through `omamobile-keys` (and touch), and locks behind a zero backlight before powering the panel off. - **Hyprland 0.56 on Omarchy uses the Lua config,** so dispatchers take Lua syntax: `hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })'` (or `"enable"`), not `dpms off`. -- **A monitor rule that only turns the screen sends no `modeChanged` in Hyprland 0.57** (`applyMonitorRuleSoft()`), and a session-lock surface was configured only on that event: a phone turned back to portrait after it locked on its side kept a landscape-sized lock screen, drawn stretched, until it was unlocked (#522). Our `packages/hyprland` 0003 configures the lock surface on a layout change too, and `tools/lock-turn-test` checks it on a phone. A rule whose scale is written differently from the active one (`2.66667` against `2.6666667`) takes the full path and hides the gap, so a test must change the transform alone. And while the display is off Hyprland applies no rule change until the next wake. [packages/hyprland/README.md](packages/hyprland/README.md) +- **A monitor rule that only turns the screen sends no `modeChanged` in Hyprland 0.57** (`applyMonitorRuleSoft()`), and a session-lock surface was configured only on that event: a phone turned back to portrait after it locked on its side kept a landscape-sized lock screen, drawn stretched, until it was unlocked (#522). Our `packages/hyprland` 0003 configures the lock surface on a layout change too, and `tools/lock-turn-test` checks it on a phone. A rule whose scale is written differently from the active one (`2.66667` against `2.6666667`) takes the full path and hides the gap, so a test must change the transform alone. And while the display is off Hyprland applies no rule change until the next wake (seen in a VM, not yet on a phone). [packages/hyprland/README.md](packages/hyprland/README.md) ### Buses and drivers diff --git a/packages/hyprland/README.md b/packages/hyprland/README.md index 9d3ff97dc..36fc9ca03 100644 --- a/packages/hyprland/README.md +++ b/packages/hyprland/README.md @@ -253,7 +253,11 @@ rebuilds: Drop the DPMS patch once upstream retries refused DPMS commits, and 0003 once upstream configures a lock surface when its monitor is only turned -(`tools/lock-turn-test` passes without it then). +(`tools/lock-turn-test` passes without it then). #785's patch +(`output-send-the-whole-state-with-done`) is the same cause one protocol +over: after a transform-only rule `wl_output` clients keep the old +transform. Whoever drops one should check the other, since one upstream +fix to `applyMonitorRuleSoft()` would cover both. **`tools/repo-build`:** - Packages are listed explicitly, so add `packages/hyprland` only when it