Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
934774f15e | ||
|
|
4b5cb5197a | ||
|
|
cbf58f6443 | ||
|
|
acdfb2801e | ||
|
|
352cfdcb24 | ||
|
|
336474793f | ||
|
|
7e0544ed70 | ||
|
|
6b395305e0 | ||
|
|
d0efba0877 | ||
|
|
8f3f000783 | ||
|
|
c1dc60af00 | ||
|
|
1c886eec3f |
No files matched your search
+12
-13
@@ -268,20 +268,19 @@ is below. These are defects in code this branch does not own; they are recorded
|
||||
here because the checks are written against the contract and therefore trip
|
||||
over them.
|
||||
|
||||
1. **The broker reads none of the container or pointer configuration.**
|
||||
`nix/module.nix` renders `sessions.containers.{max,mode,workspaceBase}` and
|
||||
`sessions.pointer.{leaseTtl,leaseMax}` into the generated TOML as PLAN §10
|
||||
names them, and `hhstreamd/policy.py:policy_from_dict` reads only
|
||||
`[defaults]` and `[apps]`. `hhstreamd/__main__.py:serve` builds its
|
||||
`ManagerConfig` from command-line flags that have no counterpart for any of
|
||||
those numbers either, so the broker runs on its own defaults (band 1000,
|
||||
4 slots, 1280x720, lease 30 s / 300 s).
|
||||
The deep versions of these — the issue, more than one idea, and why each one
|
||||
matters — live in [`docs/TODO/`](docs/TODO/README.md). Update the file there
|
||||
when one closes, so this list stays a description of what is still true.
|
||||
|
||||
Those defaults agree with the module's, so a deployment that leaves the
|
||||
options alone behaves as documented; one that changes them is ignored.
|
||||
`vm-pointer` prints the module's `leaseTtl` beside the TTL the broker
|
||||
reports, so the discrepancy is visible in the build log rather than
|
||||
inferred. The fix is in `policy.py` and `__main__.py`, not here.
|
||||
1. **The container host can be switched off, and the broker now honours it.**
|
||||
*(This item previously read "the broker reads none of the container or
|
||||
pointer configuration." That is fixed: `policy.py` parses those settings
|
||||
beside `Policy`, read in `__main__`, and a host that is switched off reports
|
||||
itself unavailable with the reason naming the key — so a disabled machine
|
||||
cannot be mistaken for one whose compositor is down. The reason it matters is
|
||||
what follows.)* Containers are consequently **off on the deployment machine**:
|
||||
no window can be put in one yet, and enabling them quarantines every
|
||||
allowlisted app. That join is the first item in `docs/TODO/`.
|
||||
|
||||
2. **`session start --no-container` is refused, not honoured.** PLAN §9 lists
|
||||
the flag; `docs/CONTRACT-sessions.md` §4 leaves `start` unchanged, and
|
||||
|
||||
@@ -278,11 +278,24 @@ blocked driver must not stall the broker.
|
||||
```json
|
||||
{"op": "warp", "output": "hh-x", "x": 0.42, "y": 0.61} -> {"ok": true}
|
||||
{"op": "button", "button": "left", "state": "down"} -> {"ok": true}
|
||||
{"op": "axis", "axis": "vertical", "value": 3.0} -> {"ok": true}
|
||||
{"op": "frame"} -> {"ok": true}
|
||||
{"op": "pressed"} -> {"ok": true, "buttons": ["left"]}
|
||||
{"op": "release_all"} -> {"ok": true, "lifted": ["left"]}
|
||||
```
|
||||
|
||||
**Amended after the freeze — `axis`, for scrolling.** Added to the op set above
|
||||
and to the broker's verbs as `pointer.scroll`. Positive vertical is *down* and
|
||||
positive horizontal is *right*: the protocol's direction, not a choice of ours,
|
||||
and the reason there is no `up`/`down` vocabulary layered over it. The output is
|
||||
whatever the last `warp` aimed at, exactly like `button`, so scrolling somewhere
|
||||
else is a warp first — which is what keeps the whole gesture atomic under the
|
||||
lease. The magnitude is bounded at 100 wheel clicks per request, in both the
|
||||
driver and the broker, because a decimal-point slip should be a refusal rather
|
||||
than a session scrolled somewhere unrecoverable. Unit tests cover validation and
|
||||
the lease; a real-compositor case is still missing — see
|
||||
`docs/TODO/scroll-has-no-compositor-proof.md`.
|
||||
|
||||
`{"ok": false, "error": "<text>"}` for anything rejected. The driver holds **no
|
||||
lease state** — the broker owns the lease; the driver is an executor that must
|
||||
never be trusted to serialise anything.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# TODO
|
||||
|
||||
Known, unfixed problems — each one real, none of them guessed at.
|
||||
|
||||
Each file answers three questions and stops:
|
||||
|
||||
- **The issue** — what is actually wrong, with the evidence for it.
|
||||
- **Ideas** — more than one, and which one is the recommended route.
|
||||
- **Why it matters** — the impact, not the principle.
|
||||
|
||||
| item | severity | state |
|
||||
| --- | --- | --- |
|
||||
| [cursor-visibility-in-captures](cursor-visibility-in-captures.md) | high | answered: the compositor draws no cursor for a virtual pointer. Needs a decision on an overlay marker |
|
||||
| [scroll-has-no-compositor-proof](scroll-has-no-compositor-proof.md) | medium | works live; unproven in a gate |
|
||||
| [reconcile-while-containers-are-off](reconcile-while-containers-are-off.md) | medium | partly fixed: discovery now survives a restart; teardown still lives inside the feature |
|
||||
| [kill-can-leave-the-app-alive](kill-can-leave-the-app-alive.md) | medium | found by counting windows, not sessions |
|
||||
|
||||
Closed since this folder was written:
|
||||
|
||||
- *"Containers do not bind"* — fixed. Windows are assigned by the pid the
|
||||
compositor reports, moved onto their desk's workspace and read back. Two
|
||||
sessions now hold two outputs with a real browser on each.
|
||||
- *"The pointer is unusable while containers are off"* — fixed with it. The
|
||||
pointer aims at the session's desk, and desks hold applications.
|
||||
- *"Discovery refuses when two compositor instances exist"* — fixed. Each
|
||||
candidate is asked for its version and the one that answers is used.
|
||||
|
||||
Severity here means "how much of the feature is actually delivered", not "how
|
||||
loud the failure is". The highest is highest because a whole class of work is
|
||||
blocked on it: the pointer is exact and invisible, so nothing can show *where*
|
||||
anything happened.
|
||||
|
||||
When one of these is fixed, delete its file and the row — this folder is a list
|
||||
of what is still true, not a history of what was thought.
|
||||
@@ -0,0 +1,63 @@
|
||||
# The compositor draws no cursor for a virtual pointer
|
||||
|
||||
## What is open
|
||||
|
||||
**The overlay marker is not implemented.** The acceptance video was recorded
|
||||
without it, so the frames show the pointer's *effects* — a page that scrolled,
|
||||
a tab that opened — and never the pointer itself. Implement it by stamping
|
||||
`hyprctl cursorpos` into each frame, mapped into the stitched layout, and label
|
||||
it as an overlay wherever the frame is published. Nothing else about the pointer
|
||||
is blocked: position, clicks and scrolling are all exact and all readable.
|
||||
|
||||
## The issue — answered, and it is not a capture setting
|
||||
|
||||
The pointer moves exactly where it is told, and **nothing is drawn**. Every
|
||||
plausible cause was eliminated by test rather than by argument:
|
||||
|
||||
| candidate | test | result |
|
||||
| --- | --- | --- |
|
||||
| `grim` not asking for the cursor | Hyprland's `Screencopy.cpp` takes an `overlayCursor` argument, so `-c` was added to the capture command | no change at the pointer |
|
||||
| hardware cursor plane | `cursor:no_hardware_cursors` | already `true` |
|
||||
| no cursor theme installed | installed `adwaita-icon-theme`, present at `/run/current-system/sw/share/icons/Adwaita` (63 cursor files) | no change |
|
||||
| theme not reaching the cursor manager | `hyprctl setcursor Adwaita 24` at runtime | no change — and note `env = XCURSOR_THEME` in the compositor's own config sets variables for **launched programs**, not for the compositor, which is where my first attempt put it |
|
||||
| hyprcursor rather than X11 themes | `cursor:enable_hyprcursor` | already `false`: the X11 path |
|
||||
|
||||
The decisive measurement: park the pointer at two points that both miss the
|
||||
browser's toolbar, capture each, diff them — **zero differing pixels**. The only
|
||||
differences that ever appear are in the URL bar, which is a blinking text caret.
|
||||
|
||||
The cause is the protocol. `zwlr_virtual_pointer_v1` has no request to set a
|
||||
cursor image, and Hyprland renders a cursor only for a pointer that has an image
|
||||
to draw. A virtual pointer warps the position and has no surface behind it, so
|
||||
the compositor has nothing to composite: every capture is faithful, and the
|
||||
cursor is simply not in it.
|
||||
|
||||
## Ideas
|
||||
|
||||
1. **Stamp the position into the frames, labelled as an overlay.** *(recommended)*
|
||||
The frame server can ask `hyprctl cursorpos` — this machine answers it exactly
|
||||
— map it into the stitched frame, and draw a marker there. It is not fiction:
|
||||
it is the compositor's own answer, drawn where the compositor says the pointer
|
||||
is, precisely because the compositor draws nothing. It has to be *named* as an
|
||||
overlay in the code and in anything published from it.
|
||||
2. **Leave the pixels alone and prove motion by readout.** `hyprctl cursorpos` is
|
||||
exact: 0.8 across a 1280-wide desk came back as 3584 with the desk starting at
|
||||
2560. Gates can assert position with no image at all — cheaper and stronger
|
||||
than a pixel check.
|
||||
3. **Ask upstream, or try a newer compositor.** Whatever makes a cursor appear
|
||||
for a virtual pointer is the real fix. Not attempted.
|
||||
4. **A synthetic pointer client.** Impossible for a plain client (it cannot draw
|
||||
over another window); it would need a layer-shell surface, which is more
|
||||
machinery than (1) for the same result.
|
||||
|
||||
## Why it matters
|
||||
|
||||
Everything about the pointer is verifiable except the part a person can see. That
|
||||
a click landed *here* is provable by readout and by what changed, but a viewer
|
||||
cannot tell **where** it happened — and a click on the wrong element and a click
|
||||
on the right one both produce a screen that changed.
|
||||
|
||||
Worth recording: this took three wrong answers (`-c`, the theme, the compositor
|
||||
setting) before the right one, and two of those came from reasoning rather than
|
||||
measurement. What settled it was boring — capture the same screen twice with the
|
||||
pointer in two places and diff them. That should have been the first move.
|
||||
@@ -0,0 +1,42 @@
|
||||
# Killing a session does not always kill the browser it started
|
||||
|
||||
## The issue
|
||||
|
||||
Three chromium processes outlived the sessions that had launched them, while the
|
||||
broker reported those sessions as ended. Found by counting windows on the
|
||||
compositor after a probe run: two windows left on the main screen whose sessions
|
||||
no longer existed, with pids older than the session that had replaced them.
|
||||
|
||||
The kill path does signal the process group — the audit line says
|
||||
`sent SIGTERM to process group 2966561` and that session's process *did* die —
|
||||
so this is not "the kill does nothing". It is narrower: two of three killings
|
||||
left a live browser behind, and the two that leaked were started while the
|
||||
compositor was unreachable from the broker, so they had no container recorded at
|
||||
all. That correlation is the only clue so far and it is not proof.
|
||||
|
||||
## Ideas
|
||||
|
||||
1. **Check whether the leak tracks the container record.** *(recommended first)*
|
||||
Kill a session whose container is `owned` and one whose container is `null`,
|
||||
several times, and count survivors. If the leak is limited to containerless
|
||||
sessions, the fix is in the kill path's cleanup of a session that never got a
|
||||
desk, not in the signal path.
|
||||
2. **Re-read the survivors from the compositor after every kill.** The teardown
|
||||
already has `container_survivors` for windows; the same shape applies to
|
||||
processes, and `procmon` already knows how to identify them by
|
||||
`(pid, starttime)`. A kill that leaves anything alive should say so in its
|
||||
reply rather than returning a clean record.
|
||||
3. **Make the idle reaper the backstop it already is.** A session that was
|
||||
reaped instead of killed goes through the same teardown; if the leak is in
|
||||
the exit path, the reaper may be leaking too — worth measuring once (1).
|
||||
4. **A test that counts processes, not sessions.** Every existing assertion is
|
||||
about the broker's view. One that counts the app's processes after a kill
|
||||
would have caught this the first time it happened.
|
||||
|
||||
## Why it matters
|
||||
|
||||
Processes that outlive their sessions are exactly what the registry's whole
|
||||
identity design (boot id, start time) exists to prevent, and the ones found were
|
||||
still holding windows on the compositor — invisible to `session list`, visible
|
||||
on screen. A machine that accumulates them slowly fills up with browsers nobody
|
||||
owns, each holding a desk slot if the band is what limits sessions.
|
||||
@@ -0,0 +1,48 @@
|
||||
# Cleanup depends on the feature it is cleaning up after
|
||||
|
||||
## The issue
|
||||
|
||||
Start-up reconciliation for stray `hh-*` outputs lives inside the container
|
||||
host, so it runs **only when containers are enabled**. Turning containers off
|
||||
therefore also turned off the broker's ability to see what it had already left
|
||||
on the compositor.
|
||||
|
||||
That is not theoretical: an output created while the feature was on survived the
|
||||
rollback switch. With containers off, nothing reconciled it, and the frame
|
||||
capture stayed **2560×720 instead of 1280×720** — the extra width being the
|
||||
orphan sitting beside the real one. The symptom is a *capture* problem, which is
|
||||
where it would be looked for, and it was fixed by restarting the compositor,
|
||||
which drops every session.
|
||||
|
||||
## Ideas
|
||||
|
||||
1. **Reconcile always, not conditionally.** *(recommended)* On start-up, list the
|
||||
compositor's outputs, find `hh-*` ones that no live session owns, and remove
|
||||
them — regardless of whether containers are enabled. "Disabled" should mean
|
||||
*create none*, not *leave the machine as it was found*.
|
||||
2. **Never start a session onto an unowned output.** If a leftover is found that
|
||||
cannot be removed, refuse to place a session on it rather than silently
|
||||
sharing it — the ambiguity is what makes the capture width unexplainable.
|
||||
3. **Record removals in the audit trail.** The `hyprctl output remove` calls are
|
||||
already logged individually; a reconcile pass that removes three outputs
|
||||
should say so once, with the names, so a later "why is my screen narrower"
|
||||
has an answer.
|
||||
4. **Make it a check.** A VM case that creates a container, disables the feature,
|
||||
and asserts the output is gone — the rollback path deserves the same gate as
|
||||
the forward path, because it is the one that runs when something is already
|
||||
wrong.
|
||||
|
||||
## Why it matters
|
||||
|
||||
A feature that cannot be turned off safely is worse than one that was never
|
||||
turned on, and this one fails asymmetrically: the *forward* path is tested
|
||||
(containers are created and torn down in `vm-sessions` and `vm-containers`),
|
||||
while the *rollback* path was never exercised before it was needed. That is
|
||||
precisely when it is used.
|
||||
|
||||
It also cost a compositor restart — the bluntest tool available, and one that
|
||||
kills every session — to clean up a state the broker itself had created and
|
||||
could no longer see. The general rule worth keeping: **teardown code belongs
|
||||
outside the thing being torn down**, or there will be exactly one configuration
|
||||
where it does not run, and it will be the configuration you are in when you
|
||||
need it.
|
||||
@@ -0,0 +1,50 @@
|
||||
# Scrolling works, but nothing proves it against a real compositor
|
||||
|
||||
## The issue
|
||||
|
||||
`hhstream session pointer scroll <id> --amount N` now exists end to end: CLI →
|
||||
`pointer.scroll` → the lease check → driver `axis` op →
|
||||
`zwlr_virtual_pointer_v1.axis(time, axis, value)` → `frame`. Validation is
|
||||
covered by unit tests, and the lease behaviour matches the other gestures.
|
||||
|
||||
What is **not** covered is the half that matters: no test scrolls a real
|
||||
application on a real compositor. The `vm-pointer` gate has no axis case, and
|
||||
the fake compositor can only prove the wiring — that the broker said the right
|
||||
thing to the driver, not that a window moved.
|
||||
|
||||
Also unproven, and worth knowing before trusting it: whether an app on a
|
||||
**headless** output honours a bare `axis` event at all. GTK and Chromium
|
||||
smooth-scrolling both look at `axis_source` and `axis_discrete`, which the
|
||||
driver does not send today. If they are required, the symptom will be a scroll
|
||||
that silently does nothing — indistinguishable from a page that would not move.
|
||||
|
||||
## Ideas
|
||||
|
||||
1. **An axis case in `vm-pointer` that reads the app's own state.** *(recommended)*
|
||||
Scroll a real app and assert *its* state changed, not the pixels — the
|
||||
contract already sets this bar for clicks ("verified by reading the app's own
|
||||
state"). A `foot` running a script that appends a line on scroll, or a page
|
||||
whose scroll offset the app can report, keeps the assertion honest.
|
||||
2. **Send `axis_source` and `axis_discrete` alongside `axis`** if (1) shows the
|
||||
event arriving and the app ignoring it. Small, confined to the driver's
|
||||
`axis` op.
|
||||
3. **Keep the direction convention in one place.** Positive vertical is down and
|
||||
positive horizontal is right, per the protocol. It is documented in
|
||||
`hhstream_pointer/buttons.py` and mirrored in the CLI's `AXES` — if a third
|
||||
copy ever appears, that is the point to notice, because two vocabularies over
|
||||
one sign is how a scroll ends up backwards.
|
||||
4. **A live check on this machine, not only in a VM.** The video that prompted
|
||||
this work is a real scroll on a real app; making that reproducible as a
|
||||
command (like `examples/proof-video.py`) is worth as much as the VM case.
|
||||
|
||||
## Why it matters
|
||||
|
||||
An unimplemented feature is honest; a **plausible** one is not. A scroll that
|
||||
does nothing, a scroll that goes the wrong way, and a scroll the app ignores all
|
||||
present as "the page would not move", and all three would be found by a human
|
||||
watching a video — which is not a test.
|
||||
|
||||
This is the same shape as the bug that made `foot` exit 230 with every test
|
||||
green: the tests exercised what was built, and the built thing was fine, and the
|
||||
app exited anyway. Anything whose acceptance proof runs through a real window
|
||||
needs a real window in the test.
|
||||
@@ -0,0 +1,214 @@
|
||||
#!/usr/bin/env python3
|
||||
"""The acceptance video: an SKS search, real scrolling, tabs, and cowsay.
|
||||
|
||||
One command, no arguments, and it cleans up after itself. It starts a browser
|
||||
session (which gets a desk of its own — its own output and workspace), films
|
||||
*that desk alone*, drives the search over the browser's own HTTP endpoints, and
|
||||
scrolls the results page with the real pointer -- `hhstream session pointer
|
||||
scroll`, which sends wl_pointer axis events rather than pressing a key.
|
||||
|
||||
Then it kills the browser, starts a terminal session on its own desk, and films
|
||||
cowsay saying what it says. The two films are joined into one mp4.
|
||||
|
||||
Why `--output` and not the published frame socket: with desks, the socket
|
||||
carries every output stitched side by side, so a viewer would watch two thirds
|
||||
wallpaper. `--output` runs grim per frame against the session's own desk and
|
||||
costs more; the trade is a video of the thing being demonstrated.
|
||||
|
||||
The cursor is **not** in the frames, and that is not a capture setting: the
|
||||
virtual pointer has no cursor image for the compositor to draw. See
|
||||
docs/TODO/cursor-visibility-in-captures.md. The scrolling is visible by what
|
||||
moves, which is why the page is scrolled rather than merely pointed at.
|
||||
|
||||
./proof-video.py [--profile DIR] [--out FILE]
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
CDP_PORT = 9344
|
||||
CDP = f"http://127.0.0.1:{CDP_PORT}"
|
||||
SEARCH = "https://www.gunpost.ca/ads?key=SKS&sort=created&order=desc"
|
||||
LISTINGS = [
|
||||
"https://www.gunpost.ca/firearms/rifles/hamilton/sks-1951-russian-excellent-rifle-762x39-100000-obo",
|
||||
"https://www.gunpost.ca/firearms/rifles/pembroke/1953-tula-russian-sks-762x39-crisp-markings-solid-hardwood-stock-box",
|
||||
"https://www.gunpost.ca/firearms/rifles/markham-york-region/chinese-type-56-sks-hush-folding-stock-original-wood-stock",
|
||||
]
|
||||
MESSAGE = "hahaha I can see the world now"
|
||||
#: Absolute, because the broker is a systemd unit and a unit's PATH has no system
|
||||
#: profile in it: a bare `cowsay` fails inside foot with "No such file or directory".
|
||||
COWSAY = "/nix/store/s4hlzmy3ll1bphdsy8vjdpcw447vbr93-cowsay-3.8.4/bin/cowsay"
|
||||
|
||||
#: How long each film runs. The beats below are timed to fit inside these.
|
||||
BROWSER_SECONDS = 44
|
||||
COW_SECONDS = 12
|
||||
|
||||
|
||||
def call(path: str, method: str = "GET") -> dict:
|
||||
req = urllib.request.Request(CDP + path, method=method)
|
||||
with urllib.request.urlopen(req, timeout=15) as response:
|
||||
body = response.read().decode()
|
||||
return json.loads(body) if body.strip() else {}
|
||||
|
||||
|
||||
def open_tab(url: str) -> str:
|
||||
return call("/json/new?" + urllib.parse.quote(url, safe=""), method="PUT")["id"]
|
||||
|
||||
|
||||
def activate(tab_id: str) -> None:
|
||||
"""Bring a tab to the front. Cosmetic: never fail the recording over it."""
|
||||
|
||||
try:
|
||||
call("/json/activate/" + tab_id)
|
||||
except Exception as exc: # noqa: BLE001 - a failed activation is not fatal
|
||||
print(f" (activate {tab_id[:8]} said: {exc})", flush=True)
|
||||
|
||||
|
||||
def hhstream(*args: str, check: bool = False) -> str:
|
||||
out = subprocess.run(["hhstream", *args], capture_output=True, text=True, timeout=300)
|
||||
if out.returncode != 0:
|
||||
print(f" (hhstream {' '.join(args[:3])} -> {out.returncode}: {out.stderr.strip()[:160]})")
|
||||
if check:
|
||||
raise SystemExit(f"hhstream {' '.join(args[:3])} failed")
|
||||
return out.stdout.strip()
|
||||
|
||||
|
||||
def desk_of(session: str) -> str:
|
||||
"""The output name of a session's desk, as the broker recorded it."""
|
||||
|
||||
reply = json.loads(hhstream("session", "container", "--json") or "{}")
|
||||
rows = reply.get("containers") or reply.get("sessions") or []
|
||||
for row in rows:
|
||||
if row.get("id") == session:
|
||||
desk = row.get("output") or (row.get("container") or {}).get("output")
|
||||
if desk:
|
||||
return desk
|
||||
raise SystemExit(f"{session} has no desk output: {json.dumps(rows)[:300]}")
|
||||
|
||||
|
||||
def busy_work(session: str) -> None:
|
||||
"""The pointer beats: scroll the results, then walk the listings.
|
||||
|
||||
Scrolling is the point of these beats. The pointer is aimed into this
|
||||
session's own desk, so the scroll lands on its page and nowhere else -- and
|
||||
because the cursor is not drawn, what a viewer sees is the page moving.
|
||||
"""
|
||||
|
||||
lease = json.loads(hhstream("session", "pointer", "acquire", session, "--json") or "{}")
|
||||
lease_id = lease.get("lease_id")
|
||||
if not lease_id:
|
||||
print(f" (no lease: {json.dumps(lease)[:200]})", flush=True)
|
||||
return
|
||||
# Down, down again, then back up: two directions, so it cannot be mistaken
|
||||
# for a page that simply loaded a different part of itself.
|
||||
hhstream("session", "pointer", "move", session, "--lease", lease_id, "--to", "0.5,0.55")
|
||||
for amount, pause in ((6, 2.5), (6, 2.5), (-4, 2.0)):
|
||||
print(f" scroll vertical {amount:+d}", flush=True)
|
||||
hhstream(
|
||||
"session", "pointer", "scroll", session,
|
||||
"--lease", lease_id, "--axis", "vertical", "--amount", str(amount),
|
||||
)
|
||||
time.sleep(pause)
|
||||
hhstream("session", "pointer", "release", session, "--lease", lease_id)
|
||||
|
||||
|
||||
def film(session: str, seconds: int, out: pathlib.Path) -> None:
|
||||
"""Record one desk until `seconds` have passed, then wait for the encoder."""
|
||||
|
||||
hhstream(
|
||||
"record", "--output", desk_of(session), "--fps", "12",
|
||||
"--seconds", str(seconds), "--out", str(out),
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--profile", default="/var/lib/hermes/agent-eyes/gunpost-profile")
|
||||
parser.add_argument("--out", default="/var/lib/hermes/agent-eyes/desks-proof.mp4")
|
||||
parser.add_argument("--work-dir", default="/var/lib/hermes/agent-eyes/takes")
|
||||
args = parser.parse_args()
|
||||
|
||||
out = pathlib.Path(args.out)
|
||||
work = pathlib.Path(args.work_dir)
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
pathlib.Path(args.profile).mkdir(parents=True, exist_ok=True)
|
||||
a, b = work / "desk-a.mp4", work / "desk-b.mp4"
|
||||
|
||||
print("=== starting the browser on its own desk ===", flush=True)
|
||||
browser = hhstream(
|
||||
"session", "start", "chromium", "--",
|
||||
"--ozone-platform=wayland", f"--user-data-dir={args.profile}",
|
||||
"--no-first-run", "--no-default-browser-check", "--window-size=1280,720",
|
||||
f"--remote-debugging-port={CDP_PORT}", "--remote-debugging-address=127.0.0.1",
|
||||
"--new-window", "about:blank",
|
||||
check=True,
|
||||
)
|
||||
print(f" {browser} on {desk_of(browser)}", flush=True)
|
||||
time.sleep(4) # let the window map and the debugging port come up
|
||||
|
||||
print("=== film 1: the search, scrolling, and three listings ===", flush=True)
|
||||
recording = subprocess.Popen(
|
||||
["hhstream", "record", "--output", desk_of(browser), "--fps", "12",
|
||||
"--seconds", str(BROWSER_SECONDS), "--out", str(a)],
|
||||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL,
|
||||
)
|
||||
time.sleep(2)
|
||||
search_tab = open_tab(SEARCH)
|
||||
activate(search_tab)
|
||||
print(" the SKS search is loading (Cloudflare included)", flush=True)
|
||||
time.sleep(13)
|
||||
busy_work(browser)
|
||||
for n, url in enumerate(LISTINGS, 1):
|
||||
activate(open_tab(url))
|
||||
print(f" listing {n} in its own tab", flush=True)
|
||||
time.sleep(4)
|
||||
activate(search_tab)
|
||||
time.sleep(2)
|
||||
recording.wait(timeout=300)
|
||||
print(f" {a}: {a.stat().st_size} bytes", flush=True)
|
||||
|
||||
print("=== clearing the browser away ===", flush=True)
|
||||
print(f" {hhstream('session', 'kill', browser)[:90]}", flush=True)
|
||||
time.sleep(2)
|
||||
|
||||
print("=== film 2: a terminal on its own desk, running cowsay ===", flush=True)
|
||||
terminal = hhstream(
|
||||
"session", "start", "foot", "--",
|
||||
"-H", "-f", "monospace:size=20", COWSAY, MESSAGE,
|
||||
check=True,
|
||||
)
|
||||
print(f" {terminal} on {desk_of(terminal)}", flush=True)
|
||||
time.sleep(2)
|
||||
film(terminal, COW_SECONDS, b)
|
||||
print(f" {b}: {b.stat().st_size} bytes", flush=True)
|
||||
print(f" {hhstream('session', 'kill', terminal)[:90]}", flush=True)
|
||||
|
||||
print("=== joining the two films ===", flush=True)
|
||||
listing = work / "concat.txt"
|
||||
listing.write_text(f"file '{a}'\nfile '{b}'\n")
|
||||
joined = subprocess.run(
|
||||
["ffmpeg", "-v", "error", "-f", "concat", "-safe", "0", "-i", str(listing),
|
||||
"-c", "copy", "-y", str(out)],
|
||||
capture_output=True, text=True,
|
||||
)
|
||||
if joined.returncode != 0:
|
||||
raise SystemExit(f"join failed: {joined.stderr.strip()[:300]}")
|
||||
probe = subprocess.run(
|
||||
["ffprobe", "-v", "error", "-show_entries", "format=duration,size",
|
||||
"-of", "default=noprint_wrappers=1", str(out)],
|
||||
capture_output=True, text=True,
|
||||
)
|
||||
print(f" {out}\n {probe.stdout.strip().replace(chr(10), ' ')}", flush=True)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+12
-2
@@ -79,8 +79,18 @@ in ''
|
||||
}
|
||||
|
||||
input {
|
||||
# No pointer will ever exist; do not let focus depend on one.
|
||||
follow_mouse = 0
|
||||
# Focus follows the pointer. This was `0`, on the reasoning written here
|
||||
# that no pointer would ever exist — true when it was written, and false
|
||||
# now that the broker injects one.
|
||||
#
|
||||
# It is not a preference. With `0` Hyprland delivers pointer events only to
|
||||
# the keyboard-focused window: measured in `vm-pointer`, a click aimed at
|
||||
# 0.25,0.75 of a session's container placed the cursor at x=299 y=519,
|
||||
# inside that window, and **both** clients reported nothing — the click was
|
||||
# aimed correctly and delivered nowhere. The cursor lease already
|
||||
# serialises input, so letting the pointer move keyboard focus cannot make
|
||||
# two sessions fight over the keyboard.
|
||||
follow_mouse = 1
|
||||
}
|
||||
|
||||
# Frames cost capture bandwidth and CPU, and no one is watching the easing.
|
||||
|
||||
@@ -27,7 +27,7 @@ DEFAULT_SOCKET = "/run/hypr-stream/stream.sock"
|
||||
#: Contract: the published socket is mode 0660 (ownership is the unit's job).
|
||||
SOCKET_MODE = 0o660
|
||||
#: Contract default for `services.hyprland-headless-stream.captureCommand`.
|
||||
DEFAULT_CAPTURE_COMMAND = ["grim", "-t", "png", "-"]
|
||||
DEFAULT_CAPTURE_COMMAND = ["grim", "-c", "-t", "png", "-"]
|
||||
|
||||
_BACKLOG = 64
|
||||
_WAIT_TICK = 0.2 # how often a blocked client thread re-checks for shutdown
|
||||
|
||||
@@ -193,6 +193,10 @@ class WaylandSink:
|
||||
self._pointer(output).button(_now_ms(), code, state)
|
||||
self._flush()
|
||||
|
||||
def axis(self, output: str, axis: int, value: float) -> None:
|
||||
self._pointer(output).axis(_now_ms(), axis, value)
|
||||
self._flush()
|
||||
|
||||
def frame(self, output: str) -> None:
|
||||
self._pointer(output).frame()
|
||||
self._flush()
|
||||
|
||||
@@ -27,7 +27,30 @@ CODES: dict[str, int] = {
|
||||
#: ``wl_pointer.button_state``. Named on the wire so a log line reads.
|
||||
STATES: dict[str, int] = {"up": 0, "down": 1}
|
||||
|
||||
#: ``wl_pointer_axis`` values. Named "vertical"/"horizontal" rather than
|
||||
#: up/down/left/right, because the sign is what carries the direction: the
|
||||
#: protocol's positive vertical scroll is *down*, and a caller asking for
|
||||
#: "down" while a negative value means down is how a scroll ends up backwards.
|
||||
AXES: dict[str, int] = {"vertical": 0, "horizontal": 1}
|
||||
|
||||
#: The largest scroll a single request may carry, in wheel clicks. Bounded so a
|
||||
#: decimal-point slip (3 -> 30000) is a refusal rather than a session scrolled
|
||||
#: into next week, where the only clue is that the page will not move back.
|
||||
MAX_AXIS_VALUE = 100.0
|
||||
|
||||
NAMES = tuple(CODES)
|
||||
AXIS_NAMES = tuple(AXES)
|
||||
|
||||
|
||||
def axis_for(name: str) -> int:
|
||||
"""The protocol axis for a name, or :class:`ValueError` naming the set."""
|
||||
|
||||
try:
|
||||
return AXES[name]
|
||||
except KeyError:
|
||||
raise ValueError(
|
||||
f"unknown axis {name!r} (known: {', '.join(AXIS_NAMES)})"
|
||||
) from None
|
||||
|
||||
|
||||
def code_for(name: str) -> int:
|
||||
|
||||
@@ -39,6 +39,13 @@ class PointerSink(Protocol):
|
||||
def button(self, output: str, code: int, state: int) -> None:
|
||||
"""An evdev button code and a ``wl_pointer.button_state``."""
|
||||
|
||||
def axis(self, output: str, axis: int, value: float) -> None:
|
||||
"""Scroll by ``value`` wheel clicks along ``axis`` (a ``wl_pointer_axis``).
|
||||
|
||||
Positive vertical is *down* and positive horizontal is *right*, which is
|
||||
the protocol's direction and not a choice of ours.
|
||||
"""
|
||||
|
||||
def frame(self, output: str) -> None:
|
||||
"""Commit the queued events. Nothing is delivered until this."""
|
||||
|
||||
@@ -107,6 +114,37 @@ class Dispatcher:
|
||||
self._pressed.pop(name, None)
|
||||
return {"ok": True}
|
||||
|
||||
def _op_axis(self, request: dict) -> dict[str, Any]:
|
||||
"""Scroll the aimed output.
|
||||
|
||||
The output is implicit, like ``button``: there is one cursor, and a
|
||||
scroll belongs to whatever it is currently over. A caller that wants to
|
||||
scroll somewhere else warps first, which is also what makes the gesture
|
||||
serialisable by the lease.
|
||||
"""
|
||||
|
||||
name = request.get("axis", "vertical")
|
||||
if not isinstance(name, str):
|
||||
raise Rejected("'axis' must be a string")
|
||||
try:
|
||||
code = buttons.axis_for(name)
|
||||
except ValueError as exc:
|
||||
raise Rejected(str(exc)) from None
|
||||
|
||||
value = request.get("value", 1.0)
|
||||
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
||||
raise Rejected("'value' must be a number of wheel clicks")
|
||||
value = float(value)
|
||||
if value != value or value in (float("inf"), float("-inf")):
|
||||
raise Rejected("'value' must be finite")
|
||||
if abs(value) > buttons.MAX_AXIS_VALUE:
|
||||
raise Rejected(
|
||||
f"'value' {value} exceeds the {buttons.MAX_AXIS_VALUE:g} wheel-click limit"
|
||||
)
|
||||
|
||||
self._sink.axis(self._aimed(), code, value)
|
||||
return {"ok": True}
|
||||
|
||||
def _op_frame(self, request: dict) -> dict[str, Any]:
|
||||
self._sink.frame(self._aimed())
|
||||
return {"ok": True}
|
||||
@@ -131,6 +169,7 @@ class Dispatcher:
|
||||
_ops = {
|
||||
"warp": _op_warp,
|
||||
"button": _op_button,
|
||||
"axis": _op_axis,
|
||||
"frame": _op_frame,
|
||||
"pressed": _op_pressed,
|
||||
"release_all": _op_release_all,
|
||||
|
||||
@@ -302,6 +302,14 @@ def _build_namespace(parser: argparse.ArgumentParser) -> None:
|
||||
#: and this list only buys a typo an exit 2 instead of an exit 10.
|
||||
BUTTONS = ("left", "right", "middle", "side", "extra", "forward", "back", "task")
|
||||
|
||||
#: Axis names the driver knows (``hhstream_pointer.buttons.AXES``), mirrored for
|
||||
#: the same reason and with the same caveat: the driver remains the authority.
|
||||
#: Direction is the sign of the amount, so there is deliberately no "down" or
|
||||
#: "up" here -- the protocol fixes positive as down (vertical) and right
|
||||
#: (horizontal), and a second vocabulary over it is how a scroll ends up
|
||||
#: backwards.
|
||||
AXES = ("vertical", "horizontal")
|
||||
|
||||
|
||||
def _build_pointer(verbs: Any, common: argparse.ArgumentParser) -> None:
|
||||
"""``session pointer <verb>`` — the one cursor, under a lease (PLAN §6).
|
||||
@@ -409,6 +417,29 @@ def _build_pointer(verbs: Any, common: argparse.ArgumentParser) -> None:
|
||||
"--button", default="left", choices=BUTTONS, metavar="B", help=_button_help()
|
||||
)
|
||||
|
||||
scroll = with_lease(add_gesture(
|
||||
"scroll",
|
||||
_cmd_pointer_scroll,
|
||||
help="scroll the session's screen where the cursor is",
|
||||
description=(
|
||||
"Scroll the session's screen. --amount is signed wheel clicks: "
|
||||
"positive scrolls down (vertical) or right (horizontal), which is "
|
||||
"the protocol's direction rather than a choice of ours. The cursor "
|
||||
"does not move, so the resume point keeps its coordinates -- but it "
|
||||
"is re-stamped, because a scroll is the session acting and a later "
|
||||
"resume should know when it last did."
|
||||
),
|
||||
))
|
||||
scroll.add_argument("id", help="session id")
|
||||
scroll.add_argument(
|
||||
"--axis", default="vertical", choices=AXES, metavar="A",
|
||||
help="vertical (default) or horizontal",
|
||||
)
|
||||
scroll.add_argument(
|
||||
"--amount", type=float, default=3.0, metavar="N",
|
||||
help="wheel clicks, signed; positive is down/right (default: 3)",
|
||||
)
|
||||
|
||||
for name, state in (("down", "down"), ("up", "up")):
|
||||
sub = with_lease(add_gesture(
|
||||
name,
|
||||
@@ -951,6 +982,29 @@ def _cmd_pointer_click(args: argparse.Namespace) -> int:
|
||||
return _finish_gesture(args, reply, render, args.id)
|
||||
|
||||
|
||||
@_guard
|
||||
def _cmd_pointer_scroll(args: argparse.Namespace) -> int:
|
||||
lease_id = _lease_of(args, args.id)
|
||||
if not lease_id:
|
||||
return _no_lease(args, args.id)
|
||||
reply = _request(
|
||||
args,
|
||||
"pointer.scroll",
|
||||
id=args.id,
|
||||
lease_id=lease_id,
|
||||
axis=args.axis,
|
||||
amount=args.amount,
|
||||
)
|
||||
|
||||
def render(r: dict[str, Any]) -> str:
|
||||
return (
|
||||
f"{r.get('id')}: scrolled {r.get('axis')} by {r.get('amount')} "
|
||||
f"at {fmt.render_bookmark(r.get('bookmark'))}"
|
||||
)
|
||||
|
||||
return _finish_gesture(args, reply, render, args.id)
|
||||
|
||||
|
||||
@_guard
|
||||
def _cmd_pointer_button(args: argparse.Namespace) -> int:
|
||||
lease_id = _lease_of(args, args.id)
|
||||
|
||||
@@ -23,7 +23,7 @@ from .clock import Clock, parse_duration
|
||||
from .compositor import CompositorError, CompositorTarget
|
||||
from .launcher import Launcher
|
||||
from .manager import DEFAULT_SETTLE_S, ManagerConfig, SessionManager
|
||||
from .policy import Policy, PolicyError, load_policy
|
||||
from .policy import Policy, PolicyError, load_policy, load_settings
|
||||
from .registry import Registry
|
||||
from .server import ControlServer
|
||||
|
||||
@@ -166,12 +166,23 @@ async def serve(
|
||||
# against whatever directory the app happens to be started in.
|
||||
state_dir = Path(args.state_dir).resolve()
|
||||
runtime_dir = Path(args.runtime_dir).resolve()
|
||||
# The same file the allowlist comes from. Read here rather than in the
|
||||
# manager so the manager keeps taking a plain ManagerConfig, which is what
|
||||
# its tests build directly.
|
||||
settings = load_settings(args.config)
|
||||
config = ManagerConfig(
|
||||
state_dir=state_dir,
|
||||
runtime_dir=runtime_dir,
|
||||
policy=policy,
|
||||
settle_s=args.settle,
|
||||
compositor=compositor,
|
||||
containers_enabled=settings.containers_enabled,
|
||||
container_base=settings.container_base,
|
||||
container_slots=settings.container_slots,
|
||||
container_mode=settings.container_mode,
|
||||
quarantine_workspace=settings.quarantine_workspace,
|
||||
pointer_ttl_s=settings.pointer_ttl_s,
|
||||
pointer_max_s=settings.pointer_max_s,
|
||||
)
|
||||
manager = SessionManager(
|
||||
config,
|
||||
|
||||
@@ -86,9 +86,15 @@ class ContainerHost:
|
||||
mode: tuple[int, int] = DEFAULT_MODE,
|
||||
quarantine_workspace: str = DEFAULT_QUARANTINE_WORKSPACE,
|
||||
ipc: HyprlandIPC | None = None,
|
||||
enabled: bool = True,
|
||||
) -> None:
|
||||
self.runtime_dir = None if runtime_dir is None else Path(runtime_dir)
|
||||
self.allocator = allocator
|
||||
#: Whether this broker gives sessions containers at all. Off is a
|
||||
#: configuration, not a failure: `available()` reports it, and the manager
|
||||
#: already knows what to do with an unavailable host (sessions without
|
||||
#: containers), so nothing else has to branch on it.
|
||||
self.enabled = enabled
|
||||
self.mode = mode
|
||||
self.quarantine_workspace = quarantine_workspace
|
||||
self._wanted_signature = signature
|
||||
@@ -138,8 +144,19 @@ class ContainerHost:
|
||||
|
||||
``version`` is the cheapest round trip that proves the socket is a live
|
||||
compositor and not a leftover inode.
|
||||
|
||||
A host switched off by configuration is unavailable on purpose, and the
|
||||
reason says which key turned it off -- otherwise a machine with
|
||||
containers disabled looks identical to one whose compositor is down, and
|
||||
the operator goes hunting for a broken compositor that is fine.
|
||||
"""
|
||||
|
||||
if not self.enabled:
|
||||
self._last_error = (
|
||||
"containers are disabled in the config "
|
||||
"([compositor] containers_enabled = false)"
|
||||
)
|
||||
return False
|
||||
try:
|
||||
self.ipc().version()
|
||||
except CompositorUnavailable as exc:
|
||||
@@ -219,6 +236,53 @@ class ContainerHost:
|
||||
raise
|
||||
return plan
|
||||
|
||||
def claim(
|
||||
self, app_id: str, pid: int | None, workspace: int, output: str | None
|
||||
) -> ContainerFacts | None:
|
||||
"""Put this session's window on its desk's workspace, and show it.
|
||||
|
||||
Assignment is by **pid**, not by class. The compositor reports every
|
||||
client's pid and the broker knows each session's, so this needs nothing
|
||||
from the application -- which is the point: the per-session window rule
|
||||
matches a class stamp that foot, GTK, Qt and the chromium wrapper all
|
||||
ignore, so a rule-bound desk is empty while the window it was made for
|
||||
sits in the quarantine backstop.
|
||||
|
||||
Two dispatches, in this order: move the window, then make its workspace
|
||||
the one its own output is showing. Moving alone leaves the window on a
|
||||
workspace nobody is looking at -- ``foreground`` false, and a frame
|
||||
capture of wallpaper.
|
||||
|
||||
Everything is read back. What the caller records is where the window
|
||||
*is* afterwards, never where it was sent.
|
||||
"""
|
||||
|
||||
facts = self.read_back(app_id, pid)
|
||||
if facts is None:
|
||||
return None
|
||||
window = facts.window or {}
|
||||
address = window.get("address")
|
||||
if facts.workspace != workspace and address:
|
||||
self.dispatch(
|
||||
[
|
||||
"hyprctl",
|
||||
"dispatch",
|
||||
"movetoworkspacesilent",
|
||||
f"{workspace},address:{address}",
|
||||
]
|
||||
)
|
||||
if output is not None and not self.is_showing(workspace, output):
|
||||
self.dispatch(["hyprctl", "dispatch", "workspace", str(workspace)])
|
||||
return self.read_back(app_id, pid) or facts
|
||||
|
||||
def is_showing(self, workspace: int, output: str) -> bool:
|
||||
"""Is ``output`` the one displaying ``workspace`` right now?"""
|
||||
|
||||
for monitor in self.ipc().monitors():
|
||||
if monitor.name == output:
|
||||
return monitor.active_workspace_id == workspace
|
||||
return False
|
||||
|
||||
def remove(self, output: str) -> None:
|
||||
"""Remove one output of ours. Refuses a name we could not have made."""
|
||||
|
||||
|
||||
@@ -83,6 +83,17 @@ class PointerDriver:
|
||||
def button(self, button: str, state: str) -> None:
|
||||
self.request({"op": "button", "button": button, "state": state})
|
||||
|
||||
def axis(self, axis_name: str, value: float) -> None:
|
||||
"""Scroll the aimed output by ``value`` wheel clicks along ``axis_name``.
|
||||
|
||||
Positive vertical is down, positive horizontal is right (the protocol's
|
||||
direction). The output is whatever the last ``warp`` aimed at, so a
|
||||
scroll into another session is a warp first -- which is also what the
|
||||
lease serialises.
|
||||
"""
|
||||
|
||||
self.request({"op": "axis", "axis": axis_name, "value": float(value)})
|
||||
|
||||
def frame(self) -> None:
|
||||
"""Commit what was queued. Nothing the driver was sent is delivered
|
||||
to the compositor until this, so every gesture ends with one."""
|
||||
|
||||
+80
-6
@@ -33,6 +33,7 @@ watching an idle desktop.
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import stat
|
||||
@@ -49,6 +50,8 @@ INSTANCE_SUBDIR = "hypr"
|
||||
REQUEST_SOCKET_NAME = ".socket.sock"
|
||||
EVENT_SOCKET_NAME = ".socket2.sock"
|
||||
|
||||
log = logging.getLogger("hhstreamd.ipc")
|
||||
|
||||
#: Requests are local, synchronous and tiny. The compositor answers at once or
|
||||
#: it is wedged; this only bounds the pathological case where it accepts the
|
||||
#: connection and then stops. It is a class attribute so a test can shorten it
|
||||
@@ -392,9 +395,23 @@ class HyprlandIPC:
|
||||
raise CompositorUnavailable(f"compositor request socket {request} is not a socket")
|
||||
return cls(request, directory / EVENT_SOCKET_NAME)
|
||||
|
||||
@staticmethod
|
||||
def _sole_instance(hypr: Path) -> str:
|
||||
"""The one directory under ``<runtime_dir>/hypr``, or a refusal."""
|
||||
@classmethod
|
||||
def _sole_instance(cls, hypr: Path) -> str:
|
||||
"""The live instance under ``<runtime_dir>/hypr``, or a refusal.
|
||||
|
||||
A restart leaves its directory behind — the compositor's log outlives
|
||||
it — so after two restarts this directory holds two names and neither is
|
||||
obviously the real one. Refusing outright (which this used to do) is
|
||||
safe but wrong after every rebuild: the broker cannot reach any
|
||||
compositor, so no container can be created and the pointer has nothing to
|
||||
aim at, all for want of a corpse being cleared.
|
||||
|
||||
So each candidate is *asked*, on its own request socket, for its version,
|
||||
and one that answers is the compositor. Nothing is inferred from
|
||||
timestamps unless more than one answers — a dead instance's log file can
|
||||
easily be newer than a live instance's socket, so age is the weakest
|
||||
signal available and is used only to break a tie.
|
||||
"""
|
||||
|
||||
try:
|
||||
with os.scandir(hypr) as entries:
|
||||
@@ -407,12 +424,69 @@ class HyprlandIPC:
|
||||
raise CompositorUnavailable(
|
||||
f"compositor instance dir {hypr} holds no instance; is the compositor running?"
|
||||
)
|
||||
if len(names) > 1:
|
||||
if len(names) == 1:
|
||||
return names[0]
|
||||
|
||||
answered = [name for name in names if cls._answers(hypr / name)]
|
||||
if len(answered) == 1:
|
||||
log.info(
|
||||
"compositor instance dir %s holds %d instances (%s); %s answered, "
|
||||
"using it and ignoring the rest",
|
||||
hypr,
|
||||
len(names),
|
||||
", ".join(names),
|
||||
answered[0],
|
||||
)
|
||||
return answered[0]
|
||||
if not answered:
|
||||
raise CompositorUnavailable(
|
||||
f"compositor instance dir {hypr} holds {len(names)} instances "
|
||||
f"({', '.join(names)}); set {SIGNATURE_ENV} or pass a signature"
|
||||
f"({', '.join(names)}) and none of them answered; set "
|
||||
f"{SIGNATURE_ENV} or pass a signature"
|
||||
)
|
||||
return names[0]
|
||||
newest = max(answered, key=lambda name: cls._socket_age(hypr / name))
|
||||
log.warning(
|
||||
"compositor instance dir %s holds %d answering instances (%s); using the "
|
||||
"most recently modified, %s — pass %s to be certain",
|
||||
hypr,
|
||||
len(answered),
|
||||
", ".join(answered),
|
||||
newest,
|
||||
SIGNATURE_ENV,
|
||||
)
|
||||
return newest
|
||||
|
||||
@classmethod
|
||||
def _answers(cls, directory: Path) -> bool:
|
||||
"""Does this instance dir hold a request socket that replies?
|
||||
|
||||
The probe is the real protocol, not a file check: a socket that exists
|
||||
but belongs to a compositor that is gone looks identical on disk, and
|
||||
the only way to tell them apart is to ask a question with a known
|
||||
answer.
|
||||
"""
|
||||
|
||||
request = directory / REQUEST_SOCKET_NAME
|
||||
try:
|
||||
mode = request.stat().st_mode
|
||||
except OSError:
|
||||
return False
|
||||
if not stat.S_ISSOCK(mode):
|
||||
return False
|
||||
try:
|
||||
cls(request, directory / EVENT_SOCKET_NAME).query("version")
|
||||
except (CompositorUnavailable, OSError):
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _socket_age(directory: Path) -> float:
|
||||
"""Modification time of the request socket, for tie-breaking only."""
|
||||
|
||||
try:
|
||||
return (directory / REQUEST_SOCKET_NAME).stat().st_mtime
|
||||
except OSError:
|
||||
return 0.0
|
||||
|
||||
# -- the request socket ------------------------------------------------
|
||||
|
||||
|
||||
+136
-1
@@ -50,7 +50,12 @@ from . import containers, procmon
|
||||
from .audit import AuditLog
|
||||
from .clock import Clock, iso
|
||||
from .compositor import CompositorTarget
|
||||
from .container_host import DEFAULT_MODE, DEFAULT_QUARANTINE_WORKSPACE, ContainerHost
|
||||
from .container_host import (
|
||||
DEFAULT_MODE,
|
||||
DEFAULT_QUARANTINE_WORKSPACE,
|
||||
ContainerFacts,
|
||||
ContainerHost,
|
||||
)
|
||||
from .driver import DriverRejected, DriverUnavailable, PointerDriver
|
||||
from .ipc import CompositorUnavailable
|
||||
from .launcher import Launcher
|
||||
@@ -116,6 +121,12 @@ DEFAULT_CONTAINER_SLOTS = 4
|
||||
#: and "click 10000 times" is not a gesture.
|
||||
MAX_CLICK_COUNT = 3
|
||||
|
||||
#: The largest scroll one request may carry, in wheel clicks. The driver
|
||||
#: enforces the same ceiling with its own copy (they are separate processes and
|
||||
#: neither imports the other); this one exists so the broker refuses early with a
|
||||
#: message naming the caller's value rather than relaying the driver's.
|
||||
MAX_SCROLL_AMOUNT = 100.0
|
||||
|
||||
SIGNALS_BY_NAME = {
|
||||
"TERM": signal.SIGTERM,
|
||||
"SIGTERM": signal.SIGTERM,
|
||||
@@ -161,6 +172,11 @@ class ManagerConfig:
|
||||
signature: str | None = None
|
||||
container_base: int = DEFAULT_CONTAINER_BASE
|
||||
container_slots: int = DEFAULT_CONTAINER_SLOTS
|
||||
#: Whether sessions get their own output and workspace. False means "process
|
||||
#: groups on the shared output", which is what the machine ran before
|
||||
#: containers existed, and what a deployment that cannot match windows to
|
||||
#: containers yet should be configured with.
|
||||
containers_enabled: bool = True
|
||||
container_mode: tuple[int, int] = DEFAULT_MODE
|
||||
quarantine_workspace: str = DEFAULT_QUARANTINE_WORKSPACE
|
||||
readback_s: float = DEFAULT_READBACK_S
|
||||
@@ -213,6 +229,7 @@ class SessionManager:
|
||||
signature=config.signature,
|
||||
mode=config.container_mode,
|
||||
quarantine_workspace=config.quarantine_workspace,
|
||||
enabled=config.containers_enabled,
|
||||
)
|
||||
# The lease runs on CLOCK_BOOTTIME like every other deadline here, so a
|
||||
# host suspended mid-gesture does not come back believing the lease is
|
||||
@@ -529,6 +546,10 @@ class SessionManager:
|
||||
# `container.reconcile` picks it up later. Nothing is invented.
|
||||
log.info("%s: no window in clients -j yet; workspace and window stay null", session.id)
|
||||
return
|
||||
scene = session.container or {}
|
||||
workspace, output = scene.get("workspace"), scene.get("output")
|
||||
if workspace is not None and output is not None:
|
||||
facts = await self._claim(session, app_id, facts, workspace, output)
|
||||
session.workspace = facts.workspace
|
||||
session.window = facts.window
|
||||
session.foreground = facts.foreground
|
||||
@@ -551,6 +572,44 @@ class SessionManager:
|
||||
)
|
||||
self.registry.persist(session, force=True)
|
||||
|
||||
async def _claim(
|
||||
self,
|
||||
session: Session,
|
||||
app_id: str,
|
||||
facts: ContainerFacts,
|
||||
workspace: int,
|
||||
output: str,
|
||||
) -> ContainerFacts:
|
||||
"""Move the session's window onto its desk, if it is not already there.
|
||||
|
||||
Skipped when the window is already home *and* the desk is showing it,
|
||||
so the steady state costs nothing. Otherwise the compositor is asked to
|
||||
move it and then read back, and what gets recorded is where the window
|
||||
ended up -- an audit event is written only when something actually
|
||||
changed, so the trail stays a record of moves rather than of polls.
|
||||
"""
|
||||
|
||||
if facts.workspace == workspace and facts.foreground:
|
||||
return facts
|
||||
try:
|
||||
claimed = self.host.claim(app_id, session.pid, workspace, output)
|
||||
except CompositorUnavailable as exc:
|
||||
log.error("%s: claiming its window failed: %s", session.id, exc)
|
||||
self.containers_available = False
|
||||
return facts
|
||||
if claimed is None:
|
||||
return facts
|
||||
if claimed.workspace != facts.workspace or claimed.foreground != facts.foreground:
|
||||
self.audit.emit(
|
||||
"container_claimed",
|
||||
session=session.id,
|
||||
from_workspace=facts.workspace,
|
||||
workspace=claimed.workspace,
|
||||
foreground=claimed.foreground,
|
||||
address=(claimed.window or {}).get("address"),
|
||||
)
|
||||
return claimed
|
||||
|
||||
async def shutdown(self) -> None:
|
||||
"""Stop watching, flush the mirror. **Sessions are left running.**
|
||||
|
||||
@@ -1479,6 +1538,15 @@ class SessionManager:
|
||||
except CompositorUnavailable as exc:
|
||||
self.containers_available = False
|
||||
return [{"id": session.id, "field": "compositor", "error": str(exc)}]
|
||||
scene = session.container or {}
|
||||
workspace, output = scene.get("workspace"), scene.get("output")
|
||||
if facts is not None and workspace is not None and output is not None:
|
||||
# Reconcile is the second place a window can be found: the first is
|
||||
# the read-back at start, and an application slow to map one -- or
|
||||
# one that reopened -- turns up only here. Claiming it is a repair,
|
||||
# so it happens before the diff is taken: what gets reported is the
|
||||
# difference between the old record and where the window now is.
|
||||
facts = await self._claim(session, app_id, facts, workspace, output)
|
||||
observed = {
|
||||
"workspace": None if facts is None else facts.workspace,
|
||||
"window": None if facts is None else facts.window,
|
||||
@@ -1652,6 +1720,44 @@ class SessionManager:
|
||||
"bookmark": self._restore_point(session, output),
|
||||
}
|
||||
|
||||
async def pointer_scroll(
|
||||
self, session_id: str, lease_id: str, axis: Any = "vertical", amount: Any = 3
|
||||
) -> dict[str, Any]:
|
||||
"""Scroll the session's screen.
|
||||
|
||||
Same shape as a click -- the lease is checked first, then the driver is
|
||||
told, then the resume point is re-stamped -- with one difference that is
|
||||
worth being precise about: **the cursor does not move**. The
|
||||
coordinates are therefore re-affirmed rather than changed. The stamp
|
||||
advances, because a scroll is the session acting and a later resume
|
||||
should know when it last did -- but not one pixel of the position
|
||||
changes, and a bookmark that claimed otherwise would be fiction.
|
||||
"""
|
||||
|
||||
session, output = await self._refresh(session_id, lease_id)
|
||||
name = _axis_name(axis if axis is not None else "vertical")
|
||||
clicks = _checked_amount(amount)
|
||||
await self._drive("axis", name, clicks)
|
||||
await self._drive("frame")
|
||||
# A bookmark from a container this session no longer has is not a
|
||||
# position in this one, so a missing or stale one falls back to the
|
||||
# centre that the acquire would have aimed at.
|
||||
known = self._restore_point(session, output) or {}
|
||||
mark = self._mark(
|
||||
session,
|
||||
lease_id,
|
||||
output,
|
||||
float(known.get("x", 0.5)),
|
||||
float(known.get("y", 0.5)),
|
||||
)
|
||||
self.audit.emit("pointer_scroll", session=session.id, axis=name, amount=clicks)
|
||||
return {
|
||||
"id": session.id,
|
||||
"axis": name,
|
||||
"amount": clicks,
|
||||
"bookmark": mark,
|
||||
}
|
||||
|
||||
async def pointer_release(self, session_id: str, lease_id: str) -> dict[str, Any]:
|
||||
"""Give the cursor back, leaving nothing pressed and a bookmark behind."""
|
||||
|
||||
@@ -2073,6 +2179,35 @@ def _button_name(value: Any) -> str:
|
||||
return value
|
||||
|
||||
|
||||
def _axis_name(value: Any) -> str:
|
||||
if not isinstance(value, str) or not value:
|
||||
raise ManagerError("invalid_argument", f"axis must be a name, got {value!r}")
|
||||
return value
|
||||
|
||||
|
||||
def _checked_amount(value: Any) -> float:
|
||||
"""A scroll amount in wheel clicks, signed.
|
||||
|
||||
Signed rather than split into `--up`/`--down`: the protocol carries direction
|
||||
in the sign (positive vertical is down), and a second vocabulary on top of it
|
||||
is how a scroll ends up backwards. Zero is refused because it is never
|
||||
intended -- it is a caller that forgot to pass an amount.
|
||||
"""
|
||||
|
||||
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
||||
raise ManagerError(
|
||||
"invalid_argument", f"amount must be a number of wheel clicks, got {value!r}"
|
||||
)
|
||||
amount = float(value)
|
||||
if amount == 0 or abs(amount) > MAX_SCROLL_AMOUNT:
|
||||
raise ManagerError(
|
||||
"invalid_argument",
|
||||
f"amount must be non-zero and at most {MAX_SCROLL_AMOUNT:g} wheel clicks, "
|
||||
f"got {amount}",
|
||||
)
|
||||
return amount
|
||||
|
||||
|
||||
def _checked_count(value: Any) -> int:
|
||||
if isinstance(value, bool) or not isinstance(value, int):
|
||||
raise ManagerError("invalid_argument", f"count must be an integer, got {value!r}")
|
||||
|
||||
@@ -169,6 +169,94 @@ def check_argv(argv: Any) -> None:
|
||||
# --------------------------------------------------------------------------
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class Settings:
|
||||
"""What the config file says that is not the allowlist.
|
||||
|
||||
Kept beside :class:`Policy` because both come out of the same TOML file, and
|
||||
read by ``__main__`` rather than by the manager, so the manager keeps taking a
|
||||
plain :class:`~hhstreamd.manager.ManagerConfig` that a test can build
|
||||
directly. Before this existed the module rendered these keys into the file
|
||||
and the broker read none of them: a deployment could turn containers off, or
|
||||
move a lease deadline, and be silently ignored while the defaults happened to
|
||||
make it look honoured.
|
||||
|
||||
The defaults mirror the manager's own; the module always renders every key,
|
||||
so they matter only for a config written by hand.
|
||||
"""
|
||||
|
||||
containers_enabled: bool = True
|
||||
container_base: int = 1000
|
||||
container_slots: int = 4
|
||||
container_mode: tuple[int, int] = (1280, 720)
|
||||
quarantine_workspace: str = "special:quarantine"
|
||||
pointer_ttl_s: float = 30.0
|
||||
pointer_max_s: float = 300.0
|
||||
|
||||
|
||||
def _mode(value: Any, key: str) -> tuple[int, int]:
|
||||
"""Parse ``"1280x720"`` into ``(1280, 720)``; refuse anything else.
|
||||
|
||||
Refusing matters more than being permissive here: a container created at the
|
||||
wrong size is a session whose window does not fit its own screen, which looks
|
||||
like an application bug rather than a typo in a config file.
|
||||
"""
|
||||
|
||||
if isinstance(value, str) and "x" in value:
|
||||
width, _, height = value.partition("x")
|
||||
try:
|
||||
return int(width), int(height)
|
||||
except ValueError:
|
||||
pass
|
||||
if isinstance(value, (list, tuple)) and len(value) == 2:
|
||||
return int(value[0]), int(value[1])
|
||||
raise PolicyError(
|
||||
"invalid_argument",
|
||||
f"[compositor] {key} must look like \"1280x720\", got {value!r}",
|
||||
)
|
||||
|
||||
|
||||
def settings_from_dict(data: dict[str, Any]) -> Settings:
|
||||
defaults = data.get("defaults", {})
|
||||
if not isinstance(defaults, dict):
|
||||
raise PolicyError("invalid_argument", "[defaults] must be a table")
|
||||
compositor = data.get("compositor", {})
|
||||
if not isinstance(compositor, dict):
|
||||
raise PolicyError("invalid_argument", "[compositor] must be a table")
|
||||
pointer = data.get("pointer", {})
|
||||
if not isinstance(pointer, dict):
|
||||
raise PolicyError("invalid_argument", "[pointer] must be a table")
|
||||
|
||||
return Settings(
|
||||
containers_enabled=bool(compositor.get("containers_enabled", True)),
|
||||
container_base=int(compositor.get("workspace_base", 1000)),
|
||||
container_slots=int(defaults.get("max_containers", 4)),
|
||||
container_mode=_mode(compositor.get("container_mode", "1280x720"), "container_mode"),
|
||||
quarantine_workspace=str(
|
||||
compositor.get("quarantine_workspace", "special:quarantine")
|
||||
),
|
||||
pointer_ttl_s=float(pointer.get("lease_ttl_s", 30.0)),
|
||||
pointer_max_s=float(pointer.get("lease_max_s", 300.0)),
|
||||
)
|
||||
|
||||
|
||||
def load_settings(path: Path | str | None) -> Settings:
|
||||
"""Read the non-allowlist settings from the file :func:`load_policy` reads.
|
||||
|
||||
A missing file is the defaults, for the same reason a missing allowlist is an
|
||||
empty one: a misconfigured deployment should behave conservatively, not fail
|
||||
to start.
|
||||
"""
|
||||
|
||||
if path is None:
|
||||
return Settings()
|
||||
path = Path(path)
|
||||
if not path.exists():
|
||||
return Settings()
|
||||
with open(path, "rb") as fh:
|
||||
return settings_from_dict(tomllib.load(fh))
|
||||
|
||||
|
||||
def load_policy(path: Path | str | None) -> Policy:
|
||||
"""Read the allowlist from a TOML file.
|
||||
|
||||
|
||||
@@ -148,6 +148,7 @@ VERBS = (
|
||||
"pointer.move",
|
||||
"pointer.button",
|
||||
"pointer.click",
|
||||
"pointer.scroll",
|
||||
"pointer.release",
|
||||
"pointer.state",
|
||||
)
|
||||
@@ -171,6 +172,7 @@ MUTATING_VERBS = frozenset(
|
||||
"pointer.move",
|
||||
"pointer.button",
|
||||
"pointer.click",
|
||||
"pointer.scroll",
|
||||
"pointer.release",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -70,6 +70,7 @@ class ControlServer:
|
||||
"pointer.move": self._op_pointer_move,
|
||||
"pointer.button": self._op_pointer_button,
|
||||
"pointer.click": self._op_pointer_click,
|
||||
"pointer.scroll": self._op_pointer_scroll,
|
||||
"pointer.release": self._op_pointer_release,
|
||||
"pointer.state": self._op_pointer_state,
|
||||
}
|
||||
@@ -356,6 +357,18 @@ class ControlServer:
|
||||
)
|
||||
)
|
||||
|
||||
async def _op_pointer_scroll(
|
||||
self, request: dict[str, Any], caller: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
return protocol.ok(
|
||||
**await self.manager.pointer_scroll(
|
||||
request.get("id"),
|
||||
request.get("lease_id"),
|
||||
request.get("axis", "vertical"),
|
||||
request.get("amount", 3),
|
||||
)
|
||||
)
|
||||
|
||||
async def _op_pointer_release(
|
||||
self, request: dict[str, Any], caller: dict[str, Any]
|
||||
) -> dict[str, Any]:
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
"""Finding the instance, and refusing to pick one when there is a choice.
|
||||
"""Finding the instance: one answer beats a name that merely exists.
|
||||
|
||||
Two instances and no signature is the dangerous case: a broker that guessed
|
||||
would aim its queries — and later its pointer — at someone else's desktop.
|
||||
Two instance dirs and no signature used to be a hard refusal. It still is when
|
||||
neither answers — a broker that guessed would aim its queries, and later its
|
||||
pointer, at someone else's desktop. But a *dead* instance directory is left
|
||||
behind by every compositor restart, so refusing on two names made the broker
|
||||
blind after every rebuild. The compositor that answers a version request is the
|
||||
one that exists; the corpse beside it is a log file.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import socket
|
||||
import threading
|
||||
|
||||
import pytest
|
||||
|
||||
from hhstreamd.ipc import SIGNATURE_ENV, CompositorUnavailable, HyprlandIPC
|
||||
|
||||
BANNER = b"Hyprland 0.56.2 built from branch v0.56.2-b\nTag: v0.56.2\n"
|
||||
|
||||
|
||||
def bind(path):
|
||||
"""A bound, listening socket at ``path``, so discovery sees a real one."""
|
||||
@@ -22,6 +30,33 @@ def bind(path):
|
||||
return sock
|
||||
|
||||
|
||||
def answering(path):
|
||||
"""A socket with a compositor behind it: it replies to a version request."""
|
||||
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
sock.bind(str(path))
|
||||
sock.listen(4)
|
||||
|
||||
def serve() -> None:
|
||||
while True:
|
||||
try:
|
||||
conn, _ = sock.accept()
|
||||
except OSError:
|
||||
return
|
||||
with conn:
|
||||
# The client half-closes after writing, so the request ends at
|
||||
# EOF -- the same shape the real compositor sees.
|
||||
while conn.recv(4096):
|
||||
pass
|
||||
try:
|
||||
conn.sendall(BANNER)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
threading.Thread(target=serve, daemon=True).start()
|
||||
return sock
|
||||
|
||||
|
||||
def test_single_instance_is_discovered(runtime_dir, instance, monkeypatch):
|
||||
monkeypatch.delenv(SIGNATURE_ENV, raising=False)
|
||||
sock = bind(instance / ".socket.sock")
|
||||
@@ -47,19 +82,60 @@ def test_zero_instances_under_hypr(runtime_dir, monkeypatch):
|
||||
HyprlandIPC.discover(runtime_dir)
|
||||
|
||||
|
||||
def test_two_instances_without_a_signature_refuses(runtime_dir, instance, monkeypatch):
|
||||
def test_two_instances_and_one_answers_uses_the_one_that_answers(
|
||||
runtime_dir, instance, monkeypatch
|
||||
):
|
||||
"""The corpse beside the live compositor must not make the broker blind."""
|
||||
|
||||
monkeypatch.delenv(SIGNATURE_ENV, raising=False)
|
||||
corpse = runtime_dir / "hypr" / "deadbee_1700000001"
|
||||
corpse.mkdir()
|
||||
(corpse / "hyprland.log").write_text("this compositor is gone; only its log is here\n")
|
||||
sock = answering(instance / ".socket.sock")
|
||||
try:
|
||||
ipc = HyprlandIPC.discover(runtime_dir)
|
||||
finally:
|
||||
sock.close()
|
||||
assert ipc.request_socket == instance / ".socket.sock"
|
||||
|
||||
|
||||
def test_two_instances_and_neither_answers_refuses(runtime_dir, instance, monkeypatch):
|
||||
"""Nothing answering is still the dangerous case, and still refused."""
|
||||
|
||||
monkeypatch.delenv(SIGNATURE_ENV, raising=False)
|
||||
other = runtime_dir / "hypr" / "deadbee_1700000001"
|
||||
other.mkdir()
|
||||
bind(instance / ".socket.sock").close()
|
||||
(other / "hyprland.log").write_text("dead\n")
|
||||
(instance / ".socket.sock").write_text("not a socket")
|
||||
with pytest.raises(CompositorUnavailable) as caught:
|
||||
HyprlandIPC.discover(runtime_dir)
|
||||
message = str(caught.value)
|
||||
assert "2 instances" in message
|
||||
assert instance.name in message and other.name in message
|
||||
assert "none of them answered" in message
|
||||
assert SIGNATURE_ENV in message
|
||||
|
||||
|
||||
def test_two_answering_instances_pick_the_most_recent(runtime_dir, instance, monkeypatch):
|
||||
"""Two live compositors is a real ambiguity: take the newest, and say so."""
|
||||
|
||||
monkeypatch.delenv(SIGNATURE_ENV, raising=False)
|
||||
older = runtime_dir / "hypr" / "aaaaaaa_1700000001"
|
||||
older.mkdir()
|
||||
older_sock = answering(older / ".socket.sock")
|
||||
newer = runtime_dir / "hypr" / "bbbbbbb_1700000002"
|
||||
newer.mkdir()
|
||||
newer_sock = answering(newer / ".socket.sock")
|
||||
try:
|
||||
os.utime(older / ".socket.sock", (1_700_000_001, 1_700_000_001))
|
||||
os.utime(newer / ".socket.sock", (1_700_000_002, 1_700_000_002))
|
||||
ipc = HyprlandIPC.discover(runtime_dir)
|
||||
finally:
|
||||
older_sock.close()
|
||||
newer_sock.close()
|
||||
assert ipc.request_socket == newer / ".socket.sock"
|
||||
|
||||
|
||||
def test_two_instances_with_an_explicit_signature(runtime_dir, instance, monkeypatch):
|
||||
monkeypatch.delenv(SIGNATURE_ENV, raising=False)
|
||||
other = runtime_dir / "hypr" / "deadbee_1700000001"
|
||||
|
||||
@@ -34,6 +34,9 @@ class RecordingSink:
|
||||
def button(self, output, code, state):
|
||||
self.calls.append(("button", output, code, state))
|
||||
|
||||
def axis(self, output, axis, value):
|
||||
self.calls.append(("axis", output, axis, value))
|
||||
|
||||
def frame(self, output):
|
||||
self.calls.append(("frame", output))
|
||||
|
||||
@@ -105,6 +108,51 @@ def test_buttons_follow_the_last_warp_not_the_first(driver, sink):
|
||||
assert sink.calls[-1] == ("button", "hh-beta", LEFT, DOWN)
|
||||
|
||||
|
||||
# -- axis (scrolling) -------------------------------------------------------
|
||||
|
||||
|
||||
def test_axis_scrolls_the_aimed_output_and_sends_no_implicit_frame(driver, sink):
|
||||
warp(driver)
|
||||
sink.calls.clear()
|
||||
|
||||
assert driver.handle({"op": "axis", "axis": "vertical", "value": 3}) == {"ok": True}
|
||||
assert sink.calls == [("axis", "hh-alpha", buttons.AXES["vertical"], 3.0)]
|
||||
|
||||
|
||||
def test_axis_defaults_to_one_vertical_click(driver, sink):
|
||||
warp(driver)
|
||||
sink.calls.clear()
|
||||
|
||||
assert driver.handle({"op": "axis"}) == {"ok": True}
|
||||
assert sink.calls == [("axis", "hh-alpha", buttons.AXES["vertical"], 1.0)]
|
||||
|
||||
|
||||
def test_a_horizontal_scroll_is_the_other_axis_and_keeps_the_sign(driver, sink):
|
||||
warp(driver)
|
||||
sink.calls.clear()
|
||||
|
||||
assert driver.handle({"op": "axis", "axis": "horizontal", "value": -2}) == {"ok": True}
|
||||
assert sink.calls == [("axis", "hh-alpha", buttons.AXES["horizontal"], -2.0)]
|
||||
# Two names, two axes -- and positive is down/right, per the protocol rather
|
||||
# than per us, which is why direction travels in the sign and not the name.
|
||||
assert buttons.AXES["vertical"] != buttons.AXES["horizontal"]
|
||||
|
||||
|
||||
def test_a_scroll_goes_to_the_pointer_the_last_warp_aimed(driver, sink):
|
||||
warp(driver, output="hh-alpha")
|
||||
warp(driver, output="hh-beta")
|
||||
sink.calls.clear()
|
||||
|
||||
driver.handle({"op": "axis", "value": 5})
|
||||
|
||||
assert sink.calls == [("axis", "hh-beta", buttons.AXES["vertical"], 5.0)]
|
||||
|
||||
|
||||
def test_scroll_before_any_warp_is_refused(driver, sink):
|
||||
assert driver.handle({"op": "axis", "value": 3})["ok"] is False
|
||||
assert sink.calls == [], "a scroll with nothing aimed must emit nothing"
|
||||
|
||||
|
||||
# -- pressed / release_all --------------------------------------------------
|
||||
|
||||
|
||||
@@ -220,6 +268,13 @@ def test_a_failed_warp_does_not_change_the_aim():
|
||||
({"op": "button", "button": "left"}, "'state' must be"),
|
||||
({"op": "button", "button": "pinky", "state": "down"}, "unknown button 'pinky'"),
|
||||
({"op": "button", "button": "left", "state": "sideways"}, "unknown button state"),
|
||||
({"op": "axis", "axis": "diagonal"}, "unknown axis 'diagonal'"),
|
||||
({"op": "axis", "axis": 0}, "'axis' must be a string"),
|
||||
({"op": "axis", "value": "a lot"}, "'value' must be a number"),
|
||||
({"op": "axis", "value": True}, "'value' must be a number"),
|
||||
({"op": "axis", "value": float("nan")}, "'value' must be finite"),
|
||||
({"op": "axis", "value": 101}, "wheel-click limit"),
|
||||
({"op": "axis", "value": -1e9}, "wheel-click limit"),
|
||||
],
|
||||
)
|
||||
def test_malformed_requests_are_answered_not_fatal(sink, request_, fragment):
|
||||
@@ -240,5 +295,21 @@ def test_a_non_object_request_is_refused(driver, request_):
|
||||
assert "must be a JSON object" in driver.handle(request_)["error"]
|
||||
|
||||
|
||||
def test_the_contracts_five_ops_are_exactly_what_is_implemented():
|
||||
assert set(Dispatcher._ops) == {"warp", "button", "frame", "pressed", "release_all"}
|
||||
def test_the_contracts_ops_are_exactly_what_is_implemented() -> None:
|
||||
"""The op set cannot drift quietly.
|
||||
|
||||
An op that exists here and nowhere in the contract -- or the reverse --
|
||||
fails this test rather than surprising whoever reads the contract next.
|
||||
``axis`` is the one addition since the freeze, made deliberately so that a
|
||||
session can scroll; the set is edited by hand, which is the reminder to
|
||||
write it down.
|
||||
"""
|
||||
|
||||
assert set(Dispatcher._ops) == {
|
||||
"warp",
|
||||
"button",
|
||||
"axis",
|
||||
"frame",
|
||||
"pressed",
|
||||
"release_all",
|
||||
}
|
||||
@@ -213,10 +213,63 @@ class FakeCompositor:
|
||||
return "ok"
|
||||
if words[:2] == ["output", "remove"] and len(words) == 3:
|
||||
return "ok" if self._remove_output(words[2]) else f"no such output {words[2]}"
|
||||
if words[:2] == ["dispatch", "movetoworkspacesilent"] and len(words) == 3:
|
||||
return self._move_to_workspace(words[2])
|
||||
if words[:2] == ["dispatch", "workspace"] and len(words) == 3:
|
||||
return self._show_workspace(words[2])
|
||||
if words[:1] == ["keyword"]:
|
||||
return self._keyword(command[len("keyword") :].strip())
|
||||
return f"unknown request {command!r}"
|
||||
|
||||
# -- dispatches -------------------------------------------------------
|
||||
|
||||
def _move_to_workspace(self, spec: str) -> str:
|
||||
"""``<workspace>,address:<addr>`` -- what the broker claims with.
|
||||
|
||||
Moving a window is the one thing that puts a real application on its
|
||||
desk, because no allowlisted app carries the class the rule matches.
|
||||
"""
|
||||
|
||||
workspace_text, _, address = spec.partition(",address:")
|
||||
if not workspace_text.isdigit() or not address:
|
||||
return f"malformed move {spec!r}"
|
||||
client = next((c for c in self._clients if c["address"] == address), None)
|
||||
if client is None:
|
||||
return f"no such window {address}"
|
||||
workspace = int(workspace_text)
|
||||
monitor = next(
|
||||
(m["name"] for m in self._monitors if m["id"] == client["monitor"]), None
|
||||
)
|
||||
if not any(w["id"] == workspace for w in self._workspaces):
|
||||
self._workspaces.append(
|
||||
{"id": workspace, "name": str(workspace), "monitor": monitor, "windows": 0}
|
||||
)
|
||||
for entry in self._workspaces:
|
||||
if entry["id"] == client["workspace"]["id"]:
|
||||
entry["windows"] = max(0, entry["windows"] - 1)
|
||||
if entry["id"] == workspace:
|
||||
entry["windows"] += 1
|
||||
client["workspace"] = {"id": workspace, "name": str(workspace)}
|
||||
return "ok"
|
||||
|
||||
def _show_workspace(self, workspace_text: str) -> str:
|
||||
"""``workspace <n>`` -- makes that workspace the visible one.
|
||||
|
||||
Only meaningful on the output that holds it, which is how Hyprland
|
||||
behaves: the workspace's own monitor switches to it.
|
||||
"""
|
||||
|
||||
if not workspace_text.lstrip("-").isdigit():
|
||||
return f"malformed workspace {workspace_text!r}"
|
||||
workspace = int(workspace_text)
|
||||
holder = next((w["monitor"] for w in self._workspaces if w["id"] == workspace), None)
|
||||
if holder is None:
|
||||
return f"no such workspace {workspace}"
|
||||
for monitor in self._monitors:
|
||||
if monitor["name"] == holder:
|
||||
monitor["activeWorkspace"] = {"id": workspace, "name": str(workspace)}
|
||||
return "ok"
|
||||
|
||||
def _keyword(self, rest: str) -> str:
|
||||
name, _, body = rest.partition(" ")
|
||||
if name == "workspace":
|
||||
@@ -353,6 +406,10 @@ class RecordingSink:
|
||||
self._check()
|
||||
self.calls.append(("button", output, code, state))
|
||||
|
||||
def axis(self, output: str, axis: int, value: float) -> None:
|
||||
self._check()
|
||||
self.calls.append(("axis", output, axis, value))
|
||||
|
||||
def frame(self, output: str) -> None:
|
||||
self._check()
|
||||
self.calls.append(("frame", output))
|
||||
|
||||
@@ -276,6 +276,47 @@ def test_container_reconcile_reports_the_difference_it_repaired(rig: Rig):
|
||||
assert rig.daemon.session(session_id)["window"] is None
|
||||
|
||||
|
||||
def test_a_window_that_lands_outside_its_desk_is_moved_onto_it(rig: Rig):
|
||||
"""The case the class-matching rule could never handle.
|
||||
|
||||
Every allowlisted application keeps its own class, so the per-session rule
|
||||
matches nothing and the window is swept to the quarantine backstop — a desk
|
||||
created and left empty. The compositor reports each client's pid, so the
|
||||
window can still be claimed: moved onto its own desk's workspace, with that
|
||||
workspace made the visible one, and read back afterwards to say so.
|
||||
"""
|
||||
|
||||
rig.compositor.auto_window = False
|
||||
session_id = start(rig.daemon, "sleeper")
|
||||
# It turns up on the main screen instead — where a quarantined window goes.
|
||||
rig.compositor.add_window(f"hh-{session_id}", 1, "HEADLESS-1", pid=WINDOW_PID)
|
||||
|
||||
rig.daemon.call("container.reconcile", id=session_id)
|
||||
|
||||
record = rig.daemon.session(session_id)
|
||||
desk = record["container"]
|
||||
assert record["workspace"] == desk["workspace"], "the read-back says where it is"
|
||||
assert record["foreground"] is True, "its desk is showing it"
|
||||
assert desk["state"] != "degraded"
|
||||
commands = rig.plan_commands()
|
||||
assert (
|
||||
f"dispatch movetoworkspacesilent {desk['workspace']},"
|
||||
f"address:{record['window']['address']}" in commands
|
||||
), commands
|
||||
assert f"dispatch workspace {desk['workspace']}" in commands, commands
|
||||
|
||||
|
||||
def test_a_window_already_on_its_desk_is_not_moved(rig: Rig):
|
||||
"""The steady state costs nothing: a move is a real change on screen."""
|
||||
|
||||
session_id = start(rig.daemon, "sleeper")
|
||||
|
||||
rig.daemon.call("container.reconcile", id=session_id)
|
||||
|
||||
assert rig.daemon.session(session_id)["workspace"] == 1000
|
||||
assert not [c for c in rig.plan_commands() if c.startswith("dispatch")]
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# the start-up scan
|
||||
# ===========================================================================
|
||||
|
||||
@@ -28,6 +28,26 @@ def compositor(short_tmpdir: Path):
|
||||
fake.stop()
|
||||
|
||||
|
||||
def test_a_disabled_host_is_unavailable_and_says_why() -> None:
|
||||
"""Turning containers off must be configuration, not a false compositor.
|
||||
|
||||
``available()`` is the whole mechanism: the manager already treats an
|
||||
unavailable host as "sessions without containers", which is exactly what
|
||||
turning them off means, so nothing else has to branch on it. It must also
|
||||
not ask a compositor this deployment never intended to talk to -- and its
|
||||
reason has to name the key, or a machine with containers disabled looks
|
||||
identical to one whose compositor is down and the operator goes hunting for a
|
||||
fault that is not there.
|
||||
"""
|
||||
|
||||
host = ContainerHost(
|
||||
None, allocator=containers.WorkspaceAllocator(1000, 4), enabled=False
|
||||
)
|
||||
|
||||
assert host.available() is False
|
||||
assert "containers_enabled" in (host.last_error or "")
|
||||
|
||||
|
||||
def make_host(fake: FakeCompositor, *, slots: int = 4) -> ContainerHost:
|
||||
return ContainerHost(
|
||||
fake.runtime_dir,
|
||||
|
||||
@@ -24,6 +24,10 @@ from hhstreamd.registry import ContainerState, Session, State, container_record
|
||||
LEFT = 0x110
|
||||
DOWN, UP = 1, 0
|
||||
|
||||
#: ``wl_pointer_axis``, mirrored from the driver for the same reason the button
|
||||
#: codes above are: these tests assert the events, so they name the wire values.
|
||||
VERTICAL, HORIZONTAL = 0, 1
|
||||
|
||||
|
||||
def make_session(session_id: str = "foot-aaaaaa", *, container: bool = True) -> Session:
|
||||
return Session(
|
||||
@@ -590,3 +594,103 @@ def test_the_sweeper_expires_a_lease_nobody_came_back_for(short_tmpdir: Path):
|
||||
if manager.driver is not None:
|
||||
manager.driver.close()
|
||||
fake.stop()
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# scrolling
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def test_scroll_drives_axis_then_frame_on_the_sessions_own_output(harness):
|
||||
harness.add()
|
||||
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
|
||||
harness.fake.sink.calls.clear()
|
||||
|
||||
reply = harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", 3))
|
||||
|
||||
assert (reply["axis"], reply["amount"]) == ("vertical", 3.0)
|
||||
assert harness.fake.sink.calls == [
|
||||
("axis", "hh-foot-aaaaaa", VERTICAL, 3.0),
|
||||
("frame", "hh-foot-aaaaaa"),
|
||||
]
|
||||
|
||||
|
||||
def test_scrolling_up_is_the_sign_and_not_a_different_verb(harness):
|
||||
"""One verb, one axis name, and the protocol's sign carries the direction."""
|
||||
|
||||
harness.add()
|
||||
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
|
||||
harness.fake.sink.calls.clear()
|
||||
|
||||
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", -3))
|
||||
|
||||
assert harness.fake.sink.calls == [
|
||||
("axis", "hh-foot-aaaaaa", VERTICAL, -3.0),
|
||||
("frame", "hh-foot-aaaaaa"),
|
||||
]
|
||||
|
||||
|
||||
def test_a_horizontal_scroll_uses_the_other_axis(harness):
|
||||
harness.add()
|
||||
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
|
||||
harness.fake.sink.calls.clear()
|
||||
|
||||
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "horizontal", 2))
|
||||
|
||||
assert harness.fake.sink.calls == [
|
||||
("axis", "hh-foot-aaaaaa", HORIZONTAL, 2.0),
|
||||
("frame", "hh-foot-aaaaaa"),
|
||||
]
|
||||
|
||||
|
||||
def test_a_scroll_restamps_the_resume_point_without_moving_it(harness):
|
||||
"""The cursor stays put -- and the record must not pretend otherwise."""
|
||||
|
||||
session = harness.add()
|
||||
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
|
||||
before = dict(session.pointer["bookmark"])
|
||||
|
||||
harness.clock.advance(7.0)
|
||||
reply = harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", 3))
|
||||
|
||||
assert (reply["bookmark"]["x"], reply["bookmark"]["y"]) == (before["x"], before["y"])
|
||||
assert reply["bookmark"]["output"] == before["output"]
|
||||
assert reply["bookmark"]["at"] != before["at"], "the session acted, so the stamp moved"
|
||||
assert harness.manager.pointer.state()["holder"] == "foot-aaaaaa"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("bad", [0, 0.0, 101, -101, "three", True, None])
|
||||
def test_a_scroll_amount_off_the_wire_is_bounded(harness, bad):
|
||||
harness.add()
|
||||
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
|
||||
|
||||
with pytest.raises(ManagerError) as exc:
|
||||
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", bad))
|
||||
|
||||
assert exc.value.error == "invalid_argument"
|
||||
|
||||
|
||||
def test_an_unknown_axis_is_refused_by_the_driver_not_invented(harness):
|
||||
harness.add()
|
||||
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
|
||||
harness.fake.sink.calls.clear()
|
||||
|
||||
with pytest.raises(ManagerError) as exc:
|
||||
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "diagonal", 3))
|
||||
|
||||
assert exc.value.error == "driver_refused"
|
||||
assert harness.fake.sink.calls == [], "a refused scroll must emit nothing"
|
||||
|
||||
|
||||
def test_a_scroll_without_the_lease_is_refused(harness):
|
||||
session = harness.add()
|
||||
harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))
|
||||
harness.fake.sink.calls.clear()
|
||||
|
||||
with pytest.raises(ManagerError):
|
||||
harness.run(
|
||||
harness.manager.pointer_scroll("foot-aaaaaa", "not-this-lease", "vertical", 3)
|
||||
)
|
||||
|
||||
assert harness.fake.sink.calls == []
|
||||
assert session.pointer.get("bookmark") is not None, "a refused scroll changes nothing"
|
||||
@@ -0,0 +1,78 @@
|
||||
"""The config file's non-allowlist half.
|
||||
|
||||
These keys are rendered by the NixOS module and, until this existed, read by
|
||||
nothing: a deployment could turn containers off or move a lease deadline and be
|
||||
silently ignored, while the defaults happened to make it look honoured. The
|
||||
values here are therefore the ones the module actually writes -- if the module's
|
||||
shape changes, these tests are where that shows up.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
import tomllib
|
||||
|
||||
import pytest
|
||||
|
||||
from hhstreamd.policy import PolicyError, load_settings, settings_from_dict
|
||||
|
||||
#: Exactly what `nix/module.nix` renders today, through
|
||||
#: `services.hyprland-headless-stream`, with containers turned off.
|
||||
MODULE_SHAPE = """
|
||||
[defaults]
|
||||
max_sessions = 4
|
||||
idle_timeout_s = 10800
|
||||
max_containers = 2
|
||||
|
||||
[compositor]
|
||||
runtime_dir = "/run/hypr-stream"
|
||||
containers_enabled = false
|
||||
workspace_base = 1000
|
||||
container_mode = "1280x720"
|
||||
|
||||
[pointer]
|
||||
enabled = true
|
||||
lease_ttl_s = 30
|
||||
lease_max_s = 300
|
||||
|
||||
[apps.chromium]
|
||||
exec = "/nix/store/x/bin/chromium"
|
||||
args_allow = ["--ozone-platform=wayland"]
|
||||
"""
|
||||
|
||||
|
||||
def test_the_module_shape_is_read() -> None:
|
||||
settings = settings_from_dict(tomllib.loads(MODULE_SHAPE))
|
||||
|
||||
assert settings.containers_enabled is False
|
||||
# max_containers lives in [defaults] while the rest live in [compositor];
|
||||
# that split is the module's, and reading only one of them is how a budget
|
||||
# silently stops applying.
|
||||
assert settings.container_slots == 2
|
||||
assert settings.container_base == 1000
|
||||
assert settings.container_mode == (1280, 720)
|
||||
assert (settings.pointer_ttl_s, settings.pointer_max_s) == (30.0, 300.0)
|
||||
|
||||
|
||||
def test_containers_default_to_on_when_the_key_is_absent() -> None:
|
||||
"""A config written before this setting existed keeps working."""
|
||||
|
||||
assert settings_from_dict({"apps": {}}).containers_enabled is True
|
||||
|
||||
|
||||
def test_a_bad_mode_is_refused_by_name() -> None:
|
||||
"""A typo must be loud: a container at the wrong size looks like an app bug."""
|
||||
|
||||
with pytest.raises(PolicyError) as exc:
|
||||
settings_from_dict({"compositor": {"container_mode": "wide"}})
|
||||
|
||||
assert "container_mode" in str(exc.value)
|
||||
|
||||
|
||||
def test_an_absent_file_is_the_defaults(tmp_path: Path) -> None:
|
||||
"""Missing config behaves conservatively rather than refusing to start."""
|
||||
|
||||
settings = load_settings(tmp_path / "absent.toml")
|
||||
|
||||
assert settings.containers_enabled is True
|
||||
assert settings.container_mode == (1280, 720)
|
||||
+38
-13
@@ -75,12 +75,18 @@ def test_a_failure_after_a_good_frame_keeps_the_known_size():
|
||||
|
||||
|
||||
def test_env_is_overlaid_on_our_own_environment():
|
||||
argv = [sys.executable, "-c",
|
||||
"import os,sys;sys.stdout.write(os.environ['WAYLAND_DISPLAY']+':'+"
|
||||
"('PATH' in os.environ and 'haspath' or 'nopath'))"]
|
||||
argv = [
|
||||
sys.executable,
|
||||
"-c",
|
||||
"import os,sys;sys.stdout.write(os.environ['WAYLAND_DISPLAY']+':'+"
|
||||
+ "('PATH' in os.environ and 'haspath' or 'nopath'))",
|
||||
]
|
||||
before = os.environ.get("WAYLAND_DISPLAY")
|
||||
capture = CommandCapture(argv, env={"WAYLAND_DISPLAY": "wayland-9"})
|
||||
assert capture.grab() == b"wayland-9:haspath"
|
||||
assert "WAYLAND_DISPLAY" not in os.environ, "our own environment was mutated"
|
||||
assert os.environ.get("WAYLAND_DISPLAY") == before, (
|
||||
"our own environment was mutated"
|
||||
)
|
||||
|
||||
|
||||
def test_empty_argv_and_bad_timeout_are_rejected_up_front():
|
||||
@@ -91,8 +97,10 @@ def test_empty_argv_and_bad_timeout_are_rejected_up_front():
|
||||
|
||||
|
||||
def test_the_helpers_stdin_is_closed_so_it_cannot_steal_ours():
|
||||
code = ("import sys;"
|
||||
"sys.stdout.buffer.write(b'EMPTY' if not sys.stdin.read() else b'DATA')")
|
||||
code = (
|
||||
"import sys;"
|
||||
"sys.stdout.buffer.write(b'EMPTY' if not sys.stdin.read() else b'DATA')"
|
||||
)
|
||||
assert CommandCapture([sys.executable, "-c", code]).grab() == b"EMPTY"
|
||||
|
||||
|
||||
@@ -102,15 +110,32 @@ def test_image_size_reads_png_headers(width, height):
|
||||
|
||||
|
||||
def test_image_size_reads_a_jpeg_sof_header():
|
||||
jpeg = (b"\xff\xd8"
|
||||
+ b"\xff\xe0" + (16).to_bytes(2, "big") + b"JFIF\x00" + b"\x00" * 9
|
||||
+ b"\xff\xc0" + (17).to_bytes(2, "big") + b"\x08"
|
||||
+ (720).to_bytes(2, "big") + (1280).to_bytes(2, "big")
|
||||
+ b"\x03" + b"\x00" * 9)
|
||||
jpeg = (
|
||||
b"\xff\xd8"
|
||||
+ b"\xff\xe0"
|
||||
+ (16).to_bytes(2, "big")
|
||||
+ b"JFIF\x00"
|
||||
+ b"\x00" * 9
|
||||
+ b"\xff\xc0"
|
||||
+ (17).to_bytes(2, "big")
|
||||
+ b"\x08"
|
||||
+ (720).to_bytes(2, "big")
|
||||
+ (1280).to_bytes(2, "big")
|
||||
+ b"\x03"
|
||||
+ b"\x00" * 9
|
||||
)
|
||||
assert image_size(jpeg) == (1280, 720)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("data", [b"", b"not an image", b"\x89PNG\r\n\x1a\n",
|
||||
b"\xff\xd8", b"\xff\xd8\xff\xc0\x00\x11"])
|
||||
@pytest.mark.parametrize(
|
||||
"data",
|
||||
[
|
||||
b"",
|
||||
b"not an image",
|
||||
b"\x89PNG\r\n\x1a\n",
|
||||
b"\xff\xd8",
|
||||
b"\xff\xd8\xff\xc0\x00\x11",
|
||||
],
|
||||
)
|
||||
def test_image_size_returns_none_when_it_cannot_tell(data):
|
||||
assert image_size(data) is None
|
||||
@@ -56,7 +56,7 @@ def test_server_defaults_match_the_contract():
|
||||
args = server.build_parser().parse_args([])
|
||||
assert args.socket == "/run/hypr-stream/stream.sock"
|
||||
assert (args.fps, args.format, args.capture_command) == (30, "png", None)
|
||||
assert server.DEFAULT_CAPTURE_COMMAND == ["grim", "-t", "png", "-"]
|
||||
assert server.DEFAULT_CAPTURE_COMMAND == ["grim", "-c", "-t", "png", "-"]
|
||||
|
||||
|
||||
def test_capture_command_is_one_argv_token_per_flag():
|
||||
|
||||
Reference in new issue
Block a user