mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-04 04:52:54 -05:00
Keep a native pointer connected while the compositor captures it
This commit is contained in:
1 parent
90187263ea
commit
f7a0d9787b
4 files changed
+42
-3
No files matched your search
@@ -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)
|
||||
@@ -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
|
||||
@@ -0,0 +1,34 @@
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wayland-client.h>
|
||||
#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;
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user