diff options
author | 2019-10-20 16:06:35 +0200 | |
---|---|---|
committer | 2019-12-31 16:04:50 +0100 | |
commit | f501a60c14375132fae64d0a04d1a5523811ac5d (patch) | |
tree | 81f7fcfb43c64c3d5c3ab4cd027226886ab4ac80 /sway | |
parent | Fix sway_log using non initialised output_config pointer (diff) | |
download | sway-f501a60c14375132fae64d0a04d1a5523811ac5d.tar.gz sway-f501a60c14375132fae64d0a04d1a5523811ac5d.tar.zst sway-f501a60c14375132fae64d0a04d1a5523811ac5d.zip |
Add virtual pointer protocol
Diffstat (limited to 'sway')
-rw-r--r-- | sway/input/input-manager.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 3d7f9e8b..a7b66b86 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <wlr/backend/libinput.h> | 6 | #include <wlr/backend/libinput.h> |
7 | #include <wlr/types/wlr_input_inhibitor.h> | 7 | #include <wlr/types/wlr_input_inhibitor.h> |
8 | #include <wlr/types/wlr_virtual_keyboard_v1.h> | 8 | #include <wlr/types/wlr_virtual_keyboard_v1.h> |
9 | #include <wlr/types/wlr_virtual_pointer_v1.h> | ||
9 | #include "sway/config.h" | 10 | #include "sway/config.h" |
10 | #include "sway/input/input-manager.h" | 11 | #include "sway/input/input-manager.h" |
11 | #include "sway/input/libinput.h" | 12 | #include "sway/input/libinput.h" |
@@ -310,6 +311,36 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) { | |||
310 | seat_add_device(seat, input_device); | 311 | seat_add_device(seat, input_device); |
311 | } | 312 | } |
312 | 313 | ||
314 | void handle_virtual_pointer(struct wl_listener *listener, void *data) { | ||
315 | struct sway_input_manager *input_manager = | ||
316 | wl_container_of(listener, input_manager, virtual_pointer_new); | ||
317 | struct wlr_virtual_pointer_v1_new_pointer_event *event = data; | ||
318 | struct wlr_virtual_pointer_v1 *pointer = event->new_pointer; | ||
319 | struct wlr_input_device *device = &pointer->input_device; | ||
320 | |||
321 | /* TODO: Consider suggested seat when creating the pointer */ | ||
322 | struct sway_seat *seat = input_manager_get_default_seat(); | ||
323 | |||
324 | struct sway_input_device *input_device = | ||
325 | calloc(1, sizeof(struct sway_input_device)); | ||
326 | if (!sway_assert(input_device, "could not allocate input device")) { | ||
327 | return; | ||
328 | } | ||
329 | device->data = input_device; | ||
330 | |||
331 | input_device->wlr_device = device; | ||
332 | input_device->identifier = input_device_get_identifier(device); | ||
333 | wl_list_insert(&input_manager->devices, &input_device->link); | ||
334 | |||
335 | sway_log(SWAY_DEBUG, "adding virtual pointer: '%s'", | ||
336 | input_device->identifier); | ||
337 | |||
338 | wl_signal_add(&device->events.destroy, &input_device->device_destroy); | ||
339 | input_device->device_destroy.notify = handle_device_destroy; | ||
340 | |||
341 | seat_add_device(seat, input_device); | ||
342 | } | ||
343 | |||
313 | struct sway_input_manager *input_manager_create(struct sway_server *server) { | 344 | struct sway_input_manager *input_manager_create(struct sway_server *server) { |
314 | struct sway_input_manager *input = | 345 | struct sway_input_manager *input = |
315 | calloc(1, sizeof(struct sway_input_manager)); | 346 | calloc(1, sizeof(struct sway_input_manager)); |
@@ -329,6 +360,13 @@ struct sway_input_manager *input_manager_create(struct sway_server *server) { | |||
329 | &input->virtual_keyboard_new); | 360 | &input->virtual_keyboard_new); |
330 | input->virtual_keyboard_new.notify = handle_virtual_keyboard; | 361 | input->virtual_keyboard_new.notify = handle_virtual_keyboard; |
331 | 362 | ||
363 | input->virtual_pointer = wlr_virtual_pointer_manager_v1_create( | ||
364 | server->wl_display | ||
365 | ); | ||
366 | wl_signal_add(&input->virtual_pointer->events.new_virtual_pointer, | ||
367 | &input->virtual_pointer_new); | ||
368 | input->virtual_pointer_new.notify = handle_virtual_pointer; | ||
369 | |||
332 | input->inhibit = wlr_input_inhibit_manager_create(server->wl_display); | 370 | input->inhibit = wlr_input_inhibit_manager_create(server->wl_display); |
333 | input->inhibit_activate.notify = handle_inhibit_activate; | 371 | input->inhibit_activate.notify = handle_inhibit_activate; |
334 | wl_signal_add(&input->inhibit->events.activate, | 372 | wl_signal_add(&input->inhibit->events.activate, |