diff options
-rw-r--r-- | include/sway/config.h | 27 | ||||
-rw-r--r-- | include/sway/input/input-manager.h | 23 | ||||
-rw-r--r-- | include/sway/input/seat.h | 28 | ||||
-rw-r--r-- | sway/commands.c | 20 | ||||
-rw-r--r-- | sway/commands/focus.c | 4 | ||||
-rw-r--r-- | sway/commands/move.c | 8 | ||||
-rw-r--r-- | sway/commands/seat.c | 11 | ||||
-rw-r--r-- | sway/commands/workspace.c | 2 | ||||
-rw-r--r-- | sway/config.c | 2 | ||||
-rw-r--r-- | sway/desktop/output.c | 4 | ||||
-rw-r--r-- | sway/desktop/wl_shell.c | 4 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 4 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 4 | ||||
-rw-r--r-- | sway/input/cursor.c | 10 | ||||
-rw-r--r-- | sway/input/input-manager.c | 144 | ||||
-rw-r--r-- | sway/input/keyboard.c | 2 | ||||
-rw-r--r-- | sway/input/seat.c | 99 | ||||
-rw-r--r-- | sway/ipc-json.c | 8 | ||||
-rw-r--r-- | sway/ipc-server.c | 6 | ||||
-rw-r--r-- | sway/server.c | 2 | ||||
-rw-r--r-- | sway/tree/container.c | 2 | ||||
-rw-r--r-- | sway/tree/layout.c | 14 | ||||
-rw-r--r-- | sway/tree/workspace.c | 14 |
23 files changed, 248 insertions, 194 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 03b51948..91f772b5 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -377,6 +377,7 @@ void free_config(struct sway_config *config); | |||
377 | void config_clear_handler_context(struct sway_config *config); | 377 | void config_clear_handler_context(struct sway_config *config); |
378 | 378 | ||
379 | void free_sway_variable(struct sway_variable *var); | 379 | void free_sway_variable(struct sway_variable *var); |
380 | |||
380 | /** | 381 | /** |
381 | * Does variable replacement for a string based on the config's currently loaded variables. | 382 | * Does variable replacement for a string based on the config's currently loaded variables. |
382 | */ | 383 | */ |
@@ -385,44 +386,68 @@ char *do_var_replacement(char *str); | |||
385 | struct cmd_results *check_security_config(); | 386 | struct cmd_results *check_security_config(); |
386 | 387 | ||
387 | int input_identifier_cmp(const void *item, const void *data); | 388 | int input_identifier_cmp(const void *item, const void *data); |
389 | |||
388 | struct input_config *new_input_config(const char* identifier); | 390 | struct input_config *new_input_config(const char* identifier); |
391 | |||
389 | void merge_input_config(struct input_config *dst, struct input_config *src); | 392 | void merge_input_config(struct input_config *dst, struct input_config *src); |
393 | |||
390 | struct input_config *copy_input_config(struct input_config *ic); | 394 | struct input_config *copy_input_config(struct input_config *ic); |
395 | |||
391 | void free_input_config(struct input_config *ic); | 396 | void free_input_config(struct input_config *ic); |
397 | |||
392 | void apply_input_config(struct input_config *input); | 398 | void apply_input_config(struct input_config *input); |
393 | 399 | ||
394 | int seat_name_cmp(const void *item, const void *data); | 400 | int seat_name_cmp(const void *item, const void *data); |
401 | |||
395 | struct seat_config *new_seat_config(const char* name); | 402 | struct seat_config *new_seat_config(const char* name); |
403 | |||
396 | void merge_seat_config(struct seat_config *dst, struct seat_config *src); | 404 | void merge_seat_config(struct seat_config *dst, struct seat_config *src); |
405 | |||
397 | struct seat_config *copy_seat_config(struct seat_config *seat); | 406 | struct seat_config *copy_seat_config(struct seat_config *seat); |
407 | |||
398 | void free_seat_config(struct seat_config *ic); | 408 | void free_seat_config(struct seat_config *ic); |
409 | |||
399 | struct seat_attachment_config *seat_attachment_config_new(); | 410 | struct seat_attachment_config *seat_attachment_config_new(); |
411 | |||
400 | struct seat_attachment_config *seat_config_get_attachment( | 412 | struct seat_attachment_config *seat_config_get_attachment( |
401 | struct seat_config *seat_config, char *identifier); | 413 | struct seat_config *seat_config, char *identifier); |
414 | |||
402 | void apply_seat_config(struct seat_config *seat); | 415 | void apply_seat_config(struct seat_config *seat); |
403 | 416 | ||
404 | int output_name_cmp(const void *item, const void *data); | 417 | int output_name_cmp(const void *item, const void *data); |
418 | |||
405 | void output_get_identifier(char *identifier, size_t len, | 419 | void output_get_identifier(char *identifier, size_t len, |
406 | struct sway_output *output); | 420 | struct sway_output *output); |
421 | |||
407 | struct output_config *new_output_config(const char *name); | 422 | struct output_config *new_output_config(const char *name); |
423 | |||
408 | void merge_output_config(struct output_config *dst, struct output_config *src); | 424 | void merge_output_config(struct output_config *dst, struct output_config *src); |
425 | |||
409 | void apply_output_config(struct output_config *oc, | 426 | void apply_output_config(struct output_config *oc, |
410 | struct sway_container *output); | 427 | struct sway_container *output); |
428 | |||
411 | void free_output_config(struct output_config *oc); | 429 | void free_output_config(struct output_config *oc); |
412 | 430 | ||
413 | int workspace_output_cmp_workspace(const void *a, const void *b); | 431 | int workspace_output_cmp_workspace(const void *a, const void *b); |
414 | 432 | ||
415 | int sway_binding_cmp(const void *a, const void *b); | 433 | int sway_binding_cmp(const void *a, const void *b); |
434 | |||
416 | int sway_binding_cmp_qsort(const void *a, const void *b); | 435 | int sway_binding_cmp_qsort(const void *a, const void *b); |
436 | |||
417 | int sway_binding_cmp_keys(const void *a, const void *b); | 437 | int sway_binding_cmp_keys(const void *a, const void *b); |
438 | |||
418 | void free_sway_binding(struct sway_binding *sb); | 439 | void free_sway_binding(struct sway_binding *sb); |
440 | |||
419 | struct sway_binding *sway_binding_dup(struct sway_binding *sb); | 441 | struct sway_binding *sway_binding_dup(struct sway_binding *sb); |
420 | 442 | ||
421 | /* Bar stuff */ | ||
422 | void load_swaybars(); | 443 | void load_swaybars(); |
444 | |||
423 | void invoke_swaybar(struct bar_config *bar); | 445 | void invoke_swaybar(struct bar_config *bar); |
446 | |||
424 | void terminate_swaybg(pid_t pid); | 447 | void terminate_swaybg(pid_t pid); |
448 | |||
425 | struct bar_config *default_bar_config(void); | 449 | struct bar_config *default_bar_config(void); |
450 | |||
426 | void free_bar_config(struct bar_config *bar); | 451 | void free_bar_config(struct bar_config *bar); |
427 | 452 | ||
428 | /* Global config singleton. */ | 453 | /* Global config singleton. */ |
diff --git a/include/sway/input/input-manager.h b/include/sway/input/input-manager.h index c6c73dba..8e39a4a7 100644 --- a/include/sway/input/input-manager.h +++ b/include/sway/input/input-manager.h | |||
@@ -14,7 +14,6 @@ extern struct sway_input_manager *input_manager; | |||
14 | struct sway_input_device { | 14 | struct sway_input_device { |
15 | char *identifier; | 15 | char *identifier; |
16 | struct wlr_input_device *wlr_device; | 16 | struct wlr_input_device *wlr_device; |
17 | struct input_config *config; | ||
18 | struct wl_list link; | 17 | struct wl_list link; |
19 | struct wl_listener device_destroy; | 18 | struct wl_listener device_destroy; |
20 | }; | 19 | }; |
@@ -27,30 +26,34 @@ struct sway_input_manager { | |||
27 | struct wl_listener new_input; | 26 | struct wl_listener new_input; |
28 | }; | 27 | }; |
29 | 28 | ||
30 | struct sway_input_manager *sway_input_manager_create( | 29 | struct sway_input_manager *input_manager_create(struct sway_server *server); |
31 | struct sway_server *server); | ||
32 | 30 | ||
33 | bool sway_input_manager_has_focus(struct sway_input_manager *input, | 31 | bool input_manager_has_focus(struct sway_input_manager *input, |
34 | struct sway_container *container); | 32 | struct sway_container *container); |
35 | 33 | ||
36 | void sway_input_manager_set_focus(struct sway_input_manager *input, | 34 | void input_manager_set_focus(struct sway_input_manager *input, |
37 | struct sway_container *container); | 35 | struct sway_container *container); |
38 | 36 | ||
39 | void sway_input_manager_configure_xcursor(struct sway_input_manager *input); | 37 | void input_manager_configure_xcursor(struct sway_input_manager *input); |
40 | 38 | ||
41 | void sway_input_manager_apply_input_config(struct sway_input_manager *input, | 39 | void input_manager_apply_input_config(struct sway_input_manager *input, |
42 | struct input_config *input_config); | 40 | struct input_config *input_config); |
43 | 41 | ||
44 | void sway_input_manager_apply_seat_config(struct sway_input_manager *input, | 42 | void input_manager_apply_seat_config(struct sway_input_manager *input, |
45 | struct seat_config *seat_config); | 43 | struct seat_config *seat_config); |
46 | 44 | ||
47 | struct sway_seat *sway_input_manager_get_default_seat( | 45 | struct sway_seat *input_manager_get_default_seat( |
48 | struct sway_input_manager *input); | 46 | struct sway_input_manager *input); |
49 | 47 | ||
50 | struct sway_seat *input_manager_get_seat(struct sway_input_manager *input, | 48 | struct sway_seat *input_manager_get_seat(struct sway_input_manager *input, |
51 | const char *seat_name); | 49 | const char *seat_name); |
52 | 50 | ||
53 | /** Gets the last seat the user interacted with */ | 51 | /** |
52 | * Gets the last seat the user interacted with | ||
53 | */ | ||
54 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input); | 54 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input); |
55 | 55 | ||
56 | struct input_config *input_device_get_config(struct sway_input_device *device); | ||
57 | |||
58 | |||
56 | #endif | 59 | #endif |
diff --git a/include/sway/input/seat.h b/include/sway/input/seat.h index 31210a5a..5c3c2c4f 100644 --- a/include/sway/input/seat.h +++ b/include/sway/input/seat.h | |||
@@ -8,7 +8,6 @@ struct sway_seat_device { | |||
8 | struct sway_seat *sway_seat; | 8 | struct sway_seat *sway_seat; |
9 | struct sway_input_device *input_device; | 9 | struct sway_input_device *input_device; |
10 | struct sway_keyboard *keyboard; | 10 | struct sway_keyboard *keyboard; |
11 | struct seat_attachment_config *attachment_config; | ||
12 | struct wl_list link; // sway_seat::devices | 11 | struct wl_list link; // sway_seat::devices |
13 | }; | 12 | }; |
14 | 13 | ||
@@ -23,7 +22,6 @@ struct sway_seat_container { | |||
23 | 22 | ||
24 | struct sway_seat { | 23 | struct sway_seat { |
25 | struct wlr_seat *wlr_seat; | 24 | struct wlr_seat *wlr_seat; |
26 | struct seat_config *config; | ||
27 | struct sway_cursor *cursor; | 25 | struct sway_cursor *cursor; |
28 | struct sway_input_manager *input; | 26 | struct sway_input_manager *input; |
29 | 27 | ||
@@ -38,28 +36,28 @@ struct sway_seat { | |||
38 | struct wl_list link; // input_manager::seats | 36 | struct wl_list link; // input_manager::seats |
39 | }; | 37 | }; |
40 | 38 | ||
41 | struct sway_seat *sway_seat_create(struct sway_input_manager *input, | 39 | struct sway_seat *seat_create(struct sway_input_manager *input, |
42 | const char *seat_name); | 40 | const char *seat_name); |
43 | 41 | ||
44 | void sway_seat_destroy(struct sway_seat *seat); | 42 | void seat_destroy(struct sway_seat *seat); |
45 | 43 | ||
46 | void sway_seat_add_device(struct sway_seat *seat, | 44 | void seat_add_device(struct sway_seat *seat, |
47 | struct sway_input_device *device); | 45 | struct sway_input_device *device); |
48 | 46 | ||
49 | void sway_seat_configure_device(struct sway_seat *seat, | 47 | void seat_configure_device(struct sway_seat *seat, |
50 | struct sway_input_device *device); | 48 | struct sway_input_device *device); |
51 | 49 | ||
52 | void sway_seat_remove_device(struct sway_seat *seat, | 50 | void seat_remove_device(struct sway_seat *seat, |
53 | struct sway_input_device *device); | 51 | struct sway_input_device *device); |
54 | 52 | ||
55 | void sway_seat_configure_xcursor(struct sway_seat *seat); | 53 | void seat_configure_xcursor(struct sway_seat *seat); |
56 | 54 | ||
57 | void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container); | 55 | void seat_set_focus(struct sway_seat *seat, struct sway_container *container); |
58 | 56 | ||
59 | void sway_seat_set_focus_warp(struct sway_seat *seat, | 57 | void seat_set_focus_warp(struct sway_seat *seat, |
60 | struct sway_container *container, bool warp); | 58 | struct sway_container *container, bool warp); |
61 | 59 | ||
62 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat); | 60 | struct sway_container *seat_get_focus(struct sway_seat *seat); |
63 | 61 | ||
64 | /** | 62 | /** |
65 | * Return the last container to be focused for the seat (or the most recently | 63 | * Return the last container to be focused for the seat (or the most recently |
@@ -70,12 +68,14 @@ struct sway_container *sway_seat_get_focus(struct sway_seat *seat); | |||
70 | * is destroyed, or focus moves to a container with children and we need to | 68 | * is destroyed, or focus moves to a container with children and we need to |
71 | * descend into the next leaf in focus order. | 69 | * descend into the next leaf in focus order. |
72 | */ | 70 | */ |
73 | struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, | 71 | struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, |
74 | struct sway_container *container); | 72 | struct sway_container *container); |
75 | 73 | ||
76 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, | 74 | struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, |
77 | enum sway_container_type type); | 75 | enum sway_container_type type); |
78 | 76 | ||
79 | void sway_seat_set_config(struct sway_seat *seat, struct seat_config *seat_config); | 77 | void seat_apply_config(struct sway_seat *seat, struct seat_config *seat_config); |
78 | |||
79 | struct seat_config *seat_get_config(struct sway_seat *seat); | ||
80 | 80 | ||
81 | #endif | 81 | #endif |
diff --git a/sway/commands.c b/sway/commands.c index b6af3d1a..9ba252b0 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -72,23 +72,23 @@ void apply_input_config(struct input_config *input) { | |||
72 | list_add(config->input_configs, input); | 72 | list_add(config->input_configs, input); |
73 | } | 73 | } |
74 | 74 | ||
75 | sway_input_manager_apply_input_config(input_manager, input); | 75 | input_manager_apply_input_config(input_manager, input); |
76 | } | 76 | } |
77 | 77 | ||
78 | void apply_seat_config(struct seat_config *seat) { | 78 | void apply_seat_config(struct seat_config *seat_config) { |
79 | int i; | 79 | int i; |
80 | i = list_seq_find(config->seat_configs, seat_name_cmp, seat->name); | 80 | i = list_seq_find(config->seat_configs, seat_name_cmp, seat_config->name); |
81 | if (i >= 0) { | 81 | if (i >= 0) { |
82 | // merge existing config | 82 | // merge existing config |
83 | struct seat_config *sc = config->seat_configs->items[i]; | 83 | struct seat_config *sc = config->seat_configs->items[i]; |
84 | merge_seat_config(sc, seat); | 84 | merge_seat_config(sc, seat_config); |
85 | free_seat_config(seat); | 85 | free_seat_config(seat_config); |
86 | seat = sc; | 86 | seat_config = sc; |
87 | } else { | 87 | } else { |
88 | list_add(config->seat_configs, seat); | 88 | list_add(config->seat_configs, seat_config); |
89 | } | 89 | } |
90 | 90 | ||
91 | sway_input_manager_apply_seat_config(input_manager, seat); | 91 | input_manager_apply_seat_config(input_manager, seat_config); |
92 | } | 92 | } |
93 | 93 | ||
94 | /* Keep alphabetized */ | 94 | /* Keep alphabetized */ |
@@ -263,7 +263,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { | |||
263 | 263 | ||
264 | if (seat == NULL) { | 264 | if (seat == NULL) { |
265 | // passing a NULL seat means we just pick the default seat | 265 | // passing a NULL seat means we just pick the default seat |
266 | seat = sway_input_manager_get_default_seat(input_manager); | 266 | seat = input_manager_get_default_seat(input_manager); |
267 | if (!sway_assert(seat, "could not find a seat to run the command on")) { | 267 | if (!sway_assert(seat, "could not find a seat to run the command on")) { |
268 | return NULL; | 268 | return NULL; |
269 | } | 269 | } |
@@ -341,7 +341,7 @@ struct cmd_results *execute_command(char *_exec, struct sway_seat *seat) { | |||
341 | // without criteria, the command acts upon the focused | 341 | // without criteria, the command acts upon the focused |
342 | // container | 342 | // container |
343 | config->handler_context.current_container = | 343 | config->handler_context.current_container = |
344 | sway_seat_get_focus_inactive(seat, &root_container); | 344 | seat_get_focus_inactive(seat, &root_container); |
345 | if (!sway_assert(config->handler_context.current_container, | 345 | if (!sway_assert(config->handler_context.current_container, |
346 | "could not get focus-inactive for root container")) { | 346 | "could not get focus-inactive for root container")) { |
347 | return NULL; | 347 | return NULL; |
diff --git a/sway/commands/focus.c b/sway/commands/focus.c index 0a521b9e..74d9d535 100644 --- a/sway/commands/focus.c +++ b/sway/commands/focus.c | |||
@@ -36,7 +36,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { | |||
36 | } | 36 | } |
37 | 37 | ||
38 | if (argc == 0) { | 38 | if (argc == 0) { |
39 | sway_seat_set_focus(seat, con); | 39 | seat_set_focus(seat, con); |
40 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 40 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
41 | } | 41 | } |
42 | 42 | ||
@@ -50,7 +50,7 @@ struct cmd_results *cmd_focus(int argc, char **argv) { | |||
50 | struct sway_container *next_focus = container_get_in_direction( | 50 | struct sway_container *next_focus = container_get_in_direction( |
51 | con, seat, direction); | 51 | con, seat, direction); |
52 | if (next_focus) { | 52 | if (next_focus) { |
53 | sway_seat_set_focus(seat, next_focus); | 53 | seat_set_focus(seat, next_focus); |
54 | } | 54 | } |
55 | 55 | ||
56 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 56 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/move.c b/sway/commands/move.c index ab959b77..644c622b 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -78,10 +78,10 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
78 | } | 78 | } |
79 | free(ws_name); | 79 | free(ws_name); |
80 | struct sway_container *old_parent = current->parent; | 80 | struct sway_container *old_parent = current->parent; |
81 | struct sway_container *focus = sway_seat_get_focus_inactive( | 81 | struct sway_container *focus = seat_get_focus_inactive( |
82 | config->handler_context.seat, ws); | 82 | config->handler_context.seat, ws); |
83 | container_move_to(current, focus); | 83 | container_move_to(current, focus); |
84 | sway_seat_set_focus(config->handler_context.seat, old_parent); | 84 | seat_set_focus(config->handler_context.seat, old_parent); |
85 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 85 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
86 | } else if (strcasecmp(argv[1], "to") == 0 | 86 | } else if (strcasecmp(argv[1], "to") == 0 |
87 | && strcasecmp(argv[2], "output") == 0) { | 87 | && strcasecmp(argv[2], "output") == 0) { |
@@ -100,7 +100,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
100 | return cmd_results_new(CMD_FAILURE, "move workspace", | 100 | return cmd_results_new(CMD_FAILURE, "move workspace", |
101 | "Can't find output with name/direction '%s'", argv[3]); | 101 | "Can't find output with name/direction '%s'", argv[3]); |
102 | } | 102 | } |
103 | struct sway_container *focus = sway_seat_get_focus_inactive( | 103 | struct sway_container *focus = seat_get_focus_inactive( |
104 | config->handler_context.seat, destination); | 104 | config->handler_context.seat, destination); |
105 | if (!focus) { | 105 | if (!focus) { |
106 | // We've never been to this output before | 106 | // We've never been to this output before |
@@ -108,7 +108,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
108 | } | 108 | } |
109 | struct sway_container *old_parent = current->parent; | 109 | struct sway_container *old_parent = current->parent; |
110 | container_move_to(current, focus); | 110 | container_move_to(current, focus); |
111 | sway_seat_set_focus(config->handler_context.seat, old_parent); | 111 | seat_set_focus(config->handler_context.seat, old_parent); |
112 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 112 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
113 | } | 113 | } |
114 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 114 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |
diff --git a/sway/commands/seat.c b/sway/commands/seat.c index 45079616..819b769c 100644 --- a/sway/commands/seat.c +++ b/sway/commands/seat.c | |||
@@ -14,7 +14,8 @@ struct cmd_results *cmd_seat(int argc, char **argv) { | |||
14 | free_seat_config(config->handler_context.seat_config); | 14 | free_seat_config(config->handler_context.seat_config); |
15 | config->handler_context.seat_config = new_seat_config(argv[0]); | 15 | config->handler_context.seat_config = new_seat_config(argv[0]); |
16 | if (!config->handler_context.seat_config) { | 16 | if (!config->handler_context.seat_config) { |
17 | return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); | 17 | return cmd_results_new(CMD_FAILURE, NULL, |
18 | "Couldn't allocate config"); | ||
18 | } | 19 | } |
19 | wlr_log(L_DEBUG, "entering seat block: %s", argv[0]); | 20 | wlr_log(L_DEBUG, "entering seat block: %s", argv[0]); |
20 | return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL); | 21 | return cmd_results_new(CMD_BLOCK_SEAT, NULL, NULL); |
@@ -28,7 +29,8 @@ struct cmd_results *cmd_seat(int argc, char **argv) { | |||
28 | if (!has_context) { | 29 | if (!has_context) { |
29 | config->handler_context.seat_config = new_seat_config(argv[0]); | 30 | config->handler_context.seat_config = new_seat_config(argv[0]); |
30 | if (!config->handler_context.seat_config) { | 31 | if (!config->handler_context.seat_config) { |
31 | return cmd_results_new(CMD_FAILURE, NULL, "Couldn't allocate config"); | 32 | return cmd_results_new(CMD_FAILURE, NULL, |
33 | "Couldn't allocate config"); | ||
32 | } | 34 | } |
33 | } | 35 | } |
34 | 36 | ||
@@ -41,7 +43,10 @@ struct cmd_results *cmd_seat(int argc, char **argv) { | |||
41 | } else if (strcasecmp("fallback", argv[1]) == 0) { | 43 | } else if (strcasecmp("fallback", argv[1]) == 0) { |
42 | res = seat_cmd_fallback(argc_new, argv_new); | 44 | res = seat_cmd_fallback(argc_new, argv_new); |
43 | } else { | 45 | } else { |
44 | res = cmd_results_new(CMD_INVALID, "seat <name>", "Unknown command %s", argv[1]); | 46 | res = |
47 | cmd_results_new(CMD_INVALID, | ||
48 | "seat <name>", "Unknown command %s", | ||
49 | argv[1]); | ||
45 | } | 50 | } |
46 | 51 | ||
47 | if (!has_context) { | 52 | if (!has_context) { |
diff --git a/sway/commands/workspace.c b/sway/commands/workspace.c index 8f39e5fc..aa4096f7 100644 --- a/sway/commands/workspace.c +++ b/sway/commands/workspace.c | |||
@@ -91,7 +91,7 @@ struct cmd_results *cmd_workspace(int argc, char **argv) { | |||
91 | } | 91 | } |
92 | workspace_switch(ws); | 92 | workspace_switch(ws); |
93 | current_container = | 93 | current_container = |
94 | sway_seat_get_focus(config->handler_context.seat); | 94 | seat_get_focus(config->handler_context.seat); |
95 | struct sway_container *new_output = container_parent(current_container, C_OUTPUT); | 95 | struct sway_container *new_output = container_parent(current_container, C_OUTPUT); |
96 | 96 | ||
97 | if (config->mouse_warping && old_output != new_output) { | 97 | if (config->mouse_warping && old_output != new_output) { |
diff --git a/sway/config.c b/sway/config.c index 0eecf7f6..90b833ab 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -125,7 +125,7 @@ static void destroy_removed_seats(struct sway_config *old_config, | |||
125 | seat_name_cmp, seat_config->name) < 0) { | 125 | seat_name_cmp, seat_config->name) < 0) { |
126 | seat = input_manager_get_seat(input_manager, | 126 | seat = input_manager_get_seat(input_manager, |
127 | seat_config->name); | 127 | seat_config->name); |
128 | sway_seat_destroy(seat); | 128 | seat_destroy(seat); |
129 | } | 129 | } |
130 | } | 130 | } |
131 | } | 131 | } |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index c4265818..5e8a081c 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -228,7 +228,7 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
228 | 228 | ||
229 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 229 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
230 | struct sway_container *focus = | 230 | struct sway_container *focus = |
231 | sway_seat_get_focus_inactive(seat, output->swayc); | 231 | seat_get_focus_inactive(seat, output->swayc); |
232 | if (!focus) { | 232 | if (!focus) { |
233 | // We've never been to this output before | 233 | // We've never been to this output before |
234 | focus = output->swayc->children->items[0]; | 234 | focus = output->swayc->children->items[0]; |
@@ -373,7 +373,7 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
373 | wl_list_init(&output->layers[i]); | 373 | wl_list_init(&output->layers[i]); |
374 | } | 374 | } |
375 | 375 | ||
376 | sway_input_manager_configure_xcursor(input_manager); | 376 | input_manager_configure_xcursor(input_manager); |
377 | 377 | ||
378 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | 378 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); |
379 | output->destroy.notify = handle_destroy; | 379 | output->destroy.notify = handle_destroy; |
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index 4fcc6317..c44fcf27 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -133,10 +133,10 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { | |||
133 | wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); | 133 | wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); |
134 | 134 | ||
135 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 135 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
136 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | 136 | struct sway_container *focus = seat_get_focus_inactive(seat, &root_container); |
137 | struct sway_container *cont = container_view_create(focus, sway_view); | 137 | struct sway_container *cont = container_view_create(focus, sway_view); |
138 | sway_view->swayc = cont; | 138 | sway_view->swayc = cont; |
139 | 139 | ||
140 | arrange_windows(cont->parent, -1, -1); | 140 | arrange_windows(cont->parent, -1, -1); |
141 | sway_input_manager_set_focus(input_manager, cont); | 141 | input_manager_set_focus(input_manager, cont); |
142 | } | 142 | } |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 713437f2..cffe83fb 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -98,11 +98,11 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
98 | container_view_destroy(view->swayc); | 98 | container_view_destroy(view->swayc); |
99 | 99 | ||
100 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 100 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
101 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | 101 | struct sway_container *focus = seat_get_focus_inactive(seat, &root_container); |
102 | struct sway_container *cont = container_view_create(focus, view); | 102 | struct sway_container *cont = container_view_create(focus, view); |
103 | view->swayc = cont; | 103 | view->swayc = cont; |
104 | arrange_windows(cont->parent, -1, -1); | 104 | arrange_windows(cont->parent, -1, -1); |
105 | sway_input_manager_set_focus(input_manager, cont); | 105 | input_manager_set_focus(input_manager, cont); |
106 | 106 | ||
107 | view_damage_whole(sway_surface->view); | 107 | view_damage_whole(sway_surface->view); |
108 | } | 108 | } |
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 273ca2bf..17f827d9 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -143,12 +143,12 @@ static void handle_map(struct wl_listener *listener, void *data) { | |||
143 | wlr_xwayland_surface_set_maximized(xsurface, true); | 143 | wlr_xwayland_surface_set_maximized(xsurface, true); |
144 | 144 | ||
145 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 145 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
146 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, | 146 | struct sway_container *focus = seat_get_focus_inactive(seat, |
147 | &root_container); | 147 | &root_container); |
148 | struct sway_container *cont = container_view_create(focus, view); | 148 | struct sway_container *cont = container_view_create(focus, view); |
149 | view->swayc = cont; | 149 | view->swayc = cont; |
150 | arrange_windows(cont->parent, -1, -1); | 150 | arrange_windows(cont->parent, -1, -1); |
151 | sway_input_manager_set_focus(input_manager, cont); | 151 | input_manager_set_focus(input_manager, cont); |
152 | } | 152 | } |
153 | 153 | ||
154 | view_damage_whole(sway_surface->view); | 154 | view_damage_whole(sway_surface->view); |
diff --git a/sway/input/cursor.c b/sway/input/cursor.c index d608a9cf..7d05e942 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c | |||
@@ -84,7 +84,7 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, | |||
84 | 84 | ||
85 | // find the focused workspace on the output for this seat | 85 | // find the focused workspace on the output for this seat |
86 | struct sway_container *ws = | 86 | struct sway_container *ws = |
87 | sway_seat_get_focus_inactive(cursor->seat, output->swayc); | 87 | seat_get_focus_inactive(cursor->seat, output->swayc); |
88 | if (ws && ws->type != C_WORKSPACE) { | 88 | if (ws && ws->type != C_WORKSPACE) { |
89 | ws = container_parent(ws, C_WORKSPACE); | 89 | ws = container_parent(ws, C_WORKSPACE); |
90 | } | 90 | } |
@@ -129,7 +129,7 @@ static void cursor_send_pointer_motion(struct sway_cursor *cursor, | |||
129 | double sx, sy; | 129 | double sx, sy; |
130 | struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy); | 130 | struct sway_container *c = container_at_cursor(cursor, &surface, &sx, &sy); |
131 | if (c && config->focus_follows_mouse) { | 131 | if (c && config->focus_follows_mouse) { |
132 | sway_seat_set_focus_warp(cursor->seat, c, false); | 132 | seat_set_focus_warp(cursor->seat, c, false); |
133 | } | 133 | } |
134 | 134 | ||
135 | // reset cursor if switching between clients | 135 | // reset cursor if switching between clients |
@@ -191,15 +191,15 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { | |||
191 | if (new_ws && new_ws->type != C_WORKSPACE) { | 191 | if (new_ws && new_ws->type != C_WORKSPACE) { |
192 | new_ws = container_parent(new_ws, C_WORKSPACE); | 192 | new_ws = container_parent(new_ws, C_WORKSPACE); |
193 | } | 193 | } |
194 | struct sway_container *old_ws = sway_seat_get_focus(cursor->seat); | 194 | struct sway_container *old_ws = seat_get_focus(cursor->seat); |
195 | if (old_ws && old_ws->type != C_WORKSPACE) { | 195 | if (old_ws && old_ws->type != C_WORKSPACE) { |
196 | old_ws = container_parent(old_ws, C_WORKSPACE); | 196 | old_ws = container_parent(old_ws, C_WORKSPACE); |
197 | } | 197 | } |
198 | if (new_ws != old_ws) { | 198 | if (new_ws != old_ws) { |
199 | sway_seat_set_focus(cursor->seat, cont); | 199 | seat_set_focus(cursor->seat, cont); |
200 | } | 200 | } |
201 | } else { | 201 | } else { |
202 | sway_seat_set_focus(cursor->seat, cont); | 202 | seat_set_focus(cursor->seat, cont); |
203 | } | 203 | } |
204 | 204 | ||
205 | wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, event->time_msec, | 205 | wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, event->time_msec, |
diff --git a/sway/input/input-manager.c b/sway/input/input-manager.c index d421a03f..c3507f65 100644 --- a/sway/input/input-manager.c +++ b/sway/input/input-manager.c | |||
@@ -26,7 +26,7 @@ struct seat_config *current_seat_config = NULL; | |||
26 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input) { | 26 | struct sway_seat *input_manager_current_seat(struct sway_input_manager *input) { |
27 | struct sway_seat *seat = config->handler_context.seat; | 27 | struct sway_seat *seat = config->handler_context.seat; |
28 | if (!seat) { | 28 | if (!seat) { |
29 | seat = sway_input_manager_get_default_seat(input_manager); | 29 | seat = input_manager_get_default_seat(input_manager); |
30 | } | 30 | } |
31 | return seat; | 31 | return seat; |
32 | } | 32 | } |
@@ -40,7 +40,7 @@ struct sway_seat *input_manager_get_seat( | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | return sway_seat_create(input, seat_name); | 43 | return seat_create(input, seat_name); |
44 | } | 44 | } |
45 | 45 | ||
46 | static char *get_device_identifier(struct wlr_input_device *device) { | 46 | static char *get_device_identifier(struct wlr_input_device *device) { |
@@ -83,7 +83,8 @@ static struct sway_input_device *input_sway_device_from_wlr( | |||
83 | static bool input_has_seat_configuration(struct sway_input_manager *input) { | 83 | static bool input_has_seat_configuration(struct sway_input_manager *input) { |
84 | struct sway_seat *seat = NULL; | 84 | struct sway_seat *seat = NULL; |
85 | wl_list_for_each(seat, &input->seats, link) { | 85 | wl_list_for_each(seat, &input->seats, link) { |
86 | if (seat->config) { | 86 | struct seat_config *seat_config = seat_get_config(seat); |
87 | if (seat_config) { | ||
87 | return true; | 88 | return true; |
88 | } | 89 | } |
89 | } | 90 | } |
@@ -91,9 +92,10 @@ static bool input_has_seat_configuration(struct sway_input_manager *input) { | |||
91 | return false; | 92 | return false; |
92 | } | 93 | } |
93 | 94 | ||
94 | static void sway_input_manager_libinput_config_pointer(struct sway_input_device *input_device) { | 95 | static void input_manager_libinput_config_pointer( |
96 | struct sway_input_device *input_device) { | ||
95 | struct wlr_input_device *wlr_device = input_device->wlr_device; | 97 | struct wlr_input_device *wlr_device = input_device->wlr_device; |
96 | struct input_config *ic = input_device->config; | 98 | struct input_config *ic = input_device_get_config(input_device); |
97 | struct libinput_device *libinput_device; | 99 | struct libinput_device *libinput_device; |
98 | 100 | ||
99 | if (!ic || !wlr_input_device_is_libinput(wlr_device)) { | 101 | if (!ic || !wlr_input_device_is_libinput(wlr_device)) { |
@@ -101,22 +103,27 @@ static void sway_input_manager_libinput_config_pointer(struct sway_input_device | |||
101 | } | 103 | } |
102 | 104 | ||
103 | libinput_device = wlr_libinput_get_device_handle(wlr_device); | 105 | libinput_device = wlr_libinput_get_device_handle(wlr_device); |
104 | wlr_log(L_DEBUG, "sway_input_manager_libinput_config_pointer(%s)", ic->identifier); | 106 | wlr_log(L_DEBUG, "input_manager_libinput_config_pointer(%s)", |
107 | ic->identifier); | ||
105 | 108 | ||
106 | if (ic->accel_profile != INT_MIN) { | 109 | if (ic->accel_profile != INT_MIN) { |
107 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)", | 110 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_profile(%d)", |
108 | ic->identifier, ic->accel_profile); | 111 | ic->identifier, ic->accel_profile); |
109 | libinput_device_config_accel_set_profile(libinput_device, ic->accel_profile); | 112 | libinput_device_config_accel_set_profile(libinput_device, |
113 | ic->accel_profile); | ||
110 | } | 114 | } |
111 | if (ic->click_method != INT_MIN) { | 115 | if (ic->click_method != INT_MIN) { |
112 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)", | 116 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) click_set_method(%d)", |
113 | ic->identifier, ic->click_method); | 117 | ic->identifier, ic->click_method); |
114 | libinput_device_config_click_set_method(libinput_device, ic->click_method); | 118 | libinput_device_config_click_set_method(libinput_device, |
119 | ic->click_method); | ||
115 | } | 120 | } |
116 | if (ic->drag_lock != INT_MIN) { | 121 | if (ic->drag_lock != INT_MIN) { |
117 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", | 122 | wlr_log(L_DEBUG, |
123 | "libinput_config_pointer(%s) tap_set_drag_lock_enabled(%d)", | ||
118 | ic->identifier, ic->click_method); | 124 | ic->identifier, ic->click_method); |
119 | libinput_device_config_tap_set_drag_lock_enabled(libinput_device, ic->drag_lock); | 125 | libinput_device_config_tap_set_drag_lock_enabled(libinput_device, |
126 | ic->drag_lock); | ||
120 | } | 127 | } |
121 | if (ic->dwt != INT_MIN) { | 128 | if (ic->dwt != INT_MIN) { |
122 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)", | 129 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) dwt_set_enabled(%d)", |
@@ -124,34 +131,43 @@ static void sway_input_manager_libinput_config_pointer(struct sway_input_device | |||
124 | libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt); | 131 | libinput_device_config_dwt_set_enabled(libinput_device, ic->dwt); |
125 | } | 132 | } |
126 | if (ic->left_handed != INT_MIN) { | 133 | if (ic->left_handed != INT_MIN) { |
127 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) left_handed_set_enabled(%d)", | 134 | wlr_log(L_DEBUG, |
135 | "libinput_config_pointer(%s) left_handed_set_enabled(%d)", | ||
128 | ic->identifier, ic->left_handed); | 136 | ic->identifier, ic->left_handed); |
129 | libinput_device_config_left_handed_set(libinput_device, ic->left_handed); | 137 | libinput_device_config_left_handed_set(libinput_device, |
138 | ic->left_handed); | ||
130 | } | 139 | } |
131 | if (ic->middle_emulation != INT_MIN) { | 140 | if (ic->middle_emulation != INT_MIN) { |
132 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) middle_emulation_set_enabled(%d)", | 141 | wlr_log(L_DEBUG, |
142 | "libinput_config_pointer(%s) middle_emulation_set_enabled(%d)", | ||
133 | ic->identifier, ic->middle_emulation); | 143 | ic->identifier, ic->middle_emulation); |
134 | libinput_device_config_middle_emulation_set_enabled(libinput_device, ic->middle_emulation); | 144 | libinput_device_config_middle_emulation_set_enabled(libinput_device, |
145 | ic->middle_emulation); | ||
135 | } | 146 | } |
136 | if (ic->natural_scroll != INT_MIN) { | 147 | if (ic->natural_scroll != INT_MIN) { |
137 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) natural_scroll_set_enabled(%d)", | 148 | wlr_log(L_DEBUG, |
149 | "libinput_config_pointer(%s) natural_scroll_set_enabled(%d)", | ||
138 | ic->identifier, ic->natural_scroll); | 150 | ic->identifier, ic->natural_scroll); |
139 | libinput_device_config_scroll_set_natural_scroll_enabled(libinput_device, ic->natural_scroll); | 151 | libinput_device_config_scroll_set_natural_scroll_enabled( |
152 | libinput_device, ic->natural_scroll); | ||
140 | } | 153 | } |
141 | if (ic->pointer_accel != FLT_MIN) { | 154 | if (ic->pointer_accel != FLT_MIN) { |
142 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)", | 155 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) accel_set_speed(%f)", |
143 | ic->identifier, ic->pointer_accel); | 156 | ic->identifier, ic->pointer_accel); |
144 | libinput_device_config_accel_set_speed(libinput_device, ic->pointer_accel); | 157 | libinput_device_config_accel_set_speed(libinput_device, |
158 | ic->pointer_accel); | ||
145 | } | 159 | } |
146 | if (ic->scroll_method != INT_MIN) { | 160 | if (ic->scroll_method != INT_MIN) { |
147 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)", | 161 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) scroll_set_method(%d)", |
148 | ic->identifier, ic->scroll_method); | 162 | ic->identifier, ic->scroll_method); |
149 | libinput_device_config_scroll_set_method(libinput_device, ic->scroll_method); | 163 | libinput_device_config_scroll_set_method(libinput_device, |
164 | ic->scroll_method); | ||
150 | } | 165 | } |
151 | if (ic->send_events != INT_MIN) { | 166 | if (ic->send_events != INT_MIN) { |
152 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)", | 167 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) send_events_set_mode(%d)", |
153 | ic->identifier, ic->send_events); | 168 | ic->identifier, ic->send_events); |
154 | libinput_device_config_send_events_set_mode(libinput_device, ic->send_events); | 169 | libinput_device_config_send_events_set_mode(libinput_device, |
170 | ic->send_events); | ||
155 | } | 171 | } |
156 | if (ic->tap != INT_MIN) { | 172 | if (ic->tap != INT_MIN) { |
157 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)", | 173 | wlr_log(L_DEBUG, "libinput_config_pointer(%s) tap_set_enabled(%d)", |
@@ -175,12 +191,11 @@ static void handle_device_destroy(struct wl_listener *listener, void *data) { | |||
175 | 191 | ||
176 | struct sway_seat *seat = NULL; | 192 | struct sway_seat *seat = NULL; |
177 | wl_list_for_each(seat, &input_manager->seats, link) { | 193 | wl_list_for_each(seat, &input_manager->seats, link) { |
178 | sway_seat_remove_device(seat, input_device); | 194 | seat_remove_device(seat, input_device); |
179 | } | 195 | } |
180 | 196 | ||
181 | wl_list_remove(&input_device->link); | 197 | wl_list_remove(&input_device->link); |
182 | wl_list_remove(&input_device->device_destroy.link); | 198 | wl_list_remove(&input_device->device_destroy.link); |
183 | free_input_config(input_device->config); | ||
184 | free(input_device->identifier); | 199 | free(input_device->identifier); |
185 | free(input_device); | 200 | free(input_device); |
186 | } | 201 | } |
@@ -203,44 +218,36 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
203 | wlr_log(L_DEBUG, "adding device: '%s'", | 218 | wlr_log(L_DEBUG, "adding device: '%s'", |
204 | input_device->identifier); | 219 | input_device->identifier); |
205 | 220 | ||
206 | // find config | ||
207 | for (int i = 0; i < config->input_configs->length; ++i) { | ||
208 | struct input_config *input_config = config->input_configs->items[i]; | ||
209 | if (strcmp(input_config->identifier, input_device->identifier) == 0) { | ||
210 | free_input_config(input_device->config); | ||
211 | input_device->config = copy_input_config(input_config); | ||
212 | break; | ||
213 | } | ||
214 | } | ||
215 | |||
216 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { | 221 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { |
217 | sway_input_manager_libinput_config_pointer(input_device); | 222 | input_manager_libinput_config_pointer(input_device); |
218 | } | 223 | } |
219 | 224 | ||
220 | struct sway_seat *seat = NULL; | 225 | struct sway_seat *seat = NULL; |
221 | if (!input_has_seat_configuration(input)) { | 226 | if (!input_has_seat_configuration(input)) { |
222 | wlr_log(L_DEBUG, "no seat configuration, using default seat"); | 227 | wlr_log(L_DEBUG, "no seat configuration, using default seat"); |
223 | seat = input_manager_get_seat(input, default_seat); | 228 | seat = input_manager_get_seat(input, default_seat); |
224 | sway_seat_add_device(seat, input_device); | 229 | seat_add_device(seat, input_device); |
225 | return; | 230 | return; |
226 | } | 231 | } |
227 | 232 | ||
228 | bool added = false; | 233 | bool added = false; |
229 | wl_list_for_each(seat, &input->seats, link) { | 234 | wl_list_for_each(seat, &input->seats, link) { |
230 | bool has_attachment = seat->config && | 235 | struct seat_config *seat_config = seat_get_config(seat); |
231 | (seat_config_get_attachment(seat->config, input_device->identifier) || | 236 | bool has_attachment = seat_config && |
232 | seat_config_get_attachment(seat->config, "*")); | 237 | (seat_config_get_attachment(seat_config, input_device->identifier) || |
238 | seat_config_get_attachment(seat_config, "*")); | ||
233 | 239 | ||
234 | if (has_attachment) { | 240 | if (has_attachment) { |
235 | sway_seat_add_device(seat, input_device); | 241 | seat_add_device(seat, input_device); |
236 | added = true; | 242 | added = true; |
237 | } | 243 | } |
238 | } | 244 | } |
239 | 245 | ||
240 | if (!added) { | 246 | if (!added) { |
241 | wl_list_for_each(seat, &input->seats, link) { | 247 | wl_list_for_each(seat, &input->seats, link) { |
242 | if (seat->config && seat->config->fallback == 1) { | 248 | struct seat_config *seat_config = seat_get_config(seat); |
243 | sway_seat_add_device(seat, input_device); | 249 | if (seat_config && seat_config->fallback == 1) { |
250 | seat_add_device(seat, input_device); | ||
244 | added = true; | 251 | added = true; |
245 | } | 252 | } |
246 | } | 253 | } |
@@ -256,7 +263,7 @@ static void handle_new_input(struct wl_listener *listener, void *data) { | |||
256 | input_device->device_destroy.notify = handle_device_destroy; | 263 | input_device->device_destroy.notify = handle_device_destroy; |
257 | } | 264 | } |
258 | 265 | ||
259 | struct sway_input_manager *sway_input_manager_create( | 266 | struct sway_input_manager *input_manager_create( |
260 | struct sway_server *server) { | 267 | struct sway_server *server) { |
261 | struct sway_input_manager *input = | 268 | struct sway_input_manager *input = |
262 | calloc(1, sizeof(struct sway_input_manager)); | 269 | calloc(1, sizeof(struct sway_input_manager)); |
@@ -277,11 +284,11 @@ struct sway_input_manager *sway_input_manager_create( | |||
277 | return input; | 284 | return input; |
278 | } | 285 | } |
279 | 286 | ||
280 | bool sway_input_manager_has_focus(struct sway_input_manager *input, | 287 | bool input_manager_has_focus(struct sway_input_manager *input, |
281 | struct sway_container *container) { | 288 | struct sway_container *container) { |
282 | struct sway_seat *seat = NULL; | 289 | struct sway_seat *seat = NULL; |
283 | wl_list_for_each(seat, &input->seats, link) { | 290 | wl_list_for_each(seat, &input->seats, link) { |
284 | if (sway_seat_get_focus(seat) == container) { | 291 | if (seat_get_focus(seat) == container) { |
285 | return true; | 292 | return true; |
286 | } | 293 | } |
287 | } | 294 | } |
@@ -289,35 +296,32 @@ bool sway_input_manager_has_focus(struct sway_input_manager *input, | |||
289 | return false; | 296 | return false; |
290 | } | 297 | } |
291 | 298 | ||
292 | void sway_input_manager_set_focus(struct sway_input_manager *input, | 299 | void input_manager_set_focus(struct sway_input_manager *input, |
293 | struct sway_container *container) { | 300 | struct sway_container *container) { |
294 | struct sway_seat *seat ; | 301 | struct sway_seat *seat ; |
295 | wl_list_for_each(seat, &input->seats, link) { | 302 | wl_list_for_each(seat, &input->seats, link) { |
296 | sway_seat_set_focus(seat, container); | 303 | seat_set_focus(seat, container); |
297 | } | 304 | } |
298 | } | 305 | } |
299 | 306 | ||
300 | void sway_input_manager_apply_input_config(struct sway_input_manager *input, | 307 | void input_manager_apply_input_config(struct sway_input_manager *input, |
301 | struct input_config *input_config) { | 308 | struct input_config *input_config) { |
302 | struct sway_input_device *input_device = NULL; | 309 | struct sway_input_device *input_device = NULL; |
303 | wl_list_for_each(input_device, &input->devices, link) { | 310 | wl_list_for_each(input_device, &input->devices, link) { |
304 | if (strcmp(input_device->identifier, input_config->identifier) == 0) { | 311 | if (strcmp(input_device->identifier, input_config->identifier) == 0) { |
305 | free_input_config(input_device->config); | ||
306 | input_device->config = copy_input_config(input_config); | ||
307 | |||
308 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { | 312 | if (input_device->wlr_device->type == WLR_INPUT_DEVICE_POINTER) { |
309 | sway_input_manager_libinput_config_pointer(input_device); | 313 | input_manager_libinput_config_pointer(input_device); |
310 | } | 314 | } |
311 | 315 | ||
312 | struct sway_seat *seat = NULL; | 316 | struct sway_seat *seat = NULL; |
313 | wl_list_for_each(seat, &input->seats, link) { | 317 | wl_list_for_each(seat, &input->seats, link) { |
314 | sway_seat_configure_device(seat, input_device); | 318 | seat_configure_device(seat, input_device); |
315 | } | 319 | } |
316 | } | 320 | } |
317 | } | 321 | } |
318 | } | 322 | } |
319 | 323 | ||
320 | void sway_input_manager_apply_seat_config(struct sway_input_manager *input, | 324 | void input_manager_apply_seat_config(struct sway_input_manager *input, |
321 | struct seat_config *seat_config) { | 325 | struct seat_config *seat_config) { |
322 | wlr_log(L_DEBUG, "applying new seat config for seat %s", | 326 | wlr_log(L_DEBUG, "applying new seat config for seat %s", |
323 | seat_config->name); | 327 | seat_config->name); |
@@ -326,7 +330,7 @@ void sway_input_manager_apply_seat_config(struct sway_input_manager *input, | |||
326 | return; | 330 | return; |
327 | } | 331 | } |
328 | 332 | ||
329 | sway_seat_set_config(seat, seat_config); | 333 | seat_apply_config(seat, seat_config); |
330 | 334 | ||
331 | // for every device, try to add it to a seat and if no seat has it | 335 | // for every device, try to add it to a seat and if no seat has it |
332 | // attached, add it to the fallback seats. | 336 | // attached, add it to the fallback seats. |
@@ -335,11 +339,12 @@ void sway_input_manager_apply_seat_config(struct sway_input_manager *input, | |||
335 | list_t *seat_list = create_list(); | 339 | list_t *seat_list = create_list(); |
336 | struct sway_seat *seat = NULL; | 340 | struct sway_seat *seat = NULL; |
337 | wl_list_for_each(seat, &input->seats, link) { | 341 | wl_list_for_each(seat, &input->seats, link) { |
338 | if (!seat->config) { | 342 | struct seat_config *seat_config = seat_get_config(seat); |
343 | if (!seat_config) { | ||
339 | continue; | 344 | continue; |
340 | } | 345 | } |
341 | if (seat_config_get_attachment(seat->config, "*") || | 346 | if (seat_config_get_attachment(seat_config, "*") || |
342 | seat_config_get_attachment(seat->config, | 347 | seat_config_get_attachment(seat_config, |
343 | input_device->identifier)) { | 348 | input_device->identifier)) { |
344 | list_add(seat_list, seat); | 349 | list_add(seat_list, seat); |
345 | } | 350 | } |
@@ -355,17 +360,18 @@ void sway_input_manager_apply_seat_config(struct sway_input_manager *input, | |||
355 | } | 360 | } |
356 | } | 361 | } |
357 | if (attached) { | 362 | if (attached) { |
358 | sway_seat_add_device(seat, input_device); | 363 | seat_add_device(seat, input_device); |
359 | } else { | 364 | } else { |
360 | sway_seat_remove_device(seat, input_device); | 365 | seat_remove_device(seat, input_device); |
361 | } | 366 | } |
362 | } | 367 | } |
363 | } else { | 368 | } else { |
364 | wl_list_for_each(seat, &input->seats, link) { | 369 | wl_list_for_each(seat, &input->seats, link) { |
365 | if (seat->config && seat->config->fallback == 1) { | 370 | struct seat_config *seat_config = seat_get_config(seat); |
366 | sway_seat_add_device(seat, input_device); | 371 | if (seat_config && seat_config->fallback == 1) { |
372 | seat_add_device(seat, input_device); | ||
367 | } else { | 373 | } else { |
368 | sway_seat_remove_device(seat, input_device); | 374 | seat_remove_device(seat, input_device); |
369 | } | 375 | } |
370 | } | 376 | } |
371 | } | 377 | } |
@@ -373,14 +379,14 @@ void sway_input_manager_apply_seat_config(struct sway_input_manager *input, | |||
373 | } | 379 | } |
374 | } | 380 | } |
375 | 381 | ||
376 | void sway_input_manager_configure_xcursor(struct sway_input_manager *input) { | 382 | void input_manager_configure_xcursor(struct sway_input_manager *input) { |
377 | struct sway_seat *seat = NULL; | 383 | struct sway_seat *seat = NULL; |
378 | wl_list_for_each(seat, &input->seats, link) { | 384 | wl_list_for_each(seat, &input->seats, link) { |
379 | sway_seat_configure_xcursor(seat); | 385 | seat_configure_xcursor(seat); |
380 | } | 386 | } |
381 | } | 387 | } |
382 | 388 | ||
383 | struct sway_seat *sway_input_manager_get_default_seat( | 389 | struct sway_seat *input_manager_get_default_seat( |
384 | struct sway_input_manager *input) { | 390 | struct sway_input_manager *input) { |
385 | struct sway_seat *seat = NULL; | 391 | struct sway_seat *seat = NULL; |
386 | wl_list_for_each(seat, &input->seats, link) { | 392 | wl_list_for_each(seat, &input->seats, link) { |
@@ -390,3 +396,15 @@ struct sway_seat *sway_input_manager_get_default_seat( | |||
390 | } | 396 | } |
391 | return seat; | 397 | return seat; |
392 | } | 398 | } |
399 | |||
400 | struct input_config *input_device_get_config(struct sway_input_device *device) { | ||
401 | struct input_config *input_config = NULL; | ||
402 | for (int i = 0; i < config->input_configs->length; ++i) { | ||
403 | input_config = config->input_configs->items[i]; | ||
404 | if (strcmp(input_config->identifier, device->identifier) == 0) { | ||
405 | return input_config; | ||
406 | } | ||
407 | } | ||
408 | |||
409 | return NULL; | ||
410 | } | ||
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c index 8d22b684..dbb0c359 100644 --- a/sway/input/keyboard.c +++ b/sway/input/keyboard.c | |||
@@ -428,7 +428,7 @@ void sway_keyboard_configure(struct sway_keyboard *keyboard) { | |||
428 | struct xkb_rule_names rules; | 428 | struct xkb_rule_names rules; |
429 | memset(&rules, 0, sizeof(rules)); | 429 | memset(&rules, 0, sizeof(rules)); |
430 | struct input_config *input_config = | 430 | struct input_config *input_config = |
431 | keyboard->seat_device->input_device->config; | 431 | input_device_get_config(keyboard->seat_device->input_device); |
432 | struct wlr_input_device *wlr_device = | 432 | struct wlr_input_device *wlr_device = |
433 | keyboard->seat_device->input_device->wlr_device; | 433 | keyboard->seat_device->input_device->wlr_device; |
434 | 434 | ||
diff --git a/sway/input/seat.c b/sway/input/seat.c index 9aa34aca..27636c1e 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c | |||
@@ -25,7 +25,7 @@ static void seat_device_destroy(struct sway_seat_device *seat_device) { | |||
25 | free(seat_device); | 25 | free(seat_device); |
26 | } | 26 | } |
27 | 27 | ||
28 | void sway_seat_destroy(struct sway_seat *seat) { | 28 | void seat_destroy(struct sway_seat *seat) { |
29 | struct sway_seat_device *seat_device, *next; | 29 | struct sway_seat_device *seat_device, *next; |
30 | wl_list_for_each_safe(seat_device, next, &seat->devices, link) { | 30 | wl_list_for_each_safe(seat_device, next, &seat->devices, link) { |
31 | seat_device_destroy(seat_device); | 31 | seat_device_destroy(seat_device); |
@@ -42,18 +42,19 @@ static void handle_seat_container_destroy(struct wl_listener *listener, | |||
42 | struct sway_seat *seat = seat_con->seat; | 42 | struct sway_seat *seat = seat_con->seat; |
43 | struct sway_container *con = seat_con->container; | 43 | struct sway_container *con = seat_con->container; |
44 | 44 | ||
45 | bool is_focus = (sway_seat_get_focus(seat) == con); | 45 | bool is_focus = (seat_get_focus(seat) == con); |
46 | 46 | ||
47 | wl_list_remove(&seat_con->link); | 47 | wl_list_remove(&seat_con->link); |
48 | 48 | ||
49 | if (is_focus) { | 49 | if (is_focus) { |
50 | // pick next focus | 50 | // pick next focus |
51 | sway_seat_set_focus(seat, NULL); | 51 | seat_set_focus(seat, NULL); |
52 | struct sway_container *next = sway_seat_get_focus_inactive(seat, con->parent); | 52 | struct sway_container *next = |
53 | seat_get_focus_inactive(seat, con->parent); | ||
53 | if (next == NULL) { | 54 | if (next == NULL) { |
54 | next = con->parent; | 55 | next = con->parent; |
55 | } | 56 | } |
56 | sway_seat_set_focus(seat, next); | 57 | seat_set_focus(seat, next); |
57 | } | 58 | } |
58 | 59 | ||
59 | wl_list_remove(&seat_con->destroy.link); | 60 | wl_list_remove(&seat_con->destroy.link); |
@@ -110,7 +111,7 @@ static void collect_focus_iter(struct sway_container *con, void *data) { | |||
110 | wl_list_insert(&seat->focus_stack, &seat_con->link); | 111 | wl_list_insert(&seat->focus_stack, &seat_con->link); |
111 | } | 112 | } |
112 | 113 | ||
113 | struct sway_seat *sway_seat_create(struct sway_input_manager *input, | 114 | struct sway_seat *seat_create(struct sway_input_manager *input, |
114 | const char *seat_name) { | 115 | const char *seat_name) { |
115 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); | 116 | struct sway_seat *seat = calloc(1, sizeof(struct sway_seat)); |
116 | if (!seat) { | 117 | if (!seat) { |
@@ -133,7 +134,8 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
133 | // init the focus stack | 134 | // init the focus stack |
134 | wl_list_init(&seat->focus_stack); | 135 | wl_list_init(&seat->focus_stack); |
135 | 136 | ||
136 | container_for_each_descendant_dfs(&root_container, collect_focus_iter, seat); | 137 | container_for_each_descendant_dfs(&root_container, |
138 | collect_focus_iter, seat); | ||
137 | 139 | ||
138 | wl_signal_add(&root_container.sway_root->events.new_container, | 140 | wl_signal_add(&root_container.sway_root->events.new_container, |
139 | &seat->new_container); | 141 | &seat->new_container); |
@@ -147,7 +149,7 @@ struct sway_seat *sway_seat_create(struct sway_input_manager *input, | |||
147 | WL_SEAT_CAPABILITY_POINTER | | 149 | WL_SEAT_CAPABILITY_POINTER | |
148 | WL_SEAT_CAPABILITY_TOUCH); | 150 | WL_SEAT_CAPABILITY_TOUCH); |
149 | 151 | ||
150 | sway_seat_configure_xcursor(seat); | 152 | seat_configure_xcursor(seat); |
151 | 153 | ||
152 | wl_list_insert(&input->seats, &seat->link); | 154 | wl_list_insert(&input->seats, &seat->link); |
153 | 155 | ||
@@ -165,11 +167,12 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
165 | if (!seat_device->keyboard) { | 167 | if (!seat_device->keyboard) { |
166 | sway_keyboard_create(seat, seat_device); | 168 | sway_keyboard_create(seat, seat_device); |
167 | } | 169 | } |
168 | struct wlr_keyboard *wlr_keyboard = seat_device->input_device->wlr_device->keyboard; | 170 | struct wlr_keyboard *wlr_keyboard = |
171 | seat_device->input_device->wlr_device->keyboard; | ||
169 | sway_keyboard_configure(seat_device->keyboard); | 172 | sway_keyboard_configure(seat_device->keyboard); |
170 | wlr_seat_set_keyboard(seat->wlr_seat, | 173 | wlr_seat_set_keyboard(seat->wlr_seat, |
171 | seat_device->input_device->wlr_device); | 174 | seat_device->input_device->wlr_device); |
172 | struct sway_container *focus = sway_seat_get_focus(seat); | 175 | struct sway_container *focus = seat_get_focus(seat); |
173 | if (focus && focus->type == C_VIEW) { | 176 | if (focus && focus->type == C_VIEW) { |
174 | // force notify reenter to pick up the new configuration | 177 | // force notify reenter to pick up the new configuration |
175 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); | 178 | wlr_seat_keyboard_clear_focus(seat->wlr_seat); |
@@ -179,7 +182,7 @@ static void seat_configure_keyboard(struct sway_seat *seat, | |||
179 | } | 182 | } |
180 | } | 183 | } |
181 | 184 | ||
182 | static struct sway_seat_device *sway_seat_get_device(struct sway_seat *seat, | 185 | static struct sway_seat_device *seat_get_device(struct sway_seat *seat, |
183 | struct sway_input_device *input_device) { | 186 | struct sway_input_device *input_device) { |
184 | struct sway_seat_device *seat_device = NULL; | 187 | struct sway_seat_device *seat_device = NULL; |
185 | wl_list_for_each(seat_device, &seat->devices, link) { | 188 | wl_list_for_each(seat_device, &seat->devices, link) { |
@@ -191,19 +194,14 @@ static struct sway_seat_device *sway_seat_get_device(struct sway_seat *seat, | |||
191 | return NULL; | 194 | return NULL; |
192 | } | 195 | } |
193 | 196 | ||
194 | void sway_seat_configure_device(struct sway_seat *seat, | 197 | void seat_configure_device(struct sway_seat *seat, |
195 | struct sway_input_device *input_device) { | 198 | struct sway_input_device *input_device) { |
196 | struct sway_seat_device *seat_device = | 199 | struct sway_seat_device *seat_device = |
197 | sway_seat_get_device(seat, input_device); | 200 | seat_get_device(seat, input_device); |
198 | if (!seat_device) { | 201 | if (!seat_device) { |
199 | return; | 202 | return; |
200 | } | 203 | } |
201 | 204 | ||
202 | if (seat->config) { | ||
203 | seat_device->attachment_config = | ||
204 | seat_config_get_attachment(seat->config, input_device->identifier); | ||
205 | } | ||
206 | |||
207 | switch (input_device->wlr_device->type) { | 205 | switch (input_device->wlr_device->type) { |
208 | case WLR_INPUT_DEVICE_POINTER: | 206 | case WLR_INPUT_DEVICE_POINTER: |
209 | seat_configure_pointer(seat, seat_device); | 207 | seat_configure_pointer(seat, seat_device); |
@@ -219,10 +217,10 @@ void sway_seat_configure_device(struct sway_seat *seat, | |||
219 | } | 217 | } |
220 | } | 218 | } |
221 | 219 | ||
222 | void sway_seat_add_device(struct sway_seat *seat, | 220 | void seat_add_device(struct sway_seat *seat, |
223 | struct sway_input_device *input_device) { | 221 | struct sway_input_device *input_device) { |
224 | if (sway_seat_get_device(seat, input_device)) { | 222 | if (seat_get_device(seat, input_device)) { |
225 | sway_seat_configure_device(seat, input_device); | 223 | seat_configure_device(seat, input_device); |
226 | return; | 224 | return; |
227 | } | 225 | } |
228 | 226 | ||
@@ -240,13 +238,13 @@ void sway_seat_add_device(struct sway_seat *seat, | |||
240 | seat_device->input_device = input_device; | 238 | seat_device->input_device = input_device; |
241 | wl_list_insert(&seat->devices, &seat_device->link); | 239 | wl_list_insert(&seat->devices, &seat_device->link); |
242 | 240 | ||
243 | sway_seat_configure_device(seat, input_device); | 241 | seat_configure_device(seat, input_device); |
244 | } | 242 | } |
245 | 243 | ||
246 | void sway_seat_remove_device(struct sway_seat *seat, | 244 | void seat_remove_device(struct sway_seat *seat, |
247 | struct sway_input_device *input_device) { | 245 | struct sway_input_device *input_device) { |
248 | struct sway_seat_device *seat_device = | 246 | struct sway_seat_device *seat_device = |
249 | sway_seat_get_device(seat, input_device); | 247 | seat_get_device(seat, input_device); |
250 | 248 | ||
251 | if (!seat_device) { | 249 | if (!seat_device) { |
252 | return; | 250 | return; |
@@ -258,7 +256,7 @@ void sway_seat_remove_device(struct sway_seat *seat, | |||
258 | seat_device_destroy(seat_device); | 256 | seat_device_destroy(seat_device); |
259 | } | 257 | } |
260 | 258 | ||
261 | void sway_seat_configure_xcursor(struct sway_seat *seat) { | 259 | void seat_configure_xcursor(struct sway_seat *seat) { |
262 | // TODO configure theme and size | 260 | // TODO configure theme and size |
263 | const char *cursor_theme = NULL; | 261 | const char *cursor_theme = NULL; |
264 | 262 | ||
@@ -273,7 +271,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
273 | } | 271 | } |
274 | 272 | ||
275 | for (int i = 0; i < root_container.children->length; ++i) { | 273 | for (int i = 0; i < root_container.children->length; ++i) { |
276 | struct sway_container *output_container = root_container.children->items[i]; | 274 | struct sway_container *output_container = |
275 | root_container.children->items[i]; | ||
277 | struct wlr_output *output = | 276 | struct wlr_output *output = |
278 | output_container->sway_output->wlr_output; | 277 | output_container->sway_output->wlr_output; |
279 | bool result = | 278 | bool result = |
@@ -292,9 +291,9 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { | |||
292 | seat->cursor->cursor->y); | 291 | seat->cursor->cursor->y); |
293 | } | 292 | } |
294 | 293 | ||
295 | void sway_seat_set_focus_warp(struct sway_seat *seat, | 294 | void seat_set_focus_warp(struct sway_seat *seat, |
296 | struct sway_container *container, bool warp) { | 295 | struct sway_container *container, bool warp) { |
297 | struct sway_container *last_focus = sway_seat_get_focus(seat); | 296 | struct sway_container *last_focus = seat_get_focus(seat); |
298 | 297 | ||
299 | if (container && last_focus == container) { | 298 | if (container && last_focus == container) { |
300 | return; | 299 | return; |
@@ -364,7 +363,7 @@ void sway_seat_set_focus_warp(struct sway_seat *seat, | |||
364 | } | 363 | } |
365 | 364 | ||
366 | if (last_focus && last_focus->type == C_VIEW && | 365 | if (last_focus && last_focus->type == C_VIEW && |
367 | !sway_input_manager_has_focus(seat->input, last_focus)) { | 366 | !input_manager_has_focus(seat->input, last_focus)) { |
368 | struct sway_view *view = last_focus->sway_view; | 367 | struct sway_view *view = last_focus->sway_view; |
369 | view_set_activated(view, false); | 368 | view_set_activated(view, false); |
370 | } | 369 | } |
@@ -372,12 +371,13 @@ void sway_seat_set_focus_warp(struct sway_seat *seat, | |||
372 | seat->has_focus = (container != NULL); | 371 | seat->has_focus = (container != NULL); |
373 | } | 372 | } |
374 | 373 | ||
375 | void sway_seat_set_focus(struct sway_seat *seat, | 374 | void seat_set_focus(struct sway_seat *seat, |
376 | struct sway_container *container) { | 375 | struct sway_container *container) { |
377 | sway_seat_set_focus_warp(seat, container, true); | 376 | seat_set_focus_warp(seat, container, true); |
378 | } | 377 | } |
379 | 378 | ||
380 | struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, struct sway_container *container) { | 379 | struct sway_container *seat_get_focus_inactive(struct sway_seat *seat, |
380 | struct sway_container *container) { | ||
381 | struct sway_seat_container *current = NULL; | 381 | struct sway_seat_container *current = NULL; |
382 | struct sway_container *parent = NULL; | 382 | struct sway_container *parent = NULL; |
383 | wl_list_for_each(current, &seat->focus_stack, link) { | 383 | wl_list_for_each(current, &seat->focus_stack, link) { |
@@ -398,16 +398,17 @@ struct sway_container *sway_seat_get_focus_inactive(struct sway_seat *seat, stru | |||
398 | return NULL; | 398 | return NULL; |
399 | } | 399 | } |
400 | 400 | ||
401 | struct sway_container *sway_seat_get_focus(struct sway_seat *seat) { | 401 | struct sway_container *seat_get_focus(struct sway_seat *seat) { |
402 | if (!seat->has_focus) { | 402 | if (!seat->has_focus) { |
403 | return NULL; | 403 | return NULL; |
404 | } | 404 | } |
405 | return sway_seat_get_focus_inactive(seat, &root_container); | 405 | return seat_get_focus_inactive(seat, &root_container); |
406 | } | 406 | } |
407 | 407 | ||
408 | struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, | 408 | struct sway_container *seat_get_focus_by_type(struct sway_seat *seat, |
409 | enum sway_container_type type) { | 409 | enum sway_container_type type) { |
410 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | 410 | struct sway_container *focus = |
411 | seat_get_focus_inactive(seat, &root_container); | ||
411 | if (focus->type == type) { | 412 | if (focus->type == type) { |
412 | return focus; | 413 | return focus; |
413 | } | 414 | } |
@@ -415,25 +416,27 @@ struct sway_container *sway_seat_get_focus_by_type(struct sway_seat *seat, | |||
415 | return container_parent(focus, type); | 416 | return container_parent(focus, type); |
416 | } | 417 | } |
417 | 418 | ||
418 | void sway_seat_set_config(struct sway_seat *seat, | 419 | void seat_apply_config(struct sway_seat *seat, |
419 | struct seat_config *seat_config) { | 420 | struct seat_config *seat_config) { |
420 | // clear configs | ||
421 | free_seat_config(seat->config); | ||
422 | seat->config = NULL; | ||
423 | |||
424 | struct sway_seat_device *seat_device = NULL; | 421 | struct sway_seat_device *seat_device = NULL; |
425 | wl_list_for_each(seat_device, &seat->devices, link) { | ||
426 | seat_device->attachment_config = NULL; | ||
427 | } | ||
428 | 422 | ||
429 | if (!seat_config) { | 423 | if (!seat_config) { |
430 | return; | 424 | return; |
431 | } | 425 | } |
432 | 426 | ||
433 | // add configs | ||
434 | seat->config = copy_seat_config(seat_config); | ||
435 | |||
436 | wl_list_for_each(seat_device, &seat->devices, link) { | 427 | wl_list_for_each(seat_device, &seat->devices, link) { |
437 | sway_seat_configure_device(seat, seat_device->input_device); | 428 | seat_configure_device(seat, seat_device->input_device); |
438 | } | 429 | } |
439 | } | 430 | } |
431 | |||
432 | struct seat_config *seat_get_config(struct sway_seat *seat) { | ||
433 | struct seat_config *seat_config = NULL; | ||
434 | for (int i = 0; i < config->seat_configs->length; ++i ) { | ||
435 | seat_config = config->seat_configs->items[i]; | ||
436 | if (strcmp(seat->wlr_seat->name, seat_config->name) == 0) { | ||
437 | return seat_config; | ||
438 | } | ||
439 | } | ||
440 | |||
441 | return NULL; | ||
442 | } | ||
diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 7c5f7304..3427c8ec 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -88,11 +88,11 @@ static void ipc_json_describe_output(struct sway_container *container, json_obje | |||
88 | json_object_new_string( | 88 | json_object_new_string( |
89 | ipc_json_get_output_transform(wlr_output->transform))); | 89 | ipc_json_get_output_transform(wlr_output->transform))); |
90 | 90 | ||
91 | struct sway_seat *seat = sway_input_manager_get_default_seat(input_manager); | 91 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); |
92 | const char *ws = NULL; | 92 | const char *ws = NULL; |
93 | if (seat) { | 93 | if (seat) { |
94 | struct sway_container *focus = | 94 | struct sway_container *focus = |
95 | sway_seat_get_focus_inactive(seat, container); | 95 | seat_get_focus_inactive(seat, container); |
96 | if (focus && focus->type != C_WORKSPACE) { | 96 | if (focus && focus->type != C_WORKSPACE) { |
97 | focus = container_parent(focus, C_WORKSPACE); | 97 | focus = container_parent(focus, C_WORKSPACE); |
98 | } | 98 | } |
@@ -139,8 +139,8 @@ json_object *ipc_json_describe_container(struct sway_container *c) { | |||
139 | return NULL; | 139 | return NULL; |
140 | } | 140 | } |
141 | 141 | ||
142 | struct sway_seat *seat = sway_input_manager_get_default_seat(input_manager); | 142 | struct sway_seat *seat = input_manager_get_default_seat(input_manager); |
143 | bool focused = sway_seat_get_focus(seat) == c; | 143 | bool focused = seat_get_focus(seat) == c; |
144 | 144 | ||
145 | json_object *object = json_object_new_object(); | 145 | json_object *object = json_object_new_object(); |
146 | 146 | ||
diff --git a/sway/ipc-server.c b/sway/ipc-server.c index 869f1ed0..df5fb699 100644 --- a/sway/ipc-server.c +++ b/sway/ipc-server.c | |||
@@ -388,8 +388,8 @@ static void ipc_get_workspaces_callback(struct sway_container *workspace, | |||
388 | // override the default focused indicator because | 388 | // override the default focused indicator because |
389 | // it's set differently for the get_workspaces reply | 389 | // it's set differently for the get_workspaces reply |
390 | struct sway_seat *seat = | 390 | struct sway_seat *seat = |
391 | sway_input_manager_get_default_seat(input_manager); | 391 | input_manager_get_default_seat(input_manager); |
392 | struct sway_container *focused_ws = sway_seat_get_focus(seat); | 392 | struct sway_container *focused_ws = seat_get_focus(seat); |
393 | if (focused_ws != NULL && focused_ws->type != C_WORKSPACE) { | 393 | if (focused_ws != NULL && focused_ws->type != C_WORKSPACE) { |
394 | focused_ws = container_parent(focused_ws, C_WORKSPACE); | 394 | focused_ws = container_parent(focused_ws, C_WORKSPACE); |
395 | } | 395 | } |
@@ -399,7 +399,7 @@ static void ipc_get_workspaces_callback(struct sway_container *workspace, | |||
399 | json_object_new_boolean(focused)); | 399 | json_object_new_boolean(focused)); |
400 | json_object_array_add((json_object *)data, workspace_json); | 400 | json_object_array_add((json_object *)data, workspace_json); |
401 | 401 | ||
402 | focused_ws = sway_seat_get_focus_inactive(seat, workspace->parent); | 402 | focused_ws = seat_get_focus_inactive(seat, workspace->parent); |
403 | if (focused_ws->type != C_WORKSPACE) { | 403 | if (focused_ws->type != C_WORKSPACE) { |
404 | focused_ws = container_parent(focused_ws, C_WORKSPACE); | 404 | focused_ws = container_parent(focused_ws, C_WORKSPACE); |
405 | } | 405 | } |
diff --git a/sway/server.c b/sway/server.c index f5cc199c..54945312 100644 --- a/sway/server.c +++ b/sway/server.c | |||
@@ -109,7 +109,7 @@ bool server_init(struct sway_server *server) { | |||
109 | return false; | 109 | return false; |
110 | } | 110 | } |
111 | 111 | ||
112 | input_manager = sway_input_manager_create(server); | 112 | input_manager = input_manager_create(server); |
113 | return true; | 113 | return true; |
114 | } | 114 | } |
115 | 115 | ||
diff --git a/sway/tree/container.c b/sway/tree/container.c index 21fe3fb0..ea0b7d5c 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -162,7 +162,7 @@ struct sway_container *container_output_create( | |||
162 | struct sway_seat *seat = NULL; | 162 | struct sway_seat *seat = NULL; |
163 | wl_list_for_each(seat, &input_manager->seats, link) { | 163 | wl_list_for_each(seat, &input_manager->seats, link) { |
164 | if (!seat->has_focus) { | 164 | if (!seat->has_focus) { |
165 | sway_seat_set_focus(seat, ws); | 165 | seat_set_focus(seat, ws); |
166 | } | 166 | } |
167 | } | 167 | } |
168 | 168 | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index de210752..62ae0603 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -157,17 +157,17 @@ void container_move_to(struct sway_container *container, | |||
157 | } | 157 | } |
158 | wl_signal_emit(&container->events.reparent, old_parent); | 158 | wl_signal_emit(&container->events.reparent, old_parent); |
159 | if (container->type == C_WORKSPACE) { | 159 | if (container->type == C_WORKSPACE) { |
160 | struct sway_seat *seat = sway_input_manager_get_default_seat( | 160 | struct sway_seat *seat = input_manager_get_default_seat( |
161 | input_manager); | 161 | input_manager); |
162 | if (old_parent->children->length == 0) { | 162 | if (old_parent->children->length == 0) { |
163 | char *ws_name = workspace_next_name(old_parent->name); | 163 | char *ws_name = workspace_next_name(old_parent->name); |
164 | struct sway_container *ws = | 164 | struct sway_container *ws = |
165 | container_workspace_create(old_parent, ws_name); | 165 | container_workspace_create(old_parent, ws_name); |
166 | free(ws_name); | 166 | free(ws_name); |
167 | sway_seat_set_focus(seat, ws); | 167 | seat_set_focus(seat, ws); |
168 | } | 168 | } |
169 | container_sort_workspaces(new_parent); | 169 | container_sort_workspaces(new_parent); |
170 | sway_seat_set_focus(seat, new_parent); | 170 | seat_set_focus(seat, new_parent); |
171 | } | 171 | } |
172 | if (old_parent) { | 172 | if (old_parent) { |
173 | arrange_windows(old_parent, -1, -1); | 173 | arrange_windows(old_parent, -1, -1); |
@@ -430,7 +430,7 @@ static struct sway_container *get_swayc_in_output_direction( | |||
430 | return NULL; | 430 | return NULL; |
431 | } | 431 | } |
432 | 432 | ||
433 | struct sway_container *ws = sway_seat_get_focus_inactive(seat, output); | 433 | struct sway_container *ws = seat_get_focus_inactive(seat, output); |
434 | if (ws->type != C_WORKSPACE) { | 434 | if (ws->type != C_WORKSPACE) { |
435 | ws = container_parent(ws, C_WORKSPACE); | 435 | ws = container_parent(ws, C_WORKSPACE); |
436 | } | 436 | } |
@@ -451,7 +451,7 @@ static struct sway_container *get_swayc_in_output_direction( | |||
451 | case MOVE_UP: | 451 | case MOVE_UP: |
452 | case MOVE_DOWN: { | 452 | case MOVE_DOWN: { |
453 | struct sway_container *focused = | 453 | struct sway_container *focused = |
454 | sway_seat_get_focus_inactive(seat, ws); | 454 | seat_get_focus_inactive(seat, ws); |
455 | if (focused && focused->parent) { | 455 | if (focused && focused->parent) { |
456 | struct sway_container *parent = focused->parent; | 456 | struct sway_container *parent = focused->parent; |
457 | if (parent->layout == L_VERT) { | 457 | if (parent->layout == L_VERT) { |
@@ -535,7 +535,7 @@ static struct sway_container *get_swayc_in_direction_under( | |||
535 | struct sway_container *container, enum movement_direction dir, | 535 | struct sway_container *container, enum movement_direction dir, |
536 | struct sway_seat *seat, struct sway_container *limit) { | 536 | struct sway_seat *seat, struct sway_container *limit) { |
537 | if (dir == MOVE_CHILD) { | 537 | if (dir == MOVE_CHILD) { |
538 | return sway_seat_get_focus_inactive(seat, container); | 538 | return seat_get_focus_inactive(seat, container); |
539 | } | 539 | } |
540 | 540 | ||
541 | struct sway_container *parent = container->parent; | 541 | struct sway_container *parent = container->parent; |
@@ -595,7 +595,7 @@ static struct sway_container *get_swayc_in_direction_under( | |||
595 | } | 595 | } |
596 | if (next->children && next->children->length) { | 596 | if (next->children && next->children->length) { |
597 | // TODO consider floating children as well | 597 | // TODO consider floating children as well |
598 | return sway_seat_get_focus_inactive(seat, next); | 598 | return seat_get_focus_inactive(seat, next); |
599 | } else { | 599 | } else { |
600 | return next; | 600 | return next; |
601 | } | 601 | } |
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index de1bf159..74330884 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -158,7 +158,7 @@ static bool _workspace_by_name(struct sway_container *view, void *data) { | |||
158 | struct sway_container *workspace_by_name(const char *name) { | 158 | struct sway_container *workspace_by_name(const char *name) { |
159 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 159 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
160 | struct sway_container *current_workspace = NULL, *current_output = NULL; | 160 | struct sway_container *current_workspace = NULL, *current_output = NULL; |
161 | struct sway_container *focus = sway_seat_get_focus(seat); | 161 | struct sway_container *focus = seat_get_focus(seat); |
162 | if (focus) { | 162 | if (focus) { |
163 | current_workspace = container_parent(focus, C_WORKSPACE); | 163 | current_workspace = container_parent(focus, C_WORKSPACE); |
164 | current_output = container_parent(focus, C_OUTPUT); | 164 | current_output = container_parent(focus, C_OUTPUT); |
@@ -200,7 +200,7 @@ struct sway_container *workspace_create(const char *name) { | |||
200 | // Otherwise create a new one | 200 | // Otherwise create a new one |
201 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 201 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
202 | struct sway_container *focus = | 202 | struct sway_container *focus = |
203 | sway_seat_get_focus_inactive(seat, &root_container); | 203 | seat_get_focus_inactive(seat, &root_container); |
204 | parent = focus; | 204 | parent = focus; |
205 | parent = container_parent(parent, C_OUTPUT); | 205 | parent = container_parent(parent, C_OUTPUT); |
206 | struct sway_container *new_ws = container_workspace_create(parent, name); | 206 | struct sway_container *new_ws = container_workspace_create(parent, name); |
@@ -260,7 +260,7 @@ struct sway_container *workspace_output_prev_next_impl( | |||
260 | } | 260 | } |
261 | 261 | ||
262 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 262 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
263 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, output); | 263 | struct sway_container *focus = seat_get_focus_inactive(seat, output); |
264 | struct sway_container *workspace = (focus->type == C_WORKSPACE ? | 264 | struct sway_container *workspace = (focus->type == C_WORKSPACE ? |
265 | focus : | 265 | focus : |
266 | container_parent(focus, C_WORKSPACE)); | 266 | container_parent(focus, C_WORKSPACE)); |
@@ -345,7 +345,7 @@ bool workspace_switch(struct sway_container *workspace) { | |||
345 | } | 345 | } |
346 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 346 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
347 | struct sway_container *focus = | 347 | struct sway_container *focus = |
348 | sway_seat_get_focus_inactive(seat, &root_container); | 348 | seat_get_focus_inactive(seat, &root_container); |
349 | if (!seat || !focus) { | 349 | if (!seat || !focus) { |
350 | return false; | 350 | return false; |
351 | } | 351 | } |
@@ -376,11 +376,11 @@ bool workspace_switch(struct sway_container *workspace) { | |||
376 | 376 | ||
377 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", | 377 | wlr_log(L_DEBUG, "Switching to workspace %p:%s", |
378 | workspace, workspace->name); | 378 | workspace, workspace->name); |
379 | struct sway_container *next = sway_seat_get_focus_inactive(seat, workspace); | 379 | struct sway_container *next = seat_get_focus_inactive(seat, workspace); |
380 | if (next == NULL) { | 380 | if (next == NULL) { |
381 | next = workspace; | 381 | next = workspace; |
382 | } | 382 | } |
383 | sway_seat_set_focus(seat, next); | 383 | seat_set_focus(seat, next); |
384 | struct sway_container *output = container_parent(workspace, C_OUTPUT); | 384 | struct sway_container *output = container_parent(workspace, C_OUTPUT); |
385 | arrange_windows(output, -1, -1); | 385 | arrange_windows(output, -1, -1); |
386 | return true; | 386 | return true; |
@@ -389,7 +389,7 @@ bool workspace_switch(struct sway_container *workspace) { | |||
389 | bool workspace_is_visible(struct sway_container *ws) { | 389 | bool workspace_is_visible(struct sway_container *ws) { |
390 | struct sway_container *output = container_parent(ws, C_OUTPUT); | 390 | struct sway_container *output = container_parent(ws, C_OUTPUT); |
391 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 391 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
392 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, output); | 392 | struct sway_container *focus = seat_get_focus_inactive(seat, output); |
393 | if (focus->type != C_WORKSPACE) { | 393 | if (focus->type != C_WORKSPACE) { |
394 | focus = container_parent(focus, C_WORKSPACE); | 394 | focus = container_parent(focus, C_WORKSPACE); |
395 | } | 395 | } |