aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/commands/seat.c52
1 files changed, 37 insertions, 15 deletions
diff --git a/sway/commands/seat.c b/sway/commands/seat.c
index a827bf74..197a405e 100644
--- a/sway/commands/seat.c
+++ b/sway/commands/seat.c
@@ -7,15 +7,45 @@
7#include "stringop.h" 7#include "stringop.h"
8 8
9// must be in order for the bsearch 9// must be in order for the bsearch
10// these handlers perform actions on the seat
11static struct cmd_handler seat_action_handlers[] = {
12 { "cursor", seat_cmd_cursor },
13};
14
15// must be in order for the bsearch
16// these handlers alter the seat config
10static struct cmd_handler seat_handlers[] = { 17static struct cmd_handler seat_handlers[] = {
11 { "attach", seat_cmd_attach }, 18 { "attach", seat_cmd_attach },
12 { "cursor", seat_cmd_cursor },
13 { "fallback", seat_cmd_fallback }, 19 { "fallback", seat_cmd_fallback },
14 { "hide_cursor", seat_cmd_hide_cursor }, 20 { "hide_cursor", seat_cmd_hide_cursor },
15 { "pointer_constraint", seat_cmd_pointer_constraint }, 21 { "pointer_constraint", seat_cmd_pointer_constraint },
16 { "xcursor_theme", seat_cmd_xcursor_theme }, 22 { "xcursor_theme", seat_cmd_xcursor_theme },
17}; 23};
18 24
25static struct cmd_results *action_handlers(int argc, char **argv) {
26 struct cmd_results *res = config_subcommand(argv, argc,
27 seat_action_handlers, sizeof(seat_action_handlers));
28 free_seat_config(config->handler_context.seat_config);
29 config->handler_context.seat_config = NULL;
30 return res;
31}
32
33static struct cmd_results *config_handlers(int argc, char **argv) {
34 struct cmd_results *res = config_subcommand(argv, argc,
35 seat_handlers, sizeof(seat_handlers));
36 if (res && res->status != CMD_SUCCESS) {
37 free_seat_config(config->handler_context.seat_config);
38 } else {
39 struct seat_config *sc =
40 store_seat_config(config->handler_context.seat_config);
41 if (!config->reading) {
42 input_manager_apply_seat_config(sc);
43 }
44 }
45 config->handler_context.seat_config = NULL;
46 return res;
47}
48
19struct cmd_results *cmd_seat(int argc, char **argv) { 49struct cmd_results *cmd_seat(int argc, char **argv) {
20 struct cmd_results *error = NULL; 50 struct cmd_results *error = NULL;
21 if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 2))) { 51 if ((error = checkarg(argc, "seat", EXPECTED_AT_LEAST, 2))) {
@@ -36,20 +66,12 @@ struct cmd_results *cmd_seat(int argc, char **argv) {
36 return cmd_results_new(CMD_FAILURE, "Couldn't allocate config"); 66 return cmd_results_new(CMD_FAILURE, "Couldn't allocate config");
37 } 67 }
38 68
39 struct cmd_results *res = config_subcommand(argv + 1, argc - 1, 69 struct cmd_results *res = NULL;
40 seat_handlers, sizeof(seat_handlers)); 70 if (find_handler(argv[1], seat_action_handlers,
41 if (res && res->status != CMD_SUCCESS) { 71 sizeof(seat_action_handlers))) {
42 free_seat_config(config->handler_context.seat_config); 72 res = action_handlers(argc - 1, argv + 1);
43 config->handler_context.seat_config = NULL; 73 } else {
44 return res; 74 res = config_handlers(argc - 1, argv + 1);
45 }
46
47 struct seat_config *sc =
48 store_seat_config(config->handler_context.seat_config);
49 if (!config->reading) {
50 input_manager_apply_seat_config(sc);
51 } 75 }
52
53 config->handler_context.seat_config = NULL;
54 return res ? res : cmd_results_new(CMD_SUCCESS, NULL); 76 return res ? res : cmd_results_new(CMD_SUCCESS, NULL);
55} 77}