aboutsummaryrefslogtreecommitdiffstats
path: root/sway/input
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-18 21:20:00 +1000
committerLibravatar Ryan Dwyer <ryandwyer1@gmail.com>2018-10-20 13:11:43 +1000
commitc006717910e5f30ca65645f701541dfa176c1392 (patch)
treec64452b7f2fe6ab481ad90c424cb14bcb0328eda /sway/input
parentMerge pull request #2872 from RyanDwyer/cursor-rebase (diff)
downloadsway-c006717910e5f30ca65645f701541dfa176c1392.tar.gz
sway-c006717910e5f30ca65645f701541dfa176c1392.tar.zst
sway-c006717910e5f30ca65645f701541dfa176c1392.zip
Minor refactor of input manager
The input manager is a singleton object. Passing the sway_input_manager argument to each of its functions is unnecessary, while removing the argument makes it obvious to the caller that it's a singleton. This patch removes the argument and makes the input manager use server.input instead. On a similar note: * sway_input_manager.server is removed in favour of using the server global. * seat.input is removed because it can get it from server.input. Due to a circular dependency, creating seat0 is now done directly in server_init rather than in input_manager_create. This is because creating seats must be done after server.input is set. Lastly, it now stores the default seat name using a constant and removes a second reference to seat0 (in input_manager_get_default_seat).
Diffstat (limited to 'sway/input')
-rw-r--r--sway/input/cursor.c20
-rw-r--r--sway/input/input-manager.c83
-rw-r--r--sway/input/keyboard.c2
-rw-r--r--sway/input/seat.c11
4 files changed, 49 insertions, 67 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 756f2f8c..a07bc53b 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -680,7 +680,7 @@ void cursor_send_pointer_motion(struct sway_cursor *cursor,
680 680
681static void handle_cursor_motion(struct wl_listener *listener, void *data) { 681static void handle_cursor_motion(struct wl_listener *listener, void *data) {
682 struct sway_cursor *cursor = wl_container_of(listener, cursor, motion); 682 struct sway_cursor *cursor = wl_container_of(listener, cursor, motion);
683 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 683 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
684 struct wlr_event_pointer_motion *event = data; 684 struct wlr_event_pointer_motion *event = data;
685 wlr_cursor_move(cursor->cursor, event->device, 685 wlr_cursor_move(cursor->cursor, event->device,
686 event->delta_x, event->delta_y); 686 event->delta_x, event->delta_y);
@@ -692,7 +692,7 @@ static void handle_cursor_motion_absolute(
692 struct wl_listener *listener, void *data) { 692 struct wl_listener *listener, void *data) {
693 struct sway_cursor *cursor = 693 struct sway_cursor *cursor =
694 wl_container_of(listener, cursor, motion_absolute); 694 wl_container_of(listener, cursor, motion_absolute);
695 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 695 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
696 struct wlr_event_pointer_motion_absolute *event = data; 696 struct wlr_event_pointer_motion_absolute *event = data;
697 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y); 697 wlr_cursor_warp_absolute(cursor->cursor, event->device, event->x, event->y);
698 cursor_send_pointer_motion(cursor, event->time_msec); 698 cursor_send_pointer_motion(cursor, event->time_msec);
@@ -970,7 +970,7 @@ void dispatch_cursor_button(struct sway_cursor *cursor,
970 970
971static void handle_cursor_button(struct wl_listener *listener, void *data) { 971static void handle_cursor_button(struct wl_listener *listener, void *data) {
972 struct sway_cursor *cursor = wl_container_of(listener, cursor, button); 972 struct sway_cursor *cursor = wl_container_of(listener, cursor, button);
973 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 973 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
974 struct wlr_event_pointer_button *event = data; 974 struct wlr_event_pointer_button *event = data;
975 dispatch_cursor_button(cursor, event->device, 975 dispatch_cursor_button(cursor, event->device,
976 event->time_msec, event->button, event->state); 976 event->time_msec, event->button, event->state);
@@ -1019,7 +1019,7 @@ static void dispatch_cursor_axis(struct sway_cursor *cursor,
1019 1019
1020static void handle_cursor_axis(struct wl_listener *listener, void *data) { 1020static void handle_cursor_axis(struct wl_listener *listener, void *data) {
1021 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis); 1021 struct sway_cursor *cursor = wl_container_of(listener, cursor, axis);
1022 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1022 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1023 struct wlr_event_pointer_axis *event = data; 1023 struct wlr_event_pointer_axis *event = data;
1024 dispatch_cursor_axis(cursor, event); 1024 dispatch_cursor_axis(cursor, event);
1025 transaction_commit_dirty(); 1025 transaction_commit_dirty();
@@ -1027,7 +1027,7 @@ static void handle_cursor_axis(struct wl_listener *listener, void *data) {
1027 1027
1028static void handle_touch_down(struct wl_listener *listener, void *data) { 1028static void handle_touch_down(struct wl_listener *listener, void *data) {
1029 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down); 1029 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_down);
1030 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1030 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1031 struct wlr_event_touch_down *event = data; 1031 struct wlr_event_touch_down *event = data;
1032 1032
1033 struct sway_seat *seat = cursor->seat; 1033 struct sway_seat *seat = cursor->seat;
@@ -1058,7 +1058,7 @@ static void handle_touch_down(struct wl_listener *listener, void *data) {
1058 1058
1059static void handle_touch_up(struct wl_listener *listener, void *data) { 1059static void handle_touch_up(struct wl_listener *listener, void *data) {
1060 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up); 1060 struct sway_cursor *cursor = wl_container_of(listener, cursor, touch_up);
1061 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1061 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1062 struct wlr_event_touch_up *event = data; 1062 struct wlr_event_touch_up *event = data;
1063 struct wlr_seat *seat = cursor->seat->wlr_seat; 1063 struct wlr_seat *seat = cursor->seat->wlr_seat;
1064 // TODO: fall back to cursor simulation if client has not bound to touch 1064 // TODO: fall back to cursor simulation if client has not bound to touch
@@ -1068,7 +1068,7 @@ static void handle_touch_up(struct wl_listener *listener, void *data) {
1068static void handle_touch_motion(struct wl_listener *listener, void *data) { 1068static void handle_touch_motion(struct wl_listener *listener, void *data) {
1069 struct sway_cursor *cursor = 1069 struct sway_cursor *cursor =
1070 wl_container_of(listener, cursor, touch_motion); 1070 wl_container_of(listener, cursor, touch_motion);
1071 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1071 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1072 struct wlr_event_touch_motion *event = data; 1072 struct wlr_event_touch_motion *event = data;
1073 1073
1074 struct sway_seat *seat = cursor->seat; 1074 struct sway_seat *seat = cursor->seat;
@@ -1132,7 +1132,7 @@ static void apply_mapping_from_region(struct wlr_input_device *device,
1132 1132
1133static void handle_tool_axis(struct wl_listener *listener, void *data) { 1133static void handle_tool_axis(struct wl_listener *listener, void *data) {
1134 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis); 1134 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_axis);
1135 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1135 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1136 struct wlr_event_tablet_tool_axis *event = data; 1136 struct wlr_event_tablet_tool_axis *event = data;
1137 struct sway_input_device *input_device = event->device->data; 1137 struct sway_input_device *input_device = event->device->data;
1138 1138
@@ -1156,7 +1156,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
1156 1156
1157static void handle_tool_tip(struct wl_listener *listener, void *data) { 1157static void handle_tool_tip(struct wl_listener *listener, void *data) {
1158 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip); 1158 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_tip);
1159 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1159 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1160 struct wlr_event_tablet_tool_tip *event = data; 1160 struct wlr_event_tablet_tool_tip *event = data;
1161 dispatch_cursor_button(cursor, event->device, event->time_msec, 1161 dispatch_cursor_button(cursor, event->device, event->time_msec,
1162 BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ? 1162 BTN_LEFT, event->state == WLR_TABLET_TOOL_TIP_DOWN ?
@@ -1166,7 +1166,7 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
1166 1166
1167static void handle_tool_button(struct wl_listener *listener, void *data) { 1167static void handle_tool_button(struct wl_listener *listener, void *data) {
1168 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button); 1168 struct sway_cursor *cursor = wl_container_of(listener, cursor, tool_button);
1169 wlr_idle_notify_activity(cursor->seat->input->server->idle, cursor->seat->wlr_seat); 1169 wlr_idle_notify_activity(server.idle, cursor->seat->wlr_seat);
1170 struct wlr_event_tablet_tool_button *event = data; 1170 struct wlr_event_tablet_tool_button *event = data;
1171 // TODO: the user may want to configure which tool buttons are mapped to 1171 // TODO: the user may want to configure which tool buttons are mapped to
1172 // which simulated pointer buttons 1172 // which simulated pointer buttons
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c
index 671f9a47..5be4143f 100644
--- a/sway/input/input-manager.c
+++ b/sway/input/input-manager.c
@@ -17,32 +17,28 @@
17#include "list.h" 17#include "list.h"
18#include "log.h" 18#include "log.h"
19 19
20static const char *default_seat = "seat0"; 20#define DEFAULT_SEAT "seat0"
21
22// TODO make me not global
23struct sway_input_manager *input_manager;
24 21
25struct input_config *current_input_config = NULL; 22struct input_config *current_input_config = NULL;
26struct seat_config *current_seat_config = NULL; 23struct seat_config *current_seat_config = NULL;
27 24
28struct sway_seat *input_manager_current_seat(struct sway_input_manager *input) { 25struct sway_seat *input_manager_current_seat(void) {
29 struct sway_seat *seat = config->handler_context.seat; 26 struct sway_seat *seat = config->handler_context.seat;
30 if (!seat) { 27 if (!seat) {
31 seat = input_manager_get_default_seat(input_manager); 28 seat = input_manager_get_default_seat();
32 } 29 }
33 return seat; 30 return seat;
34} 31}
35 32
36struct sway_seat *input_manager_get_seat( 33struct sway_seat *input_manager_get_seat(const char *seat_name) {
37 struct sway_input_manager *input, const char *seat_name) {
38 struct sway_seat *seat = NULL; 34 struct sway_seat *seat = NULL;
39 wl_list_for_each(seat, &input->seats, link) { 35 wl_list_for_each(seat, &server.input->seats, link) {
40 if (strcmp(seat->wlr_seat->name, seat_name) == 0) { 36 if (strcmp(seat->wlr_seat->name, seat_name) == 0) {
41 return seat; 37 return seat;
42 } 38 }
43 } 39 }
44 40
45 return seat_create(input, seat_name); 41 return seat_create(seat_name);
46} 42}
47 43
48char *input_device_get_identifier(struct wlr_input_device *device) { 44char *input_device_get_identifier(struct wlr_input_device *device) {
@@ -72,9 +68,9 @@ char *input_device_get_identifier(struct wlr_input_device *device) {
72} 68}
73 69
74static struct sway_input_device *input_sway_device_from_wlr( 70static struct sway_input_device *input_sway_device_from_wlr(
75 struct sway_input_manager *input, struct wlr_input_device *device) { 71 struct wlr_input_device *device) {
76 struct sway_input_device *input_device = NULL; 72 struct sway_input_device *input_device = NULL;
77 wl_list_for_each(input_device, &input->devices, link) { 73 wl_list_for_each(input_device, &server.input->devices, link) {
78 if (input_device->wlr_device == device) { 74 if (input_device->wlr_device == device) {
79 return input_device; 75 return input_device;
80 } 76 }
@@ -82,9 +78,9 @@ static struct sway_input_device *input_sway_device_from_wlr(
82 return NULL; 78 return NULL;
83} 79}
84 80
85static bool input_has_seat_configuration(struct sway_input_manager *input) { 81static bool input_has_seat_configuration(void) {
86 struct sway_seat *seat = NULL; 82 struct sway_seat *seat = NULL;
87 wl_list_for_each(seat, &input->seats, link) { 83 wl_list_for_each(seat, &server.input->seats, link) {
88 struct seat_config *seat_config = seat_get_config(seat); 84 struct seat_config *seat_config = seat_get_config(seat);
89 if (seat_config) { 85 if (seat_config) {
90 return true; 86 return true;
@@ -244,8 +240,7 @@ static void input_manager_libinput_config_pointer(
244static void handle_device_destroy(struct wl_listener *listener, void *data) { 240static void handle_device_destroy(struct wl_listener *listener, void *data) {
245 struct wlr_input_device *device = data; 241 struct wlr_input_device *device = data;
246 242
247 struct sway_input_device *input_device = 243 struct sway_input_device *input_device = input_sway_device_from_wlr(device);
248 input_sway_device_from_wlr(input_manager, device);
249 244
250 if (!sway_assert(input_device, "could not find sway device")) { 245 if (!sway_assert(input_device, "could not find sway device")) {
251 return; 246 return;
@@ -255,7 +250,7 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) {
255 input_device->identifier); 250 input_device->identifier);
256 251
257 struct sway_seat *seat = NULL; 252 struct sway_seat *seat = NULL;
258 wl_list_for_each(seat, &input_manager->seats, link) { 253 wl_list_for_each(seat, &server.input->seats, link) {
259 seat_remove_device(seat, input_device); 254 seat_remove_device(seat, input_device);
260 } 255 }
261 256
@@ -297,9 +292,9 @@ static void handle_new_input(struct wl_listener *listener, void *data) {
297 input_device->device_destroy.notify = handle_device_destroy; 292 input_device->device_destroy.notify = handle_device_destroy;
298 293
299 struct sway_seat *seat = NULL; 294 struct sway_seat *seat = NULL;
300 if (!input_has_seat_configuration(input)) { 295 if (!input_has_seat_configuration()) {
301 wlr_log(WLR_DEBUG, "no seat configuration, using default seat"); 296 wlr_log(WLR_DEBUG, "no seat configuration, using default seat");
302 seat = input_manager_get_seat(input, default_seat); 297 seat = input_manager_get_seat(DEFAULT_SEAT);
303 seat_add_device(seat, input_device); 298 seat_add_device(seat, input_device);
304 return; 299 return;
305 } 300 }
@@ -364,7 +359,7 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) {
364 struct wlr_virtual_keyboard_v1 *keyboard = data; 359 struct wlr_virtual_keyboard_v1 *keyboard = data;
365 struct wlr_input_device *device = &keyboard->input_device; 360 struct wlr_input_device *device = &keyboard->input_device;
366 361
367 struct sway_seat *seat = input_manager_get_default_seat(input_manager); 362 struct sway_seat *seat = input_manager_get_default_seat();
368 363
369 // TODO: The user might want this on a different seat 364 // TODO: The user might want this on a different seat
370 struct sway_input_device *input_device = 365 struct sway_input_device *input_device =
@@ -387,21 +382,16 @@ void handle_virtual_keyboard(struct wl_listener *listener, void *data) {
387 seat_add_device(seat, input_device); 382 seat_add_device(seat, input_device);
388} 383}
389 384
390struct sway_input_manager *input_manager_create( 385struct sway_input_manager *input_manager_create(struct sway_server *server) {
391 struct sway_server *server) {
392 struct sway_input_manager *input = 386 struct sway_input_manager *input =
393 calloc(1, sizeof(struct sway_input_manager)); 387 calloc(1, sizeof(struct sway_input_manager));
394 if (!input) { 388 if (!input) {
395 return NULL; 389 return NULL;
396 } 390 }
397 input->server = server;
398 391
399 wl_list_init(&input->devices); 392 wl_list_init(&input->devices);
400 wl_list_init(&input->seats); 393 wl_list_init(&input->seats);
401 394
402 // create the default seat
403 input_manager_get_seat(input, default_seat);
404
405 input->new_input.notify = handle_new_input; 395 input->new_input.notify = handle_new_input;
406 wl_signal_add(&server->backend->events.new_input, &input->new_input); 396 wl_signal_add(&server->backend->events.new_input, &input->new_input);
407 397
@@ -422,10 +412,9 @@ struct sway_input_manager *input_manager_create(
422 return input; 412 return input;
423} 413}
424 414
425bool input_manager_has_focus(struct sway_input_manager *input, 415bool input_manager_has_focus(struct sway_node *node) {
426 struct sway_node *node) {
427 struct sway_seat *seat = NULL; 416 struct sway_seat *seat = NULL;
428 wl_list_for_each(seat, &input->seats, link) { 417 wl_list_for_each(seat, &server.input->seats, link) {
429 if (seat_get_focus(seat) == node) { 418 if (seat_get_focus(seat) == node) {
430 return true; 419 return true;
431 } 420 }
@@ -434,19 +423,17 @@ bool input_manager_has_focus(struct sway_input_manager *input,
434 return false; 423 return false;
435} 424}
436 425
437void input_manager_set_focus(struct sway_input_manager *input, 426void input_manager_set_focus(struct sway_node *node) {
438 struct sway_node *node) {
439 struct sway_seat *seat; 427 struct sway_seat *seat;
440 wl_list_for_each(seat, &input->seats, link) { 428 wl_list_for_each(seat, &server.input->seats, link) {
441 seat_set_focus(seat, node); 429 seat_set_focus(seat, node);
442 } 430 }
443} 431}
444 432
445void input_manager_apply_input_config(struct sway_input_manager *input, 433void input_manager_apply_input_config(struct input_config *input_config) {
446 struct input_config *input_config) {
447 struct sway_input_device *input_device = NULL; 434 struct sway_input_device *input_device = NULL;
448 bool wildcard = strcmp(input_config->identifier, "*") == 0; 435 bool wildcard = strcmp(input_config->identifier, "*") == 0;
449 wl_list_for_each(input_device, &input->devices, link) { 436 wl_list_for_each(input_device, &server.input->devices, link) {
450 if (strcmp(input_device->identifier, input_config->identifier) == 0 437 if (strcmp(input_device->identifier, input_config->identifier) == 0
451 || wildcard) { 438 || wildcard) {
452 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER || 439 if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER ||
@@ -459,18 +446,17 @@ void input_manager_apply_input_config(struct sway_input_manager *input,
459 } 446 }
460 447
461 struct sway_seat *seat = NULL; 448 struct sway_seat *seat = NULL;
462 wl_list_for_each(seat, &input->seats, link) { 449 wl_list_for_each(seat, &server.input->seats, link) {
463 seat_configure_device(seat, input_device); 450 seat_configure_device(seat, input_device);
464 } 451 }
465 } 452 }
466 } 453 }
467} 454}
468 455
469void input_manager_apply_seat_config(struct sway_input_manager *input, 456void input_manager_apply_seat_config(struct seat_config *seat_config) {
470 struct seat_config *seat_config) {
471 wlr_log(WLR_DEBUG, "applying new seat config for seat %s", 457 wlr_log(WLR_DEBUG, "applying new seat config for seat %s",
472 seat_config->name); 458 seat_config->name);
473 struct sway_seat *seat = input_manager_get_seat(input, seat_config->name); 459 struct sway_seat *seat = input_manager_get_seat(seat_config->name);
474 if (!seat) { 460 if (!seat) {
475 return; 461 return;
476 } 462 }
@@ -480,10 +466,10 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
480 // for every device, try to add it to a seat and if no seat has it 466 // for every device, try to add it to a seat and if no seat has it
481 // attached, add it to the fallback seats. 467 // attached, add it to the fallback seats.
482 struct sway_input_device *input_device = NULL; 468 struct sway_input_device *input_device = NULL;
483 wl_list_for_each(input_device, &input->devices, link) { 469 wl_list_for_each(input_device, &server.input->devices, link) {
484 list_t *seat_list = create_list(); 470 list_t *seat_list = create_list();
485 struct sway_seat *seat = NULL; 471 struct sway_seat *seat = NULL;
486 wl_list_for_each(seat, &input->seats, link) { 472 wl_list_for_each(seat, &server.input->seats, link) {
487 struct seat_config *seat_config = seat_get_config(seat); 473 struct seat_config *seat_config = seat_get_config(seat);
488 if (!seat_config) { 474 if (!seat_config) {
489 continue; 475 continue;
@@ -496,7 +482,7 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
496 } 482 }
497 483
498 if (seat_list->length) { 484 if (seat_list->length) {
499 wl_list_for_each(seat, &input->seats, link) { 485 wl_list_for_each(seat, &server.input->seats, link) {
500 bool attached = false; 486 bool attached = false;
501 for (int i = 0; i < seat_list->length; ++i) { 487 for (int i = 0; i < seat_list->length; ++i) {
502 if (seat == seat_list->items[i]) { 488 if (seat == seat_list->items[i]) {
@@ -511,7 +497,7 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
511 } 497 }
512 } 498 }
513 } else { 499 } else {
514 wl_list_for_each(seat, &input->seats, link) { 500 wl_list_for_each(seat, &server.input->seats, link) {
515 struct seat_config *seat_config = seat_get_config(seat); 501 struct seat_config *seat_config = seat_get_config(seat);
516 if (seat_config && seat_config->fallback == 1) { 502 if (seat_config && seat_config->fallback == 1) {
517 seat_add_device(seat, input_device); 503 seat_add_device(seat, input_device);
@@ -524,18 +510,17 @@ void input_manager_apply_seat_config(struct sway_input_manager *input,
524 } 510 }
525} 511}
526 512
527void input_manager_configure_xcursor(struct sway_input_manager *input) { 513void input_manager_configure_xcursor(void) {
528 struct sway_seat *seat = NULL; 514 struct sway_seat *seat = NULL;
529 wl_list_for_each(seat, &input->seats, link) { 515 wl_list_for_each(seat, &server.input->seats, link) {
530 seat_configure_xcursor(seat); 516 seat_configure_xcursor(seat);
531 } 517 }
532} 518}
533 519
534struct sway_seat *input_manager_get_default_seat( 520struct sway_seat *input_manager_get_default_seat(void) {
535 struct sway_input_manager *input) {
536 struct sway_seat *seat = NULL; 521 struct sway_seat *seat = NULL;
537 wl_list_for_each(seat, &input->seats, link) { 522 wl_list_for_each(seat, &server.input->seats, link) {
538 if (strcmp(seat->wlr_seat->name, "seat0") == 0) { 523 if (strcmp(seat->wlr_seat->name, DEFAULT_SEAT) == 0) {
539 return seat; 524 return seat;
540 } 525 }
541 } 526 }
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 4427dabe..5c1e7ae6 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -211,7 +211,7 @@ static void handle_keyboard_key(struct wl_listener *listener, void *data) {
211 struct wlr_input_device *wlr_device = 211 struct wlr_input_device *wlr_device =
212 keyboard->seat_device->input_device->wlr_device; 212 keyboard->seat_device->input_device->wlr_device;
213 char *device_identifier = input_device_get_identifier(wlr_device); 213 char *device_identifier = input_device_get_identifier(wlr_device);
214 wlr_idle_notify_activity(seat->input->server->idle, wlr_seat); 214 wlr_idle_notify_activity(server.idle, wlr_seat);
215 struct wlr_event_keyboard_key *event = data; 215 struct wlr_event_keyboard_key *event = data;
216 bool input_inhibited = seat->exclusive_client != NULL; 216 bool input_inhibited = seat->exclusive_client != NULL;
217 217
diff --git a/sway/input/seat.c b/sway/input/seat.c
index d7733855..330b7bbe 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -95,8 +95,7 @@ static void seat_send_focus(struct sway_node *node, struct sway_seat *seat) {
95 if (view && seat_is_input_allowed(seat, view->surface)) { 95 if (view && seat_is_input_allowed(seat, view->surface)) {
96#ifdef HAVE_XWAYLAND 96#ifdef HAVE_XWAYLAND
97 if (view->type == SWAY_VIEW_XWAYLAND) { 97 if (view->type == SWAY_VIEW_XWAYLAND) {
98 struct wlr_xwayland *xwayland = 98 struct wlr_xwayland *xwayland = server.xwayland.wlr_xwayland;
99 seat->input->server->xwayland.wlr_xwayland;
100 wlr_xwayland_set_seat(xwayland, seat->wlr_seat); 99 wlr_xwayland_set_seat(xwayland, seat->wlr_seat);
101 } 100 }
102#endif 101#endif
@@ -328,14 +327,13 @@ static void collect_focus_container_iter(struct sway_container *container,
328 collect_focus_iter(&container->node, data); 327 collect_focus_iter(&container->node, data);
329} 328}
330 329
331struct sway_seat *seat_create(struct sway_input_manager *input, 330struct sway_seat *seat_create(const char *seat_name) {
332 const char *seat_name) {
333 struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); 331 struct sway_seat *seat = calloc(1, sizeof(struct sway_seat));
334 if (!seat) { 332 if (!seat) {
335 return NULL; 333 return NULL;
336 } 334 }
337 335
338 seat->wlr_seat = wlr_seat_create(input->server->wl_display, seat_name); 336 seat->wlr_seat = wlr_seat_create(server.wl_display, seat_name);
339 if (!sway_assert(seat->wlr_seat, "could not allocate seat")) { 337 if (!sway_assert(seat->wlr_seat, "could not allocate seat")) {
340 free(seat); 338 free(seat);
341 return NULL; 339 return NULL;
@@ -361,10 +359,9 @@ struct sway_seat *seat_create(struct sway_input_manager *input,
361 wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon); 359 wl_signal_add(&seat->wlr_seat->events.new_drag_icon, &seat->new_drag_icon);
362 seat->new_drag_icon.notify = handle_new_drag_icon; 360 seat->new_drag_icon.notify = handle_new_drag_icon;
363 361
364 seat->input = input;
365 wl_list_init(&seat->devices); 362 wl_list_init(&seat->devices);
366 363
367 wl_list_insert(&input->seats, &seat->link); 364 wl_list_insert(&server.input->seats, &seat->link);
368 365
369 return seat; 366 return seat;
370} 367}