aboutsummaryrefslogtreecommitdiff
path: root/sway/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands.c')
-rw-r--r--sway/commands.c105
1 files changed, 78 insertions, 27 deletions
diff --git a/sway/commands.c b/sway/commands.c
index d6cf7a64..34afb6a0 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -9,6 +9,7 @@
#include "sway/commands.h"
#include "sway/config.h"
#include "sway/security.h"
+#include "sway/input/input-manager.h"
#include "stringop.h"
#include "log.h"
@@ -56,6 +57,40 @@ struct cmd_results *checkarg(int argc, const char *name, enum expected_args type
return error;
}
+void apply_input_config(struct input_config *input) {
+ int i;
+ i = list_seq_find(config->input_configs, input_identifier_cmp, input->identifier);
+ if (i >= 0) {
+ // merge existing config
+ struct input_config *ic = config->input_configs->items[i];
+ merge_input_config(ic, input);
+ free_input_config(input);
+ input = ic;
+ } else {
+ list_add(config->input_configs, input);
+ }
+
+ current_input_config = input;
+ sway_input_manager_apply_input_config(input_manager, input);
+}
+
+void apply_seat_config(struct seat_config *seat) {
+ int i;
+ i = list_seq_find(config->seat_configs, seat_name_cmp, seat->name);
+ if (i >= 0) {
+ // merge existing config
+ struct seat_config *sc = config->seat_configs->items[i];
+ merge_seat_config(sc, seat);
+ free_seat_config(seat);
+ seat = sc;
+ } else {
+ list_add(config->seat_configs, seat);
+ }
+
+ current_seat_config = seat;
+ sway_input_manager_apply_seat_config(input_manager, seat);
+}
+
/**
* Check and add color to buffer.
*
@@ -96,7 +131,9 @@ static struct cmd_handler handlers[] = {
{ "exec_always", cmd_exec_always },
{ "exit", cmd_exit },
{ "include", cmd_include },
+ { "input", cmd_input },
{ "output", cmd_output },
+ { "seat", cmd_seat },
};
static int handler_compare(const void *_a, const void *_b) {
@@ -105,37 +142,51 @@ static int handler_compare(const void *_a, const void *_b) {
return strcasecmp(a->command, b->command);
}
+// must be in order for the bsearch
+static struct cmd_handler input_handlers[] = {
+ { "accel_profile", input_cmd_accel_profile },
+ { "click_method", input_cmd_click_method },
+ { "drag_lock", input_cmd_drag_lock },
+ { "dwt", input_cmd_dwt },
+ { "events", input_cmd_events },
+ { "left_handed", input_cmd_left_handed },
+ { "middle_emulation", input_cmd_middle_emulation },
+ { "natural_scroll", input_cmd_natural_scroll },
+ { "pointer_accel", input_cmd_pointer_accel },
+ { "scroll_method", input_cmd_scroll_method },
+ { "tap", input_cmd_tap },
+ { "xkb_layout", input_cmd_xkb_layout },
+ { "xkb_model", input_cmd_xkb_model },
+ { "xkb_options", input_cmd_xkb_options },
+ { "xkb_rules", input_cmd_xkb_rules },
+ { "xkb_variant", input_cmd_xkb_variant },
+};
+
+// must be in order for the bsearch
+static struct cmd_handler seat_handlers[] = {
+ { "attach", seat_cmd_attach },
+ { "fallback", seat_cmd_fallback },
+};
+
static struct cmd_handler *find_handler(char *line, enum cmd_status block) {
struct cmd_handler d = { .command=line };
struct cmd_handler *res = NULL;
- sway_log(L_DEBUG, "find_handler(%s) %d", line, block == CMD_BLOCK_INPUT);
- /* TODO
- if (block == CMD_BLOCK_BAR) {
- res = bsearch(&d, bar_handlers,
- sizeof(bar_handlers) / sizeof(struct cmd_handler),
- sizeof(struct cmd_handler), handler_compare);
- } else if (block == CMD_BLOCK_BAR_COLORS){
- res = bsearch(&d, bar_colors_handlers,
- sizeof(bar_colors_handlers) / sizeof(struct cmd_handler),
- sizeof(struct cmd_handler), handler_compare);
- } else if (block == CMD_BLOCK_INPUT) {
+ sway_log(L_DEBUG, "find_handler(%s) %d", line, block == CMD_BLOCK_SEAT);
+
+ if (block == CMD_BLOCK_INPUT) {
res = bsearch(&d, input_handlers,
- sizeof(input_handlers) / sizeof(struct cmd_handler),
- sizeof(struct cmd_handler), handler_compare);
- } else if (block == CMD_BLOCK_IPC) {
- res = bsearch(&d, ipc_handlers,
- sizeof(ipc_handlers) / sizeof(struct cmd_handler),
- sizeof(struct cmd_handler), handler_compare);
- } else if (block == CMD_BLOCK_IPC_EVENTS) {
- res = bsearch(&d, ipc_event_handlers,
- sizeof(ipc_event_handlers) / sizeof(struct cmd_handler),
- sizeof(struct cmd_handler), handler_compare);
+ sizeof(input_handlers) / sizeof(struct cmd_handler),
+ sizeof(struct cmd_handler), handler_compare);
+ } else if (block == CMD_BLOCK_SEAT) {
+ res = bsearch(&d, seat_handlers,
+ sizeof(seat_handlers) / sizeof(struct cmd_handler),
+ sizeof(struct cmd_handler), handler_compare);
} else {
- */
res = bsearch(&d, handlers,
- sizeof(handlers) / sizeof(struct cmd_handler),
- sizeof(struct cmd_handler), handler_compare);
- //}
+ sizeof(handlers) / sizeof(struct cmd_handler),
+ sizeof(struct cmd_handler), handler_compare);
+ }
+
return res;
}
@@ -239,8 +290,8 @@ struct cmd_results *config_command(char *exec, enum cmd_status block) {
argv[i] = do_var_replacement(argv[i]);
unescape_string(argv[i]);
}
- /* Strip quotes for first argument.
- * TODO This part needs to be handled much better */
+ // Strip quotes for first argument.
+ // TODO This part needs to be handled much better
if (argc>1 && (*argv[1] == '\"' || *argv[1] == '\'')) {
strip_quotes(argv[1]);
}