diff options
-rw-r--r-- | include/sway/input/input-manager.h | 3 | ||||
-rw-r--r-- | include/sway/input/seat.h | 1 | ||||
-rw-r--r-- | sway/input/input-manager.c | 25 | ||||
-rw-r--r-- | sway/input/seat.c | 11 | ||||
-rw-r--r-- | sway/server.c | 3 |
5 files changed, 41 insertions, 2 deletions
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index 145edd4b..45c75199 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> | 4 | #include <wlr/types/wlr_keyboard_shortcuts_inhibit_v1.h> |
5 | #include <wlr/types/wlr_virtual_keyboard_v1.h> | 5 | #include <wlr/types/wlr_virtual_keyboard_v1.h> |
6 | #include <wlr/types/wlr_virtual_pointer_v1.h> | 6 | #include <wlr/types/wlr_virtual_pointer_v1.h> |
7 | #include <wlr/types/wlr_transient_seat_v1.h> | ||
7 | #include "sway/server.h" | 8 | #include "sway/server.h" |
8 | #include "sway/config.h" | 9 | #include "sway/config.h" |
9 | #include "list.h" | 10 | #include "list.h" |
@@ -24,6 +25,7 @@ struct sway_input_manager { | |||
24 | struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; | 25 | struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard; |
25 | struct wlr_virtual_pointer_manager_v1 *virtual_pointer; | 26 | struct wlr_virtual_pointer_manager_v1 *virtual_pointer; |
26 | struct wlr_pointer_gestures_v1 *pointer_gestures; | 27 | struct wlr_pointer_gestures_v1 *pointer_gestures; |
28 | struct wlr_transient_seat_manager_v1 *transient_seat_manager; | ||
27 | 29 | ||
28 | struct wl_listener new_input; | 30 | struct wl_listener new_input; |
29 | struct wl_listener inhibit_activate; | 31 | struct wl_listener inhibit_activate; |
@@ -31,6 +33,7 @@ struct sway_input_manager { | |||
31 | struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor; | 33 | struct wl_listener keyboard_shortcuts_inhibit_new_inhibitor; |
32 | struct wl_listener virtual_keyboard_new; | 34 | struct wl_listener virtual_keyboard_new; |
33 | struct wl_listener virtual_pointer_new; | 35 | struct wl_listener virtual_pointer_new; |
36 | struct wl_listener transient_seat_create; | ||
34 | }; | 37 | }; |
35 | 38 | ||
36 | struct sway_input_manager *input_manager_create(struct sway_server *server); | 39 | struct sway_input_manager *input_manager_create(struct sway_server *server); |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 475753d8..428f9679 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -124,6 +124,7 @@ struct sway_seat { | |||
124 | struct wl_listener start_drag; | 124 | struct wl_listener start_drag; |
125 | struct wl_listener request_set_selection; | 125 | struct wl_listener request_set_selection; |
126 | struct wl_listener request_set_primary_selection; | 126 | struct wl_listener request_set_primary_selection; |
127 | struct wl_listener destroy; | ||
127 | 128 | ||
128 | struct wl_list devices; // sway_seat_device::link | 129 | struct wl_list devices; // sway_seat_device::link |
129 | struct wl_list keyboard_groups; // sway_keyboard_group::link | 130 | struct wl_list keyboard_groups; // sway_keyboard_group::link |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index 089e1e71..248ca34e 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -2,7 +2,9 @@ | |||
2 | #include <stdio.h> | 2 | #include <stdio.h> |
3 | #include <string.h> | 3 | #include <string.h> |
4 | #include <math.h> | 4 | #include <math.h> |
5 | #include <assert.h> | ||
5 | #include <wlr/config.h> | 6 | #include <wlr/config.h> |
7 | #include <wlr/backend/libinput.h> | ||
6 | #include <wlr/types/wlr_cursor.h> | 8 | #include <wlr/types/wlr_cursor.h> |
7 | #include <wlr/types/wlr_keyboard_group.h> | 9 | #include <wlr/types/wlr_keyboard_group.h> |
8 | #include <wlr/types/wlr_virtual_keyboard_v1.h> | 10 | #include <wlr/types/wlr_virtual_keyboard_v1.h> |
@@ -431,6 +433,20 @@ void handle_virtual_pointer(struct wl_listener *listener, void *data) { | |||
431 | } | 433 | } |
432 | } | 434 | } |
433 | 435 | ||
436 | static void handle_transient_seat_manager_create_seat( | ||
437 | struct wl_listener *listener, void *data) { | ||
438 | struct wlr_transient_seat_v1 *transient_seat = data; | ||
439 | static uint64_t i; | ||
440 | char name[256]; | ||
441 | snprintf(name, sizeof(name), "transient-%"PRIx64, i++); | ||
442 | struct sway_seat *seat = seat_create(name); | ||
443 | if (seat && seat->wlr_seat) { | ||
444 | wlr_transient_seat_v1_ready(transient_seat, seat->wlr_seat); | ||
445 | } else { | ||
446 | wlr_transient_seat_v1_deny(transient_seat); | ||
447 | } | ||
448 | } | ||
449 | |||
434 | struct sway_input_manager *input_manager_create(struct sway_server *server) { | 450 | struct sway_input_manager *input_manager_create(struct sway_server *server) { |
435 | struct sway_input_manager *input = | 451 | struct sway_input_manager *input = |
436 | calloc(1, sizeof(struct sway_input_manager)); | 452 | calloc(1, sizeof(struct sway_input_manager)); |
@@ -466,6 +482,15 @@ struct sway_input_manager *input_manager_create(struct sway_server *server) { | |||
466 | 482 | ||
467 | input->pointer_gestures = wlr_pointer_gestures_v1_create(server->wl_display); | 483 | input->pointer_gestures = wlr_pointer_gestures_v1_create(server->wl_display); |
468 | 484 | ||
485 | input->transient_seat_manager = | ||
486 | wlr_transient_seat_manager_v1_create(server->wl_display); | ||
487 | assert(input->transient_seat_manager); | ||
488 | |||
489 | input->transient_seat_create.notify = | ||
490 | handle_transient_seat_manager_create_seat; | ||
491 | wl_signal_add(&input->transient_seat_manager->events.create_seat, | ||
492 | &input->transient_seat_create); | ||
493 | |||
469 | return input; | 494 | return input; |
470 | } | 495 | } |
471 | 496 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index f2486893..0c5672bc 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -67,6 +67,12 @@ static void seat_node_destroy(struct sway_seat_node *seat_node) { | |||
67 | } | 67 | } |
68 | 68 | ||
69 | void seat_destroy(struct sway_seat *seat) { | 69 | void seat_destroy(struct sway_seat *seat) { |
70 | wlr_seat_destroy(seat->wlr_seat); | ||
71 | } | ||
72 | |||
73 | static void handle_seat_destroy(struct wl_listener *listener, void *data) { | ||
74 | struct sway_seat *seat = wl_container_of(listener, seat, destroy); | ||
75 | |||
70 | if (seat == config->handler_context.seat) { | 76 | if (seat == config->handler_context.seat) { |
71 | config->handler_context.seat = input_manager_get_default_seat(); | 77 | config->handler_context.seat = input_manager_get_default_seat(); |
72 | } | 78 | } |
@@ -87,7 +93,7 @@ void seat_destroy(struct sway_seat *seat) { | |||
87 | wl_list_remove(&seat->request_set_selection.link); | 93 | wl_list_remove(&seat->request_set_selection.link); |
88 | wl_list_remove(&seat->request_set_primary_selection.link); | 94 | wl_list_remove(&seat->request_set_primary_selection.link); |
89 | wl_list_remove(&seat->link); | 95 | wl_list_remove(&seat->link); |
90 | wlr_seat_destroy(seat->wlr_seat); | 96 | wl_list_remove(&seat->destroy.link); |
91 | for (int i = 0; i < seat->deferred_bindings->length; i++) { | 97 | for (int i = 0; i < seat->deferred_bindings->length; i++) { |
92 | free_sway_binding(seat->deferred_bindings->items[i]); | 98 | free_sway_binding(seat->deferred_bindings->items[i]); |
93 | } | 99 | } |
@@ -534,6 +540,9 @@ struct sway_seat *seat_create(const char *seat_name) { | |||
534 | return NULL; | 540 | return NULL; |
535 | } | 541 | } |
536 | 542 | ||
543 | seat->destroy.notify = handle_seat_destroy; | ||
544 | wl_signal_add(&seat->wlr_seat->events.destroy, &seat->destroy); | ||
545 | |||
537 | seat->idle_inhibit_sources = seat->idle_wake_sources = | 546 | seat->idle_inhibit_sources = seat->idle_wake_sources = |
538 | IDLE_SOURCE_KEYBOARD | | 547 | IDLE_SOURCE_KEYBOARD | |
539 | IDLE_SOURCE_POINTER | | 548 | IDLE_SOURCE_POINTER | |
diff --git a/sway/server.c b/sway/server.c index 51bde794..d159dc9b 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -112,7 +112,8 @@ static bool is_privileged(const struct wl_global *global) { | |||
112 | global == server.session_lock.manager->global || | 112 | global == server.session_lock.manager->global || |
113 | global == server.input->keyboard_shortcuts_inhibit->global || | 113 | global == server.input->keyboard_shortcuts_inhibit->global || |
114 | global == server.input->virtual_keyboard->global || | 114 | global == server.input->virtual_keyboard->global || |
115 | global == server.input->virtual_pointer->global; | 115 | global == server.input->virtual_pointer->global || |
116 | global == server.input->transient_seat_manager->global; | ||
116 | } | 117 | } |
117 | 118 | ||
118 | static bool filter_global(const struct wl_client *client, | 119 | static bool filter_global(const struct wl_client *client, |