From 90187263ea1f34bedf78d10cf0cbf793234123d7 Mon Sep 17 00:00:00 2001 From: Codex Date: Mon, 30 Nov 2026 16:45:10 +0100 Subject: [PATCH] Inspect the released Pen cursor on a native Wayland canvas --- .github/qa/wayland-pen.py | 56 +++++++++++++++++++++++++++++++ .github/qa/wayland-pen.sh | 16 +++++++++ .github/workflows/wayland-pen.yml | 31 +++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 .github/qa/wayland-pen.py create mode 100644 .github/qa/wayland-pen.sh create mode 100644 .github/workflows/wayland-pen.yml diff --git a/.github/qa/wayland-pen.py b/.github/qa/wayland-pen.py new file mode 100644 index 0000000000..650b10cb1a --- /dev/null +++ b/.github/qa/wayland-pen.py @@ -0,0 +1,56 @@ +import json +import os +from pathlib import Path +import socket +import subprocess +import time +from PIL import Image, ImageChops + +directory = Path("/tmp/pen-qa") +for attempt in range(120): + try: + connection = socket.create_connection(("127.0.0.1", 48572), timeout=2) + break + except OSError: + time.sleep(0.5) +else: + raise RuntimeError("VectorCraft control endpoint did not start") + +with connection, connection.makefile("rwb") as stream: + connection.settimeout(30) + def call(method, **params): + stream.write((json.dumps(dict(id=1, method=method, params=params))+"\n").encode()) + stream.flush() + response = json.loads(stream.readline()) + assert response["ok"], response + return response["result"] + + call("auth", token=os.environ["VECTORCRAFT_CONTROL_TOKEN"]) + call("engine.execute", command="file.new", params=dict(width=500, height=400)) + call("engine.execute", command="tool.select", params=dict(tool="pen")) + time.sleep(1) + view = call("ui.inspect") + tree = json.loads(subprocess.check_output(["swaymsg","-rt","get_tree"])) + def windows(node): + if node.get("app_id"): + yield node + for child in node.get("nodes",[]) + node.get("floating_nodes",[]): + yield from windows(child) + window, = [w for w in windows(tree) if "vectorcraft" in w["app_id"].lower()] + assert window["focused"] and window["shell"] == "xdg_shell", window + a, b, width, height = view["canvasRect"] + extent = window["rect"] + x = round(extent["x"] + (a + width/2)*extent["width"]/view["window"][0]) + y = round(extent["y"] + (b + height/2)*extent["height"]/view["window"][1]) + subprocess.run(["swaymsg","seat","seat0","cursor","set",str(x),str(y)],check=True) + time.sleep(1) + for filename, extra in [("without",[]),("with",["-c"])]: + subprocess.run(["grim",*extra,str(directory/(filename+".png"))],check=True) + base, shown = [Image.open(directory/(n+".png")).convert("RGB") for n in ("without","with")] + area = (x-70,y-70,x+70,y+70) + delta = ImageChops.difference(shown.crop(area),base.crop(area)) + bounds = delta.getbbox() + assert bounds, ("composited cursor missing", x, y, view["canvasRect"]) + pointer = shown.crop(area).crop(bounds) + pointer.resize((pointer.width*8,pointer.height*8),Image.Resampling.NEAREST).save(directory/"nib.png") + print("Composited cursor size:",pointer.size,"at",x,y, flush=True) diff --git a/.github/qa/wayland-pen.sh b/.github/qa/wayland-pen.sh new file mode 100644 index 0000000000..5907dfdcaa --- /dev/null +++ b/.github/qa/wayland-pen.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail +mkdir -p /tmp/pen-qa +export XDG_RUNTIME_DIR="$(mktemp -d)" +export WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 WLR_RENDERER=pixman LIBGL_ALWAYS_SOFTWARE=1 +export XDG_CURRENT_DESKTOP=sway XDG_SESSION_TYPE=wayland +echo 'output * mode 1600x1000' > "$RUNNER_TEMP/sway.conf" +sway -c "$RUNNER_TEMP/sway.conf" >/tmp/pen-qa/sway.log 2>&1 & +for i in $(seq 100); do compgen -G "$XDG_RUNTIME_DIR/sway-ipc*.sock" >/dev/null && break; sleep .2; done +export SWAYSOCK="$(ls "$XDG_RUNTIME_DIR"/sway-ipc*.sock | head -1)" +export WAYLAND_DISPLAY="$(basename "$(find "$XDG_RUNTIME_DIR" -type s -name 'wayland-*' | head -1)")" +dbus-update-activation-environment WAYLAND_DISPLAY XDG_RUNTIME_DIR XDG_CURRENT_DESKTOP +export VECTORCRAFT_CONTROL_TOKEN="$(openssl rand -hex 32)" +vectorcraft --control 48572 >/tmp/pen-qa/app.log 2>&1 & +wlrctl pointer move 1 1 +/usr/bin/python3 .github/qa/wayland-pen.py diff --git a/.github/workflows/wayland-pen.yml b/.github/workflows/wayland-pen.yml new file mode 100644 index 0000000000..96be1d0248 --- /dev/null +++ b/.github/workflows/wayland-pen.yml @@ -0,0 +1,31 @@ +name: Wayland Pen cursor GUI +on: + push: + branches: [qa/wayland-pen-0251] +permissions: + contents: read + actions: read +jobs: + cursor: + runs-on: ubuntu-24.04 + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Install compositor and VectorCraft + env: + GH_TOKEN: ${{ github.token }} + VERSION: 0.25.0 + run: | + sudo apt-get update -qq + sudo apt-get install -y grim sway python3-pil wlrctl + gh release download "v$VERSION" -p "*-linux-x86_64.deb" -D "$RUNNER_TEMP/bundle" + sudo apt-get install -y "$RUNNER_TEMP"/bundle/*.deb + - name: Capture Pen pointer on the canvas + run: dbus-run-session -- bash .github/qa/wayland-pen.sh + - if: always() + uses: actions/upload-artifact@v4 + with: + name: wayland-pen-captures + path: /tmp/pen-qa/*