diff options
author | Cole Mickens <cole.mickens@gmail.com> | 2016-01-17 02:53:37 -0800 |
---|---|---|
committer | Cole Mickens <cole.mickens@gmail.com> | 2016-01-19 06:51:36 -0800 |
commit | 28081b76891ddbbb825dee6c202037d78aa8f164 (patch) | |
tree | 6b7412f626f5d9f10dba8920a2543dfd3c5a662e /sway/config.c | |
parent | Add ffmpeg/imagemagick to depenency list (diff) | |
download | sway-28081b76891ddbbb825dee6c202037d78aa8f164.tar.gz sway-28081b76891ddbbb825dee6c202037d78aa8f164.tar.zst sway-28081b76891ddbbb825dee6c202037d78aa8f164.zip |
libinput
Diffstat (limited to 'sway/config.c')
-rw-r--r-- | sway/config.c | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/sway/config.c b/sway/config.c index ae6a02b1..debd480a 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -6,6 +6,9 @@ | |||
6 | #include <sys/types.h> | 6 | #include <sys/types.h> |
7 | #include <sys/wait.h> | 7 | #include <sys/wait.h> |
8 | #include <signal.h> | 8 | #include <signal.h> |
9 | #include <libinput.h> | ||
10 | #include <limits.h> | ||
11 | #include <float.h> | ||
9 | #include "wayland-desktop-shell-server-protocol.h" | 12 | #include "wayland-desktop-shell-server-protocol.h" |
10 | #include "readline.h" | 13 | #include "readline.h" |
11 | #include "stringop.h" | 14 | #include "stringop.h" |
@@ -16,6 +19,7 @@ | |||
16 | #include "layout.h" | 19 | #include "layout.h" |
17 | #include "input_state.h" | 20 | #include "input_state.h" |
18 | #include "criteria.h" | 21 | #include "criteria.h" |
22 | #include "input.h" | ||
19 | 23 | ||
20 | struct sway_config *config = NULL; | 24 | struct sway_config *config = NULL; |
21 | 25 | ||
@@ -59,6 +63,11 @@ static void free_bar(struct bar_config *bar) { | |||
59 | free(bar); | 63 | free(bar); |
60 | } | 64 | } |
61 | 65 | ||
66 | void free_input_config(struct input_config *ic) { | ||
67 | free(ic->identifier); | ||
68 | free(ic); | ||
69 | } | ||
70 | |||
62 | void free_output_config(struct output_config *oc) { | 71 | void free_output_config(struct output_config *oc) { |
63 | free(oc->name); | 72 | free(oc->name); |
64 | free(oc); | 73 | free(oc); |
@@ -99,6 +108,11 @@ static void free_config(struct sway_config *config) { | |||
99 | } | 108 | } |
100 | list_free(config->criteria); | 109 | list_free(config->criteria); |
101 | 110 | ||
111 | for (i = 0; i < config->input_configs->length; ++i) { | ||
112 | free_input_config(config->input_configs->items[i]); | ||
113 | } | ||
114 | list_free(config->input_configs); | ||
115 | |||
102 | for (i = 0; i < config->output_configs->length; ++i) { | 116 | for (i = 0; i < config->output_configs->length; ++i) { |
103 | free_output_config(config->output_configs->items[i]); | 117 | free_output_config(config->output_configs->items[i]); |
104 | } | 118 | } |
@@ -119,6 +133,7 @@ static void config_defaults(struct sway_config *config) { | |||
119 | config->bars = create_list(); | 133 | config->bars = create_list(); |
120 | config->workspace_outputs = create_list(); | 134 | config->workspace_outputs = create_list(); |
121 | config->criteria = create_list(); | 135 | config->criteria = create_list(); |
136 | config->input_configs = create_list(); | ||
122 | config->output_configs = create_list(); | 137 | config->output_configs = create_list(); |
123 | 138 | ||
124 | config->cmd_queue = create_list(); | 139 | config->cmd_queue = create_list(); |
@@ -294,6 +309,14 @@ bool read_config(FILE *file, bool is_active) { | |||
294 | } | 309 | } |
295 | break; | 310 | break; |
296 | 311 | ||
312 | case CMD_BLOCK_INPUT: | ||
313 | if (block == CMD_BLOCK_END) { | ||
314 | block = CMD_BLOCK_INPUT; | ||
315 | } else { | ||
316 | sway_log(L_ERROR, "Invalid block '%s'", line); | ||
317 | } | ||
318 | break; | ||
319 | |||
297 | case CMD_BLOCK_BAR: | 320 | case CMD_BLOCK_BAR: |
298 | if (block == CMD_BLOCK_END) { | 321 | if (block == CMD_BLOCK_END) { |
299 | block = CMD_BLOCK_BAR; | 322 | block = CMD_BLOCK_BAR; |
@@ -318,6 +341,12 @@ bool read_config(FILE *file, bool is_active) { | |||
318 | block = CMD_BLOCK_END; | 341 | block = CMD_BLOCK_END; |
319 | break; | 342 | break; |
320 | 343 | ||
344 | case CMD_BLOCK_INPUT: | ||
345 | sway_log(L_DEBUG, "End of input block"); | ||
346 | current_input_config = NULL; | ||
347 | block = CMD_BLOCK_END; | ||
348 | break; | ||
349 | |||
321 | case CMD_BLOCK_BAR: | 350 | case CMD_BLOCK_BAR: |
322 | sway_log(L_DEBUG, "End of bar block"); | 351 | sway_log(L_DEBUG, "End of bar block"); |
323 | config->current_bar = NULL; | 352 | config->current_bar = NULL; |
@@ -353,6 +382,12 @@ bool read_config(FILE *file, bool is_active) { | |||
353 | return success; | 382 | return success; |
354 | } | 383 | } |
355 | 384 | ||
385 | int input_identifier_cmp(const void *item, const void *data) { | ||
386 | const struct input_config *ic = item; | ||
387 | const char *identifier = data; | ||
388 | return strcmp(ic->identifier, identifier); | ||
389 | } | ||
390 | |||
356 | int output_name_cmp(const void *item, const void *data) { | 391 | int output_name_cmp(const void *item, const void *data) { |
357 | const struct output_config *output = item; | 392 | const struct output_config *output = item; |
358 | const char *name = data; | 393 | const char *name = data; |
@@ -360,6 +395,42 @@ int output_name_cmp(const void *item, const void *data) { | |||
360 | return strcmp(output->name, name); | 395 | return strcmp(output->name, name); |
361 | } | 396 | } |
362 | 397 | ||
398 | void merge_input_config(struct input_config *dst, struct input_config *src) { | ||
399 | if (src->identifier) { | ||
400 | if (dst->identifier) { | ||
401 | free(dst->identifier); | ||
402 | } | ||
403 | dst->identifier = strdup(src->identifier); | ||
404 | } | ||
405 | if (src->click_method != INT_MIN) { | ||
406 | dst->click_method = src->click_method; | ||
407 | } | ||
408 | if (src->drag_lock != INT_MIN) { | ||
409 | dst->drag_lock = src->drag_lock; | ||
410 | } | ||
411 | if (src->dwt != INT_MIN) { | ||
412 | dst->dwt = src->dwt; | ||
413 | } | ||
414 | if (src->middle_emulation != INT_MIN) { | ||
415 | dst->middle_emulation = src->middle_emulation; | ||
416 | } | ||
417 | if (src->natural_scroll != INT_MIN) { | ||
418 | dst->natural_scroll = src->natural_scroll; | ||
419 | } | ||
420 | if (src->pointer_accel != FLT_MIN) { | ||
421 | dst->pointer_accel = src->pointer_accel; | ||
422 | } | ||
423 | if (src->scroll_method != INT_MIN) { | ||
424 | dst->scroll_method = src->scroll_method; | ||
425 | } | ||
426 | if (src->send_events != INT_MIN) { | ||
427 | dst->send_events = src->send_events; | ||
428 | } | ||
429 | if (src->tap != INT_MIN) { | ||
430 | dst->tap = src->tap; | ||
431 | } | ||
432 | } | ||
433 | |||
363 | void merge_output_config(struct output_config *dst, struct output_config *src) { | 434 | void merge_output_config(struct output_config *dst, struct output_config *src) { |
364 | if (src->name) { | 435 | if (src->name) { |
365 | if (dst->name) { | 436 | if (dst->name) { |
@@ -508,6 +579,51 @@ void load_swaybars(swayc_t *output, int output_idx) { | |||
508 | list_free(bars); | 579 | list_free(bars); |
509 | } | 580 | } |
510 | 581 | ||
582 | void apply_input_config(struct input_config *ic, struct libinput_device *dev) { | ||
583 | if (ic) { | ||
584 | sway_log(L_DEBUG, | ||
585 | "apply_input_config(%s)", | ||
586 | ic->identifier); | ||
587 | } | ||
588 | |||
589 | if (ic && ic->click_method != INT_MIN) { | ||
590 | sway_log(L_DEBUG, "apply_input_config(%s) click_set_method(%d)", ic->identifier, ic->click_method); | ||
591 | libinput_device_config_click_set_method(dev, ic->click_method); | ||
592 | } | ||
593 | if (ic && ic->drag_lock != INT_MIN) { | ||
594 | sway_log(L_DEBUG, "apply_input_config(%s) tap_set_drag_lock_enabled(%d)", ic->identifier, ic->click_method); | ||
595 | libinput_device_config_tap_set_drag_lock_enabled(dev, ic->drag_lock); | ||
596 | } | ||
597 | if (ic && ic->dwt != INT_MIN) { | ||
598 | sway_log(L_DEBUG, "apply_input_config(%s) dwt_set_enabled(%d)", ic->identifier, ic->dwt); | ||
599 | libinput_device_config_dwt_set_enabled(dev, ic->dwt); | ||
600 | } | ||
601 | if (ic && ic->middle_emulation != INT_MIN) { | ||
602 | sway_log(L_DEBUG, "apply_input_config(%s) middle_emulation_set_enabled(%d)", ic->identifier, ic->middle_emulation); | ||
603 | libinput_device_config_middle_emulation_set_enabled(dev, ic->middle_emulation); | ||
604 | } | ||
605 | if (ic && ic->natural_scroll != INT_MIN) { | ||
606 | sway_log(L_DEBUG, "apply_input_config(%s) natural_scroll_set_enabled(%d)", ic->identifier, ic->natural_scroll); | ||
607 | libinput_device_config_scroll_set_natural_scroll_enabled(dev, ic->natural_scroll); | ||
608 | } | ||
609 | if (ic && ic->pointer_accel != FLT_MIN) { | ||
610 | sway_log(L_DEBUG, "apply_input_config(%s) accel_set_speed(%f)", ic->identifier, ic->pointer_accel); | ||
611 | libinput_device_config_accel_set_speed(dev, ic->pointer_accel); | ||
612 | } | ||
613 | if (ic && ic->scroll_method != INT_MIN) { | ||
614 | sway_log(L_DEBUG, "apply_input_config(%s) scroll_set_method(%d)", ic->identifier, ic->scroll_method); | ||
615 | libinput_device_config_scroll_set_method(dev, ic->scroll_method); | ||
616 | } | ||
617 | if (ic && ic->send_events != INT_MIN) { | ||
618 | sway_log(L_DEBUG, "apply_input_config(%s) send_events_set_mode(%d)", ic->identifier, ic->send_events); | ||
619 | libinput_device_config_send_events_set_mode(dev, ic->send_events); | ||
620 | } | ||
621 | if (ic && ic->tap != INT_MIN) { | ||
622 | sway_log(L_DEBUG, "apply_input_config(%s) tap_set_enabled(%d)", ic->identifier, ic->tap); | ||
623 | libinput_device_config_tap_set_enabled(dev, ic->tap); | ||
624 | } | ||
625 | } | ||
626 | |||
511 | void apply_output_config(struct output_config *oc, swayc_t *output) { | 627 | void apply_output_config(struct output_config *oc, swayc_t *output) { |
512 | if (oc && oc->width > 0 && oc->height > 0) { | 628 | if (oc && oc->width > 0 && oc->height > 0) { |
513 | output->width = oc->width; | 629 | output->width = oc->width; |