diff options
author | Drew DeVault <sir@cmpwn.com> | 2018-10-19 14:00:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-19 14:00:03 +0200 |
commit | 96e3686ae882818edc35a14c207dfd97c40366d9 (patch) | |
tree | 2b898904e8c1e43417bfa92568bff23545ff642d /sway/commands | |
parent | 19adc3ff2dc262ade0bc1a87895e49696224d5d0 (diff) | |
parent | 2e637b7368de565a85f77fbd03408f33b763dd7b (diff) |
Merge pull request #2875 from RedSoxFan/input-device-bindings
cmd_bind{sym,code}: Implement per-device bindings
Diffstat (limited to 'sway/commands')
-rw-r--r-- | sway/commands/bind.c | 14 | ||||
-rw-r--r-- | sway/commands/seat/cursor.c | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/sway/commands/bind.c b/sway/commands/bind.c index 701d9746..5832d01e 100644 --- a/sway/commands/bind.c +++ b/sway/commands/bind.c @@ -26,6 +26,7 @@ void free_sway_binding(struct sway_binding *binding) { if (binding->keys) { free_flat_list(binding->keys); } + free(binding->input); free(binding->command); free(binding); } @@ -37,6 +38,10 @@ void free_sway_binding(struct sway_binding *binding) { */ static bool binding_key_compare(struct sway_binding *binding_a, struct sway_binding *binding_b) { + if (strcmp(binding_a->input, binding_b->input) != 0) { + return false; + } + if (binding_a->type != binding_b->type) { return false; } @@ -149,6 +154,7 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, return cmd_results_new(CMD_FAILURE, bindtype, "Unable to allocate binding"); } + binding->input = strdup("*"); binding->keys = create_list(); binding->modifiers = 0; binding->flags = 0; @@ -168,6 +174,10 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, binding->flags |= BINDING_BORDER; } else if (strcmp("--exclude-titlebar", argv[0]) == 0) { exclude_titlebar = true; + } else if (strncmp("--input-device=", argv[0], + strlen("--input-device=")) == 0) { + free(binding->input); + binding->input = strdup(argv[0] + strlen("--input-device=")); } else { break; } @@ -257,8 +267,8 @@ static struct cmd_results *cmd_bindsym_or_bindcode(int argc, char **argv, list_add(mode_bindings, binding); } - wlr_log(WLR_DEBUG, "%s - Bound %s to command %s", - bindtype, argv[0], binding->command); + wlr_log(WLR_DEBUG, "%s - Bound %s to command `%s` for device '%s'", + bindtype, argv[0], binding->command, binding->input); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index cd6630e0..595e9bc6 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c @@ -80,6 +80,6 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor, return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); } } - dispatch_cursor_button(cursor, 0, button, state); + dispatch_cursor_button(cursor, NULL, 0, button, state); return cmd_results_new(CMD_SUCCESS, NULL, NULL); } |