diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-14 11:11:56 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-14 11:11:56 -0500 |
commit | 92fef27eaa0b52c9d37bdabff14ae21cd6660f46 (patch) | |
tree | 7a923bbbc233079006597d82721117bae88b6ac6 /sway/commands.c | |
parent | seat configuration (diff) | |
download | sway-92fef27eaa0b52c9d37bdabff14ae21cd6660f46.tar.gz sway-92fef27eaa0b52c9d37bdabff14ae21cd6660f46.tar.zst sway-92fef27eaa0b52c9d37bdabff14ae21cd6660f46.zip |
basic configuration
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/sway/commands.c b/sway/commands.c index 6645436a..e003e06d 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -71,7 +71,24 @@ void input_cmd_apply(struct input_config *input) { | |||
71 | } | 71 | } |
72 | 72 | ||
73 | current_input_config = input; | 73 | current_input_config = input; |
74 | sway_input_manager_apply_config(input_manager, input); | 74 | sway_input_manager_apply_input_config(input_manager, input); |
75 | } | ||
76 | |||
77 | void seat_cmd_apply(struct seat_config *seat) { | ||
78 | int i; | ||
79 | i = list_seq_find(config->seat_configs, seat_name_cmp, seat->name); | ||
80 | if (i >= 0) { | ||
81 | // merge existing config | ||
82 | struct seat_config *sc = config->seat_configs->items[i]; | ||
83 | merge_seat_config(sc, seat); | ||
84 | free_seat_config(seat); | ||
85 | seat = sc; | ||
86 | } else { | ||
87 | list_add(config->seat_configs, seat); | ||
88 | } | ||
89 | |||
90 | current_seat_config = seat; | ||
91 | sway_input_manager_apply_seat_config(input_manager, seat); | ||
75 | } | 92 | } |
76 | 93 | ||
77 | /** | 94 | /** |
@@ -115,6 +132,7 @@ static struct cmd_handler handlers[] = { | |||
115 | { "exit", cmd_exit }, | 132 | { "exit", cmd_exit }, |
116 | { "include", cmd_include }, | 133 | { "include", cmd_include }, |
117 | { "input", cmd_input }, | 134 | { "input", cmd_input }, |
135 | { "seat", cmd_seat }, | ||
118 | }; | 136 | }; |
119 | 137 | ||
120 | static int handler_compare(const void *_a, const void *_b) { | 138 | static int handler_compare(const void *_a, const void *_b) { |
@@ -135,19 +153,27 @@ static struct cmd_handler input_handlers[] = { | |||
135 | { "natural_scroll", input_cmd_natural_scroll }, | 153 | { "natural_scroll", input_cmd_natural_scroll }, |
136 | { "pointer_accel", input_cmd_pointer_accel }, | 154 | { "pointer_accel", input_cmd_pointer_accel }, |
137 | { "scroll_method", input_cmd_scroll_method }, | 155 | { "scroll_method", input_cmd_scroll_method }, |
138 | { "seat", input_cmd_seat }, | ||
139 | { "tap", input_cmd_tap }, | 156 | { "tap", input_cmd_tap }, |
140 | }; | 157 | }; |
141 | 158 | ||
159 | // must be in order for the bsearch | ||
160 | static struct cmd_handler seat_handlers[] = { | ||
161 | { "attach", seat_cmd_attach }, | ||
162 | }; | ||
163 | |||
142 | static struct cmd_handler *find_handler(char *line, enum cmd_status block) { | 164 | static struct cmd_handler *find_handler(char *line, enum cmd_status block) { |
143 | struct cmd_handler d = { .command=line }; | 165 | struct cmd_handler d = { .command=line }; |
144 | struct cmd_handler *res = NULL; | 166 | struct cmd_handler *res = NULL; |
145 | sway_log(L_DEBUG, "find_handler(%s) %d", line, block == CMD_BLOCK_INPUT); | 167 | sway_log(L_DEBUG, "find_handler(%s) %d", line, block == CMD_BLOCK_SEAT); |
146 | 168 | ||
147 | if (block == CMD_BLOCK_INPUT) { | 169 | if (block == CMD_BLOCK_INPUT) { |
148 | res = bsearch(&d, input_handlers, | 170 | res = bsearch(&d, input_handlers, |
149 | sizeof(input_handlers) / sizeof(struct cmd_handler), | 171 | sizeof(input_handlers) / sizeof(struct cmd_handler), |
150 | sizeof(struct cmd_handler), handler_compare); | 172 | sizeof(struct cmd_handler), handler_compare); |
173 | } else if (block == CMD_BLOCK_SEAT) { | ||
174 | res = bsearch(&d, seat_handlers, | ||
175 | sizeof(seat_handlers) / sizeof(struct cmd_handler), | ||
176 | sizeof(struct cmd_handler), handler_compare); | ||
151 | } else { | 177 | } else { |
152 | res = bsearch(&d, handlers, | 178 | res = bsearch(&d, handlers, |
153 | sizeof(handlers) / sizeof(struct cmd_handler), | 179 | sizeof(handlers) / sizeof(struct cmd_handler), |