Restructure input initialisation
parent
b0077c93fe
commit
7eaece7c0a
|
@ -22,7 +22,6 @@
|
|||
|
||||
struct pointer {
|
||||
struct nvnc* vnc;
|
||||
struct zwlr_virtual_pointer_manager_v1* manager;
|
||||
struct zwlr_virtual_pointer_v1* pointer;
|
||||
|
||||
enum nvnc_button_mask current_mask;
|
||||
|
@ -34,7 +33,7 @@ struct pointer {
|
|||
uint32_t height;
|
||||
};
|
||||
|
||||
int pointer_init(struct pointer* self, struct wl_seat* seat);
|
||||
int pointer_init(struct pointer* self);
|
||||
void pointer_destroy(struct pointer* self);
|
||||
|
||||
void pointer_set(struct pointer* self, uint32_t x, uint32_t y,
|
||||
|
|
70
src/main.c
70
src/main.c
|
@ -66,6 +66,7 @@ struct wayvnc {
|
|||
|
||||
struct zxdg_output_manager_v1* xdg_output_manager;
|
||||
struct zwp_virtual_keyboard_manager_v1* keyboard_manager;
|
||||
struct zwlr_virtual_pointer_manager_v1* pointer_manager;
|
||||
|
||||
struct renderer renderer;
|
||||
const struct output* selected_output;
|
||||
|
@ -158,7 +159,7 @@ static void registry_add(void* data, struct wl_registry* registry,
|
|||
}
|
||||
|
||||
if (strcmp(interface, zwlr_virtual_pointer_manager_v1_interface.name) == 0) {
|
||||
self->pointer_backend.manager =
|
||||
self->pointer_manager =
|
||||
wl_registry_bind(registry, id,
|
||||
&zwlr_virtual_pointer_manager_v1_interface,
|
||||
1);
|
||||
|
@ -229,7 +230,7 @@ void wayvnc_destroy(struct wayvnc* self)
|
|||
zwp_virtual_keyboard_manager_v1_destroy(self->keyboard_manager);
|
||||
keyboard_destroy(&self->keyboard_backend);
|
||||
|
||||
zwlr_virtual_pointer_manager_v1_destroy(self->pointer_backend.manager);
|
||||
zwlr_virtual_pointer_manager_v1_destroy(self->pointer_manager);
|
||||
pointer_destroy(&self->pointer_backend);
|
||||
|
||||
if (self->screencopy_backend.manager)
|
||||
|
@ -241,6 +242,18 @@ void wayvnc_destroy(struct wayvnc* self)
|
|||
wl_display_disconnect(self->display);
|
||||
}
|
||||
|
||||
static void init_xdg_outputs(struct wayvnc* self)
|
||||
{
|
||||
struct output* output;
|
||||
wl_list_for_each(output, &self->outputs, link) {
|
||||
struct zxdg_output_v1* xdg_output =
|
||||
zxdg_output_manager_v1_get_xdg_output(
|
||||
self->xdg_output_manager, output->wl_output);
|
||||
|
||||
output_set_xdg_output(output, xdg_output);
|
||||
}
|
||||
}
|
||||
|
||||
static int init_wayland(struct wayvnc* self)
|
||||
{
|
||||
static const struct wl_registry_listener registry_listener = {
|
||||
|
@ -264,6 +277,21 @@ static int init_wayland(struct wayvnc* self)
|
|||
wl_display_dispatch(self->display);
|
||||
wl_display_roundtrip(self->display);
|
||||
|
||||
init_xdg_outputs(self);
|
||||
|
||||
if (!self->pointer_manager) {
|
||||
log_error("Virtual Pointer protocol not supported by compositor.\n");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if (!self->keyboard_manager) {
|
||||
log_error("Virtual Keyboard protocol not supported by compositor.\n");
|
||||
goto failure;
|
||||
}
|
||||
|
||||
wl_display_dispatch(self->display);
|
||||
wl_display_roundtrip(self->display);
|
||||
|
||||
if (!self->dmabuf_backend.manager && !self->screencopy_backend.manager) {
|
||||
log_error("Compositor supports neither screencopy nor export-dmabuf! Exiting.\n");
|
||||
goto failure;
|
||||
|
@ -275,18 +303,6 @@ static int init_wayland(struct wayvnc* self)
|
|||
self->screencopy_backend.frame_capture.on_done = on_capture_done;
|
||||
self->screencopy_backend.frame_capture.userdata = self;
|
||||
|
||||
struct output* output;
|
||||
wl_list_for_each(output, &self->outputs, link) {
|
||||
struct zxdg_output_v1* xdg_output =
|
||||
zxdg_output_manager_v1_get_xdg_output(
|
||||
self->xdg_output_manager, output->wl_output);
|
||||
|
||||
output_set_xdg_output(output, xdg_output);
|
||||
}
|
||||
|
||||
wl_display_dispatch(self->display);
|
||||
wl_display_roundtrip(self->display);
|
||||
|
||||
return 0;
|
||||
|
||||
failure:
|
||||
|
@ -405,7 +421,7 @@ int init_nvnc(struct wayvnc* self, const char* addr, uint16_t port)
|
|||
self->selected_output->height,
|
||||
format);
|
||||
|
||||
if (self->pointer_backend.manager)
|
||||
if (self->pointer_manager)
|
||||
nvnc_set_pointer_fn(self->nvnc, on_pointer_event);
|
||||
|
||||
if (self->keyboard_backend.virtual_keyboard)
|
||||
|
@ -676,27 +692,21 @@ int main(int argc, char* argv[])
|
|||
self.dmabuf_backend.fc.wl_output = out->wl_output;
|
||||
self.screencopy_backend.frame_capture.wl_output = out->wl_output;
|
||||
|
||||
if (self.pointer_backend.manager) {
|
||||
self.pointer_backend.width = out->width;
|
||||
self.pointer_backend.height = out->height;
|
||||
}
|
||||
|
||||
assert(self.keyboard_manager);
|
||||
|
||||
self.keyboard_backend.virtual_keyboard =
|
||||
zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(
|
||||
self.keyboard_manager, self.selected_seat->wl_seat);
|
||||
|
||||
keyboard_init(&self.keyboard_backend, self.kb_layout);
|
||||
|
||||
if (self.pointer_backend.manager) {
|
||||
self.pointer_backend.vnc = self.nvnc;
|
||||
pointer_init(&self.pointer_backend, self.selected_seat->wl_seat);
|
||||
} else {
|
||||
log_error("Compositor does not support %s.\n",
|
||||
zwlr_virtual_pointer_manager_v1_interface.name);
|
||||
goto failure;
|
||||
}
|
||||
self.pointer_backend.vnc = self.nvnc;
|
||||
self.pointer_backend.width = out->width;
|
||||
self.pointer_backend.height = out->height;
|
||||
|
||||
self.pointer_backend.pointer =
|
||||
zwlr_virtual_pointer_manager_v1_create_virtual_pointer(
|
||||
self.pointer_manager, self.selected_seat->wl_seat);
|
||||
|
||||
pointer_init(&self.pointer_backend);
|
||||
|
||||
if (renderer_init(&self.renderer, self.selected_output->width,
|
||||
self.selected_output->height) < 0) {
|
||||
|
|
|
@ -23,11 +23,8 @@
|
|||
#include "wlr-virtual-pointer-unstable-v1.h"
|
||||
#include "time-util.h"
|
||||
|
||||
int pointer_init(struct pointer* self, struct wl_seat* seat)
|
||||
int pointer_init(struct pointer* self)
|
||||
{
|
||||
self->pointer =
|
||||
zwlr_virtual_pointer_manager_v1_create_virtual_pointer(self->manager, seat);
|
||||
|
||||
zwlr_virtual_pointer_v1_axis_source(self->pointer,
|
||||
WL_POINTER_AXIS_SOURCE_WHEEL);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue