diff options
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/seat.c | 13 | ||||
-rw-r--r-- | sway/commands/seat/attach.c | 21 | ||||
-rw-r--r-- | sway/commands/seat/fallback.c | 19 |
3 files changed, 23 insertions, 30 deletions
diff --git a/sway/commands/seat.c b/sway/commands/seat.c index 5abb19b0..56acd204 100644 --- a/sway/commands/seat.c +++ b/sway/commands/seat.c | |||
@@ -26,9 +26,16 @@ struct cmd_results *cmd_seat(int argc, char **argv) { | |||
26 | 26 | ||
27 | struct cmd_results *res = config_subcommand(argv + 1, argc - 1, | 27 | struct cmd_results *res = config_subcommand(argv + 1, argc - 1, |
28 | seat_handlers, sizeof(seat_handlers)); | 28 | seat_handlers, sizeof(seat_handlers)); |
29 | if (res && res->status != CMD_SUCCESS) { | ||
30 | free_seat_config(config->handler_context.seat_config); | ||
31 | config->handler_context.seat_config = NULL; | ||
32 | return res; | ||
33 | } | ||
29 | 34 | ||
30 | free_seat_config(config->handler_context.seat_config); | 35 | struct seat_config *sc = |
31 | config->handler_context.seat_config = NULL; | 36 | store_seat_config(config->handler_context.seat_config); |
37 | input_manager_apply_seat_config(sc); | ||
32 | 38 | ||
33 | return res; | 39 | config->handler_context.seat_config = NULL; |
40 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
34 | } | 41 | } |
diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c index 8d646c2d..0fb17f1d 100644 --- a/sway/commands/seat/attach.c +++ b/sway/commands/seat/attach.c | |||
@@ -1,10 +1,7 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | 1 | #define _POSIX_C_SOURCE 200809L |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include <strings.h> | ||
4 | #include "sway/input/input-manager.h" | ||
5 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
6 | #include "sway/config.h" | 4 | #include "sway/config.h" |
7 | #include "log.h" | ||
8 | #include "stringop.h" | 5 | #include "stringop.h" |
9 | 6 | ||
10 | struct cmd_results *seat_cmd_attach(int argc, char **argv) { | 7 | struct cmd_results *seat_cmd_attach(int argc, char **argv) { |
@@ -12,19 +9,17 @@ struct cmd_results *seat_cmd_attach(int argc, char **argv) { | |||
12 | if ((error = checkarg(argc, "attach", EXPECTED_AT_LEAST, 1))) { | 9 | if ((error = checkarg(argc, "attach", EXPECTED_AT_LEAST, 1))) { |
13 | return error; | 10 | return error; |
14 | } | 11 | } |
15 | struct seat_config *current_seat_config = | 12 | if (!config->handler_context.seat_config) { |
16 | config->handler_context.seat_config; | ||
17 | if (!current_seat_config) { | ||
18 | return cmd_results_new(CMD_FAILURE, "attach", "No seat defined"); | 13 | return cmd_results_new(CMD_FAILURE, "attach", "No seat defined"); |
19 | } | 14 | } |
20 | 15 | ||
21 | struct seat_config *new_config = new_seat_config(current_seat_config->name); | 16 | struct seat_attachment_config *attachment = seat_attachment_config_new(); |
22 | struct seat_attachment_config *new_attachment = seat_attachment_config_new(); | 17 | if (!attachment) { |
23 | new_attachment->identifier = strdup(argv[0]); | 18 | return cmd_results_new(CMD_FAILURE, "attach", |
24 | list_add(new_config->attachments, new_attachment); | 19 | "Failed to allocate seat attachment config"); |
25 | |||
26 | if (!config->validating) { | ||
27 | apply_seat_config(new_config); | ||
28 | } | 20 | } |
21 | attachment->identifier = strdup(argv[0]); | ||
22 | list_add(config->handler_context.seat_config->attachments, attachment); | ||
23 | |||
29 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
30 | } | 25 | } |
diff --git a/sway/commands/seat/fallback.c b/sway/commands/seat/fallback.c index a0ddf3ef..8f1ab12c 100644 --- a/sway/commands/seat/fallback.c +++ b/sway/commands/seat/fallback.c | |||
@@ -1,27 +1,18 @@ | |||
1 | #include <string.h> | ||
2 | #include <strings.h> | ||
3 | #include "sway/config.h" | 1 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | ||
6 | #include "util.h" | 3 | #include "util.h" |
7 | 4 | ||
8 | struct cmd_results *seat_cmd_fallback(int argc, char **argv) { | 5 | struct cmd_results *seat_cmd_fallback(int argc, char **argv) { |
9 | struct cmd_results *error = NULL; | 6 | struct cmd_results *error = NULL; |
10 | if ((error = checkarg(argc, "fallback", EXPECTED_AT_LEAST, 1))) { | 7 | if ((error = checkarg(argc, "fallback", EXPECTED_EQUAL_TO, 1))) { |
11 | return error; | 8 | return error; |
12 | } | 9 | } |
13 | struct seat_config *current_seat_config = | 10 | if (!config->handler_context.seat_config) { |
14 | config->handler_context.seat_config; | ||
15 | if (!current_seat_config) { | ||
16 | return cmd_results_new(CMD_FAILURE, "fallback", "No seat defined"); | 11 | return cmd_results_new(CMD_FAILURE, "fallback", "No seat defined"); |
17 | } | 12 | } |
18 | struct seat_config *new_config = | ||
19 | new_seat_config(current_seat_config->name); | ||
20 | |||
21 | new_config->fallback = parse_boolean(argv[0], false); | ||
22 | 13 | ||
23 | if (!config->validating) { | 14 | config->handler_context.seat_config->fallback = |
24 | apply_seat_config(new_config); | 15 | parse_boolean(argv[0], false); |
25 | } | 16 | |
26 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 17 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
27 | } | 18 | } |