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
This commit is contained in:
Dominique Martinet 2021-05-18 08:52:22 +09:00 committed by Dominique Martinet
parent b60a686d30
commit 5443d3f828
2 changed files with 19 additions and 0 deletions

17
seat.c
View file

@ -24,6 +24,7 @@
#include <wlr/types/wlr_surface.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
#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;
}

2
seat.h
View file

@ -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;