From 5443d3f8281c882d73a5f42ddb242c23c3533574 Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Tue, 18 May 2021 08:52:22 +0900 Subject: [PATCH] seat: add wlr_virtual_pointer_manager_v1 together with the previous patch, wayvnc can now be used with cage: $ cage something # figure out which wayland socket cage used $ WAYLAND_DISPLAY=wayland-0 wayvnc Note this does not appear to work with headless backend, e.g. starting cage with WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 cage something does start and wayvnc connects/displays output, but there are tons of errors and input does not work --- seat.c | 17 +++++++++++++++++ seat.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/seat.c b/seat.c index 5906828..59f8c16 100644 --- a/seat.c +++ b/seat.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #if CAGE_HAS_XWAYLAND @@ -207,6 +208,18 @@ handle_new_pointer(struct cg_seat *seat, struct wlr_input_device *device) map_input_device_to_output(seat, device); } +static void +handle_virtual_pointer(struct wl_listener *listener, void *data) +{ + struct cg_seat *seat = wl_container_of(listener, seat, new_virtual_pointer); + struct wlr_virtual_pointer_v1_new_pointer_event *event = data; + struct wlr_virtual_pointer_v1 *pointer = event->new_pointer; + struct wlr_input_device *device = &pointer->input_device; + + /* event->suggested_seat should be checked if we handle multiple seats */ + handle_new_pointer(seat, device); +} + static void handle_modifier_event(struct wlr_input_device *device, struct cg_seat *seat) { @@ -824,6 +837,10 @@ seat_create(struct cg_server *server, struct wlr_backend *backend) wl_signal_add(&seat->virtual_keyboard->events.new_virtual_keyboard, &seat->new_virtual_keyboard); seat->new_virtual_keyboard.notify = handle_virtual_keyboard; + seat->virtual_pointer = wlr_virtual_pointer_manager_v1_create(server->wl_display); + wl_signal_add(&seat->virtual_pointer->events.new_virtual_pointer, &seat->new_virtual_pointer); + seat->new_virtual_pointer.notify = handle_virtual_pointer; + return seat; } diff --git a/seat.h b/seat.h index 36573d4..fefc5c9 100644 --- a/seat.h +++ b/seat.h @@ -27,7 +27,9 @@ struct cg_seat { // These belong to higher level if multiple seats are allowed struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; + struct wlr_virtual_pointer_manager_v1 *virtual_pointer; struct wl_listener new_virtual_keyboard; + struct wl_listener new_virtual_pointer; struct wlr_cursor *cursor; struct wlr_xcursor_manager *xcursor_manager;