aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Andri Yngvason <andri@yngvason.is>2020-02-08 18:17:42 +0000
committerLibravatar Simon Ser <contact@emersion.fr>2024-03-18 09:07:21 +0100
commit5a7477cb8f568ce4aeb852215ad40899f18f3d91 (patch)
treeb080fbb1902c8ebab17c29a6ea44be670cc8b2af /sway
parentman: document that the scale might be adjusted (diff)
downloadsway-5a7477cb8f568ce4aeb852215ad40899f18f3d91.tar.gz
sway-5a7477cb8f568ce4aeb852215ad40899f18f3d91.tar.zst
sway-5a7477cb8f568ce4aeb852215ad40899f18f3d91.zip
Implement transient seat management
Diffstat (limited to 'sway')
-rw-r--r--sway/input/input-manager.c25
-rw-r--r--sway/input/seat.c11
-rw-r--r--sway/server.c3
3 files changed, 37 insertions, 2 deletions
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
436static 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
434struct sway_input_manager *input_manager_create(struct sway_server *server) { 450struct 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
69void seat_destroy(struct sway_seat *seat) { 69void seat_destroy(struct sway_seat *seat) {
70 wlr_seat_destroy(seat->wlr_seat);
71}
72
73static 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
118static bool filter_global(const struct wl_client *client, 119static bool filter_global(const struct wl_client *client,