diff options
author | Tony Crisci <tony@dubstepdish.com> | 2017-12-12 09:02:30 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2017-12-12 09:03:58 -0500 |
commit | 538903bc5ace56c1dab0f5287fb4d0bab78a0165 (patch) | |
tree | d45d08f64e98a76c730145cf3ea75dd199d9f6c8 | |
parent | sway input device (diff) | |
download | sway-538903bc5ace56c1dab0f5287fb4d0bab78a0165.tar.gz sway-538903bc5ace56c1dab0f5287fb4d0bab78a0165.tar.zst sway-538903bc5ace56c1dab0f5287fb4d0bab78a0165.zip |
config cleanup
-rw-r--r-- | sway/commands/input/accel_profile.c | 6 | ||||
-rw-r--r-- | sway/commands/input/click_method.c | 12 | ||||
-rw-r--r-- | sway/commands/input/drag_lock.c | 9 | ||||
-rw-r--r-- | sway/commands/input/dwt.c | 6 | ||||
-rw-r--r-- | sway/commands/input/events.c | 15 | ||||
-rw-r--r-- | sway/commands/input/left_handed.c | 9 | ||||
-rw-r--r-- | sway/commands/input/middle_emulation.c | 12 | ||||
-rw-r--r-- | sway/commands/input/natural_scroll.c | 9 | ||||
-rw-r--r-- | sway/commands/input/pointer_accel.c | 9 | ||||
-rw-r--r-- | sway/commands/input/scroll_method.c | 9 | ||||
-rw-r--r-- | sway/commands/input/tap.c | 9 | ||||
-rw-r--r-- | sway/config.c | 37 |
12 files changed, 94 insertions, 48 deletions
diff --git a/sway/commands/input/accel_profile.c b/sway/commands/input/accel_profile.c index 13ded431..9b5fb7a2 100644 --- a/sway/commands/input/accel_profile.c +++ b/sway/commands/input/accel_profile.c | |||
@@ -9,9 +9,11 @@ struct cmd_results *input_cmd_accel_profile(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "accel_profile", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, "accel_profile", |
13 | "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | if (strcasecmp(argv[0], "adaptive") == 0) { | 18 | if (strcasecmp(argv[0], "adaptive") == 0) { |
17 | new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; | 19 | new_config->accel_profile = LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE; |
diff --git a/sway/commands/input/click_method.c b/sway/commands/input/click_method.c index 40f075ce..a0e3bddf 100644 --- a/sway/commands/input/click_method.c +++ b/sway/commands/input/click_method.c | |||
@@ -5,15 +5,18 @@ | |||
5 | #include "log.h" | 5 | #include "log.h" |
6 | 6 | ||
7 | struct cmd_results *input_cmd_click_method(int argc, char **argv) { | 7 | struct cmd_results *input_cmd_click_method(int argc, char **argv) { |
8 | sway_log(L_DEBUG, "click_method for device: %d %s", current_input_config==NULL, current_input_config->identifier); | 8 | sway_log(L_DEBUG, "click_method for device: %d %s", |
9 | current_input_config==NULL, current_input_config->identifier); | ||
9 | struct cmd_results *error = NULL; | 10 | struct cmd_results *error = NULL; |
10 | if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) { | 11 | if ((error = checkarg(argc, "click_method", EXPECTED_AT_LEAST, 1))) { |
11 | return error; | 12 | return error; |
12 | } | 13 | } |
13 | if (!current_input_config) { | 14 | if (!current_input_config) { |
14 | return cmd_results_new(CMD_FAILURE, "click_method", "No input device defined."); | 15 | return cmd_results_new(CMD_FAILURE, "click_method", |
16 | "No input device defined."); | ||
15 | } | 17 | } |
16 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 18 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | ||
17 | 20 | ||
18 | if (strcasecmp(argv[0], "none") == 0) { | 21 | if (strcasecmp(argv[0], "none") == 0) { |
19 | new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; | 22 | new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_NONE; |
@@ -22,7 +25,8 @@ struct cmd_results *input_cmd_click_method(int argc, char **argv) { | |||
22 | } else if (strcasecmp(argv[0], "clickfinger") == 0) { | 25 | } else if (strcasecmp(argv[0], "clickfinger") == 0) { |
23 | new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; | 26 | new_config->click_method = LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; |
24 | } else { | 27 | } else { |
25 | return cmd_results_new(CMD_INVALID, "click_method", "Expected 'click_method <none|button_areas|clickfinger'"); | 28 | return cmd_results_new(CMD_INVALID, "click_method", |
29 | "Expected 'click_method <none|button_areas|clickfinger'"); | ||
26 | } | 30 | } |
27 | 31 | ||
28 | input_cmd_apply(new_config); | 32 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c index 11e7fbea..149a6183 100644 --- a/sway/commands/input/drag_lock.c +++ b/sway/commands/input/drag_lock.c | |||
@@ -9,16 +9,19 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "drag_lock", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, |
13 | "drag_lock", "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | if (strcasecmp(argv[0], "enabled") == 0) { | 18 | if (strcasecmp(argv[0], "enabled") == 0) { |
17 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; | 19 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; |
18 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 20 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
19 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; | 21 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; |
20 | } else { | 22 | } else { |
21 | return cmd_results_new(CMD_INVALID, "drag_lock", "Expected 'drag_lock <enabled|disabled>'"); | 23 | return cmd_results_new(CMD_INVALID, "drag_lock", |
24 | "Expected 'drag_lock <enabled|disabled>'"); | ||
22 | } | 25 | } |
23 | 26 | ||
24 | input_cmd_apply(new_config); | 27 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c index f3cbf252..0954575c 100644 --- a/sway/commands/input/dwt.c +++ b/sway/commands/input/dwt.c | |||
@@ -11,14 +11,16 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) { | |||
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, "dwt", "No input device defined."); |
13 | } | 13 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 14 | struct input_config *new_config = |
15 | new_input_config(current_input_config->identifier); | ||
15 | 16 | ||
16 | if (strcasecmp(argv[0], "enabled") == 0) { | 17 | if (strcasecmp(argv[0], "enabled") == 0) { |
17 | new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; | 18 | new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; |
18 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 19 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
19 | new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; | 20 | new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; |
20 | } else { | 21 | } else { |
21 | return cmd_results_new(CMD_INVALID, "dwt", "Expected 'dwt <enabled|disabled>'"); | 22 | return cmd_results_new(CMD_INVALID, "dwt", |
23 | "Expected 'dwt <enabled|disabled>'"); | ||
22 | } | 24 | } |
23 | 25 | ||
24 | input_cmd_apply(new_config); | 26 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/events.c b/sway/commands/input/events.c index 4b2fdff5..f44c0ec7 100644 --- a/sway/commands/input/events.c +++ b/sway/commands/input/events.c | |||
@@ -5,24 +5,29 @@ | |||
5 | #include "log.h" | 5 | #include "log.h" |
6 | 6 | ||
7 | struct cmd_results *input_cmd_events(int argc, char **argv) { | 7 | struct cmd_results *input_cmd_events(int argc, char **argv) { |
8 | sway_log(L_DEBUG, "events for device: %s", current_input_config->identifier); | 8 | sway_log(L_DEBUG, "events for device: %s", |
9 | current_input_config->identifier); | ||
9 | struct cmd_results *error = NULL; | 10 | struct cmd_results *error = NULL; |
10 | if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) { | 11 | if ((error = checkarg(argc, "events", EXPECTED_AT_LEAST, 1))) { |
11 | return error; | 12 | return error; |
12 | } | 13 | } |
13 | if (!current_input_config) { | 14 | if (!current_input_config) { |
14 | return cmd_results_new(CMD_FAILURE, "events", "No input device defined."); | 15 | return cmd_results_new(CMD_FAILURE, "events", |
16 | "No input device defined."); | ||
15 | } | 17 | } |
16 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 18 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | ||
17 | 20 | ||
18 | if (strcasecmp(argv[0], "enabled") == 0) { | 21 | if (strcasecmp(argv[0], "enabled") == 0) { |
19 | new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; | 22 | new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; |
20 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 23 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
21 | new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; | 24 | new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED; |
22 | } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) { | 25 | } else if (strcasecmp(argv[0], "disabled_on_external_mouse") == 0) { |
23 | new_config->send_events = LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; | 26 | new_config->send_events = |
27 | LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE; | ||
24 | } else { | 28 | } else { |
25 | return cmd_results_new(CMD_INVALID, "events", "Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); | 29 | return cmd_results_new(CMD_INVALID, "events", |
30 | "Expected 'events <enabled|disabled|disabled_on_external_mouse>'"); | ||
26 | } | 31 | } |
27 | 32 | ||
28 | input_cmd_apply(new_config); | 33 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c index 715df2a1..dc8fcd56 100644 --- a/sway/commands/input/left_handed.c +++ b/sway/commands/input/left_handed.c | |||
@@ -9,16 +9,19 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "left_handed", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, "left_handed", |
13 | "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | if (strcasecmp(argv[0], "enabled") == 0) { | 18 | if (strcasecmp(argv[0], "enabled") == 0) { |
17 | new_config->left_handed = 1; | 19 | new_config->left_handed = 1; |
18 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 20 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
19 | new_config->left_handed = 0; | 21 | new_config->left_handed = 0; |
20 | } else { | 22 | } else { |
21 | return cmd_results_new(CMD_INVALID, "left_handed", "Expected 'left_handed <enabled|disabled>'"); | 23 | return cmd_results_new(CMD_INVALID, "left_handed", |
24 | "Expected 'left_handed <enabled|disabled>'"); | ||
22 | } | 25 | } |
23 | 26 | ||
24 | input_cmd_apply(new_config); | 27 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c index d31ce950..e19964d8 100644 --- a/sway/commands/input/middle_emulation.c +++ b/sway/commands/input/middle_emulation.c | |||
@@ -9,16 +9,20 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "middle_emulation", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, "middle_emulation", |
13 | "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | if (strcasecmp(argv[0], "enabled") == 0) { | 18 | if (strcasecmp(argv[0], "enabled") == 0) { |
17 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; | 19 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; |
18 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 20 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
19 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; | 21 | new_config->middle_emulation = |
22 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; | ||
20 | } else { | 23 | } else { |
21 | return cmd_results_new(CMD_INVALID, "middle_emulation", "Expected 'middle_emulation <enabled|disabled>'"); | 24 | return cmd_results_new(CMD_INVALID, "middle_emulation", |
25 | "Expected 'middle_emulation <enabled|disabled>'"); | ||
22 | } | 26 | } |
23 | 27 | ||
24 | input_cmd_apply(new_config); | 28 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c index 9d1dc506..8272c5b3 100644 --- a/sway/commands/input/natural_scroll.c +++ b/sway/commands/input/natural_scroll.c | |||
@@ -9,16 +9,19 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "natural_scoll", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, "natural_scoll", |
13 | "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | if (strcasecmp(argv[0], "enabled") == 0) { | 18 | if (strcasecmp(argv[0], "enabled") == 0) { |
17 | new_config->natural_scroll = 1; | 19 | new_config->natural_scroll = 1; |
18 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 20 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
19 | new_config->natural_scroll = 0; | 21 | new_config->natural_scroll = 0; |
20 | } else { | 22 | } else { |
21 | return cmd_results_new(CMD_INVALID, "natural_scroll", "Expected 'natural_scroll <enabled|disabled>'"); | 23 | return cmd_results_new(CMD_INVALID, "natural_scroll", |
24 | "Expected 'natural_scroll <enabled|disabled>'"); | ||
22 | } | 25 | } |
23 | 26 | ||
24 | input_cmd_apply(new_config); | 27 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/pointer_accel.c b/sway/commands/input/pointer_accel.c index 87fb5cff..2c9db5bf 100644 --- a/sway/commands/input/pointer_accel.c +++ b/sway/commands/input/pointer_accel.c | |||
@@ -9,13 +9,16 @@ struct cmd_results *input_cmd_pointer_accel(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "pointer_accel", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, |
13 | "pointer_accel", "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | float pointer_accel = atof(argv[0]); | 18 | float pointer_accel = atof(argv[0]); |
17 | if (pointer_accel < -1 || pointer_accel > 1) { | 19 | if (pointer_accel < -1 || pointer_accel > 1) { |
18 | return cmd_results_new(CMD_INVALID, "pointer_accel", "Input out of range [-1, 1]"); | 20 | return cmd_results_new(CMD_INVALID, "pointer_accel", |
21 | "Input out of range [-1, 1]"); | ||
19 | } | 22 | } |
20 | new_config->pointer_accel = pointer_accel; | 23 | new_config->pointer_accel = pointer_accel; |
21 | 24 | ||
diff --git a/sway/commands/input/scroll_method.c b/sway/commands/input/scroll_method.c index 98873938..40277155 100644 --- a/sway/commands/input/scroll_method.c +++ b/sway/commands/input/scroll_method.c | |||
@@ -9,9 +9,11 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) { | |||
9 | return error; | 9 | return error; |
10 | } | 10 | } |
11 | if (!current_input_config) { | 11 | if (!current_input_config) { |
12 | return cmd_results_new(CMD_FAILURE, "scroll_method", "No input device defined."); | 12 | return cmd_results_new(CMD_FAILURE, "scroll_method", |
13 | "No input device defined."); | ||
13 | } | 14 | } |
14 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 15 | struct input_config *new_config = |
16 | new_input_config(current_input_config->identifier); | ||
15 | 17 | ||
16 | if (strcasecmp(argv[0], "none") == 0) { | 18 | if (strcasecmp(argv[0], "none") == 0) { |
17 | new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 19 | new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_NO_SCROLL; |
@@ -22,7 +24,8 @@ struct cmd_results *input_cmd_scroll_method(int argc, char **argv) { | |||
22 | } else if (strcasecmp(argv[0], "on_button_down") == 0) { | 24 | } else if (strcasecmp(argv[0], "on_button_down") == 0) { |
23 | new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; | 25 | new_config->scroll_method = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN; |
24 | } else { | 26 | } else { |
25 | return cmd_results_new(CMD_INVALID, "scroll_method", "Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); | 27 | return cmd_results_new(CMD_INVALID, "scroll_method", |
28 | "Expected 'scroll_method <none|two_finger|edge|on_button_down>'"); | ||
26 | } | 29 | } |
27 | 30 | ||
28 | input_cmd_apply(new_config); | 31 | input_cmd_apply(new_config); |
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c index 1109466f..18a54087 100644 --- a/sway/commands/input/tap.c +++ b/sway/commands/input/tap.c | |||
@@ -13,17 +13,20 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) { | |||
13 | if (!current_input_config) { | 13 | if (!current_input_config) { |
14 | return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); | 14 | return cmd_results_new(CMD_FAILURE, "tap", "No input device defined."); |
15 | } | 15 | } |
16 | struct input_config *new_config = new_input_config(current_input_config->identifier); | 16 | struct input_config *new_config = |
17 | new_input_config(current_input_config->identifier); | ||
17 | 18 | ||
18 | if (strcasecmp(argv[0], "enabled") == 0) { | 19 | if (strcasecmp(argv[0], "enabled") == 0) { |
19 | new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; | 20 | new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; |
20 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 21 | } else if (strcasecmp(argv[0], "disabled") == 0) { |
21 | new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; | 22 | new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; |
22 | } else { | 23 | } else { |
23 | return cmd_results_new(CMD_INVALID, "tap", "Expected 'tap <enabled|disabled>'"); | 24 | return cmd_results_new(CMD_INVALID, "tap", |
25 | "Expected 'tap <enabled|disabled>'"); | ||
24 | } | 26 | } |
25 | 27 | ||
26 | sway_log(L_DEBUG, "apply-tap for device: %s", current_input_config->identifier); | 28 | sway_log(L_DEBUG, "apply-tap for device: %s", |
29 | current_input_config->identifier); | ||
27 | input_cmd_apply(new_config); | 30 | input_cmd_apply(new_config); |
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
29 | } | 32 | } |
diff --git a/sway/config.c b/sway/config.c index 7ae3c2a4..4bc74ee0 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <dev/evdev/input-event-codes.h> | 21 | #include <dev/evdev/input-event-codes.h> |
22 | #endif | 22 | #endif |
23 | #include <wlr/types/wlr_output.h> | 23 | #include <wlr/types/wlr_output.h> |
24 | #include "sway/input/input-manager.h" | ||
24 | #include "sway/commands.h" | 25 | #include "sway/commands.h" |
25 | #include "sway/config.h" | 26 | #include "sway/config.h" |
26 | #include "sway/layout.h" | 27 | #include "sway/layout.h" |
@@ -48,7 +49,8 @@ static void config_defaults(struct sway_config *config) { | |||
48 | 49 | ||
49 | if (!(config->cmd_queue = create_list())) goto cleanup; | 50 | if (!(config->cmd_queue = create_list())) goto cleanup; |
50 | 51 | ||
51 | if (!(config->current_mode = malloc(sizeof(struct sway_mode)))) goto cleanup; | 52 | if (!(config->current_mode = malloc(sizeof(struct sway_mode)))) |
53 | goto cleanup; | ||
52 | if (!(config->current_mode->name = malloc(sizeof("default")))) goto cleanup; | 54 | if (!(config->current_mode->name = malloc(sizeof("default")))) goto cleanup; |
53 | strcpy(config->current_mode->name, "default"); | 55 | strcpy(config->current_mode->name, "default"); |
54 | if (!(config->current_mode->bindings = create_list())) goto cleanup; | 56 | if (!(config->current_mode->bindings = create_list())) goto cleanup; |
@@ -337,8 +339,9 @@ bool load_main_config(const char *file, bool is_active) { | |||
337 | bool success = true; | 339 | bool success = true; |
338 | DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); | 340 | DIR *dir = opendir(SYSCONFDIR "/sway/security.d"); |
339 | if (!dir) { | 341 | if (!dir) { |
340 | sway_log(L_ERROR, "%s does not exist, sway will have no security configuration" | 342 | sway_log(L_ERROR, |
341 | " and will probably be broken", SYSCONFDIR "/sway/security.d"); | 343 | "%s does not exist, sway will have no security configuration" |
344 | " and will probably be broken", SYSCONFDIR "/sway/security.d"); | ||
342 | } else { | 345 | } else { |
343 | list_t *secconfigs = create_list(); | 346 | list_t *secconfigs = create_list(); |
344 | char *base = SYSCONFDIR "/sway/security.d/"; | 347 | char *base = SYSCONFDIR "/sway/security.d/"; |
@@ -362,8 +365,12 @@ bool load_main_config(const char *file, bool is_active) { | |||
362 | list_qsort(secconfigs, qstrcmp); | 365 | list_qsort(secconfigs, qstrcmp); |
363 | for (int i = 0; i < secconfigs->length; ++i) { | 366 | for (int i = 0; i < secconfigs->length; ++i) { |
364 | char *_path = secconfigs->items[i]; | 367 | char *_path = secconfigs->items[i]; |
365 | if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || (((s.st_mode & 0777) != 0644) && (s.st_mode & 0777) != 0444)) { | 368 | if (stat(_path, &s) || s.st_uid != 0 || s.st_gid != 0 || |
366 | sway_log(L_ERROR, "Refusing to load %s - it must be owned by root and mode 644 or 444", _path); | 369 | (((s.st_mode & 0777) != 0644) && |
370 | (s.st_mode & 0777) != 0444)) { | ||
371 | sway_log(L_ERROR, | ||
372 | "Refusing to load %s - it must be owned by root " | ||
373 | "and mode 644 or 444", _path); | ||
367 | success = false; | 374 | success = false; |
368 | } else { | 375 | } else { |
369 | success = success && load_config(_path, config); | 376 | success = success && load_config(_path, config); |
@@ -392,7 +399,8 @@ bool load_main_config(const char *file, bool is_active) { | |||
392 | return success; | 399 | return success; |
393 | } | 400 | } |
394 | 401 | ||
395 | static bool load_include_config(const char *path, const char *parent_dir, struct sway_config *config) { | 402 | static bool load_include_config(const char *path, const char *parent_dir, |
403 | struct sway_config *config) { | ||
396 | // save parent config | 404 | // save parent config |
397 | const char *parent_config = config->current_config; | 405 | const char *parent_config = config->current_config; |
398 | 406 | ||
@@ -402,7 +410,8 @@ static bool load_include_config(const char *path, const char *parent_dir, struct | |||
402 | len = len + strlen(parent_dir) + 2; | 410 | len = len + strlen(parent_dir) + 2; |
403 | full_path = malloc(len * sizeof(char)); | 411 | full_path = malloc(len * sizeof(char)); |
404 | if (!full_path) { | 412 | if (!full_path) { |
405 | sway_log(L_ERROR, "Unable to allocate full path to included config"); | 413 | sway_log(L_ERROR, |
414 | "Unable to allocate full path to included config"); | ||
406 | return false; | 415 | return false; |
407 | } | 416 | } |
408 | snprintf(full_path, len, "%s/%s", parent_dir, path); | 417 | snprintf(full_path, len, "%s/%s", parent_dir, path); |
@@ -421,7 +430,9 @@ static bool load_include_config(const char *path, const char *parent_dir, struct | |||
421 | for (j = 0; j < config->config_chain->length; ++j) { | 430 | for (j = 0; j < config->config_chain->length; ++j) { |
422 | char *old_path = config->config_chain->items[j]; | 431 | char *old_path = config->config_chain->items[j]; |
423 | if (strcmp(real_path, old_path) == 0) { | 432 | if (strcmp(real_path, old_path) == 0) { |
424 | sway_log(L_DEBUG, "%s already included once, won't be included again.", real_path); | 433 | sway_log(L_DEBUG, |
434 | "%s already included once, won't be included again.", | ||
435 | real_path); | ||
425 | free(real_path); | 436 | free(real_path); |
426 | return false; | 437 | return false; |
427 | } | 438 | } |
@@ -509,8 +520,8 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
509 | switch(res->status) { | 520 | switch(res->status) { |
510 | case CMD_FAILURE: | 521 | case CMD_FAILURE: |
511 | case CMD_INVALID: | 522 | case CMD_INVALID: |
512 | sway_log(L_ERROR, "Error on line %i '%s': %s (%s)", line_number, line, | 523 | sway_log(L_ERROR, "Error on line %i '%s': %s (%s)", line_number, |
513 | res->error, config->current_config); | 524 | line, res->error, config->current_config); |
514 | success = false; | 525 | success = false; |
515 | break; | 526 | break; |
516 | 527 | ||
@@ -585,8 +596,7 @@ bool read_config(FILE *file, struct sway_config *config) { | |||
585 | 596 | ||
586 | case CMD_BLOCK_INPUT: | 597 | case CMD_BLOCK_INPUT: |
587 | sway_log(L_DEBUG, "End of input block"); | 598 | sway_log(L_DEBUG, "End of input block"); |
588 | // TODO: input | 599 | current_input_config = NULL; |
589 | //current_input_config = NULL; | ||
590 | block = CMD_BLOCK_END; | 600 | block = CMD_BLOCK_END; |
591 | break; | 601 | break; |
592 | 602 | ||
@@ -651,7 +661,8 @@ char *do_var_replacement(char *str) { | |||
651 | char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); | 661 | char *newstr = malloc(strlen(str) - vnlen + vvlen + 1); |
652 | if (!newstr) { | 662 | if (!newstr) { |
653 | sway_log(L_ERROR, | 663 | sway_log(L_ERROR, |
654 | "Unable to allocate replacement during variable expansion"); | 664 | "Unable to allocate replacement " |
665 | "during variable expansion"); | ||
655 | break; | 666 | break; |
656 | } | 667 | } |
657 | char *newptr = newstr; | 668 | char *newptr = newstr; |