diff --git a/.github/qa/wayland-pen.py b/.github/qa/wayland-pen.py index 650b10cb1a..5e16b24c98 100644 --- a/.github/qa/wayland-pen.py +++ b/.github/qa/wayland-pen.py @@ -42,7 +42,7 @@ with connection, connection.makefile("rwb") as stream: 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) + pointer_process = subprocess.Popen([os.environ["RUNNER_TEMP"]+"/test-pointer",str(x),str(y),"1600","1000"], stdin=subprocess.PIPE) time.sleep(1) for filename, extra in [("without",[]),("with",["-c"])]: subprocess.run(["grim",*extra,str(directory/(filename+".png"))],check=True) @@ -53,4 +53,6 @@ with connection, connection.makefile("rwb") as stream: 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") + pointer_process.stdin.close() + assert pointer_process.wait(timeout=5) == 0 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 index 5907dfdcaa..455e288352 100644 --- a/.github/qa/wayland-pen.sh +++ b/.github/qa/wayland-pen.sh @@ -12,5 +12,8 @@ export WAYLAND_DISPLAY="$(basename "$(find "$XDG_RUNTIME_DIR" -type s -name 'way 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 +curl -fsSL https://raw.githubusercontent.com/swaywm/wlr-protocols/master/unstable/wlr-virtual-pointer-unstable-v1.xml > "$RUNNER_TEMP/virtual-pointer.xml" +wayland-scanner client-header "$RUNNER_TEMP/virtual-pointer.xml" "$RUNNER_TEMP/pointer.h" +wayland-scanner private-code "$RUNNER_TEMP/virtual-pointer.xml" "$RUNNER_TEMP/pointer.c" +cc -I"$RUNNER_TEMP" .github/qa/wayland-pointer.c "$RUNNER_TEMP/pointer.c" -lwayland-client -o "$RUNNER_TEMP/test-pointer" /usr/bin/python3 .github/qa/wayland-pen.py diff --git a/.github/qa/wayland-pointer.c b/.github/qa/wayland-pointer.c new file mode 100644 index 0000000000..51ffd92cfd --- /dev/null +++ b/.github/qa/wayland-pointer.c @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include +#include "pointer.h" + +static struct zwlr_virtual_pointer_manager_v1 *manager; +static struct wl_seat *seat; +static void global(void *data, struct wl_registry *registry, uint32_t id, const char *name, uint32_t version) { + if (!strcmp(name, zwlr_virtual_pointer_manager_v1_interface.name)) + manager = wl_registry_bind(registry, id, &zwlr_virtual_pointer_manager_v1_interface, 1); + if (!strcmp(name, wl_seat_interface.name)) + seat = wl_registry_bind(registry, id, &wl_seat_interface, 1); +} +static void removed(void *data, struct wl_registry *registry, uint32_t id) {} +int main(int argc, char **argv) { + assert(argc == 5); + struct wl_display *display = wl_display_connect(NULL); + assert(display); + struct wl_registry *registry = wl_display_get_registry(display); + const struct wl_registry_listener listener = {global, removed}; + wl_registry_add_listener(registry, &listener, NULL); + wl_display_roundtrip(display); + assert(manager && seat); + struct zwlr_virtual_pointer_v1 *pointer = zwlr_virtual_pointer_manager_v1_create_virtual_pointer(manager, seat); + zwlr_virtual_pointer_v1_motion_absolute(pointer, 1, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); + zwlr_virtual_pointer_v1_frame(pointer); + wl_display_roundtrip(display); + getchar(); + wl_display_disconnect(display); + return 0; +} diff --git a/.github/workflows/wayland-pen.yml b/.github/workflows/wayland-pen.yml index 96be1d0248..18665ac1ad 100644 --- a/.github/workflows/wayland-pen.yml +++ b/.github/workflows/wayland-pen.yml @@ -19,7 +19,7 @@ jobs: VERSION: 0.25.0 run: | sudo apt-get update -qq - sudo apt-get install -y grim sway python3-pil wlrctl + sudo apt-get install -y grim sway python3-pil libwayland-dev libwayland-bin 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