diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-23 15:04:46 -0400 |
---|---|---|
committer | Brian Ashworth <bosrsf04@gmail.com> | 2018-07-23 21:33:17 -0400 |
commit | 863914ec9574eb58cb0746d59f216997c4863cdf (patch) | |
tree | aaddd8ae854d1dde4b50cfd4ef470c1acf83b6ce /sway | |
parent | Merge pull request #2342 from RyanDwyer/update-cursor (diff) | |
download | sway-863914ec9574eb58cb0746d59f216997c4863cdf.tar.gz sway-863914ec9574eb58cb0746d59f216997c4863cdf.tar.zst sway-863914ec9574eb58cb0746d59f216997c4863cdf.zip |
Switch to using a function to parse booleans
Diffstat (limited to 'sway')
-rw-r--r-- | sway/commands/focus_follows_mouse.c | 4 | ||||
-rw-r--r-- | sway/commands/focus_wrapping.c | 12 | ||||
-rw-r--r-- | sway/commands/force_focus_wrapping.c | 8 | ||||
-rw-r--r-- | sway/commands/fullscreen.c | 14 | ||||
-rw-r--r-- | sway/commands/input/drag_lock.c | 9 | ||||
-rw-r--r-- | sway/commands/input/dwt.c | 9 | ||||
-rw-r--r-- | sway/commands/input/left_handed.c | 11 | ||||
-rw-r--r-- | sway/commands/input/middle_emulation.c | 9 | ||||
-rw-r--r-- | sway/commands/input/natural_scroll.c | 11 | ||||
-rw-r--r-- | sway/commands/input/tap.c | 9 | ||||
-rw-r--r-- | sway/commands/output/dpms.c | 8 | ||||
-rw-r--r-- | sway/commands/show_marks.c | 10 | ||||
-rw-r--r-- | sway/commands/urgent.c | 10 |
13 files changed, 39 insertions, 85 deletions
diff --git a/sway/commands/focus_follows_mouse.c b/sway/commands/focus_follows_mouse.c index 661e7852..0b0e334c 100644 --- a/sway/commands/focus_follows_mouse.c +++ b/sway/commands/focus_follows_mouse.c | |||
@@ -1,12 +1,14 @@ | |||
1 | #include <string.h> | 1 | #include <string.h> |
2 | #include <strings.h> | 2 | #include <strings.h> |
3 | #include "sway/commands.h" | 3 | #include "sway/commands.h" |
4 | #include "util.h" | ||
4 | 5 | ||
5 | struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) { | 6 | struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) { |
6 | struct cmd_results *error = NULL; | 7 | struct cmd_results *error = NULL; |
7 | if ((error = checkarg(argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1))) { | 8 | if ((error = checkarg(argc, "focus_follows_mouse", EXPECTED_EQUAL_TO, 1))) { |
8 | return error; | 9 | return error; |
9 | } | 10 | } |
10 | config->focus_follows_mouse = !strcasecmp(argv[0], "yes"); | 11 | config->focus_follows_mouse = |
12 | parse_boolean(argv[0], config->focus_follows_mouse); | ||
11 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 13 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
12 | } | 14 | } |
diff --git a/sway/commands/focus_wrapping.c b/sway/commands/focus_wrapping.c index 0a9e0bf2..15704228 100644 --- a/sway/commands/focus_wrapping.c +++ b/sway/commands/focus_wrapping.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <strings.h> | 1 | #include <strings.h> |
2 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "util.h" | ||
4 | 5 | ||
5 | struct cmd_results *cmd_focus_wrapping(int argc, char **argv) { | 6 | struct cmd_results *cmd_focus_wrapping(int argc, char **argv) { |
6 | struct cmd_results *error = NULL; | 7 | struct cmd_results *error = NULL; |
@@ -8,15 +9,12 @@ struct cmd_results *cmd_focus_wrapping(int argc, char **argv) { | |||
8 | return error; | 9 | return error; |
9 | } | 10 | } |
10 | 11 | ||
11 | if (strcasecmp(argv[0], "no") == 0) { | 12 | if (strcmp(argv[0], "force") == 0) { |
12 | config->focus_wrapping = WRAP_NO; | ||
13 | } else if (strcasecmp(argv[0], "yes") == 0) { | ||
14 | config->focus_wrapping = WRAP_YES; | ||
15 | } else if (strcasecmp(argv[0], "force") == 0) { | ||
16 | config->focus_wrapping = WRAP_FORCE; | 13 | config->focus_wrapping = WRAP_FORCE; |
14 | } else if (parse_boolean(argv[0], config->focus_wrapping == WRAP_YES)) { | ||
15 | config->focus_wrapping = WRAP_YES; | ||
17 | } else { | 16 | } else { |
18 | return cmd_results_new(CMD_INVALID, "focus_wrapping", | 17 | config->focus_wrapping = WRAP_NO; |
19 | "Expected 'focus_wrapping yes|no|force'"); | ||
20 | } | 18 | } |
21 | 19 | ||
22 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 20 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/force_focus_wrapping.c b/sway/commands/force_focus_wrapping.c index bc1d067f..0892d9e9 100644 --- a/sway/commands/force_focus_wrapping.c +++ b/sway/commands/force_focus_wrapping.c | |||
@@ -1,6 +1,7 @@ | |||
1 | #include <strings.h> | 1 | #include <strings.h> |
2 | #include "sway/commands.h" | 2 | #include "sway/commands.h" |
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "util.h" | ||
4 | 5 | ||
5 | struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) { | 6 | struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) { |
6 | struct cmd_results *error = | 7 | struct cmd_results *error = |
@@ -9,13 +10,10 @@ struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) { | |||
9 | return error; | 10 | return error; |
10 | } | 11 | } |
11 | 12 | ||
12 | if (strcasecmp(argv[0], "no") == 0) { | 13 | if (parse_boolean(argv[0], config->focus_wrapping == WRAP_FORCE)) { |
13 | config->focus_wrapping = WRAP_YES; | ||
14 | } else if (strcasecmp(argv[0], "yes") == 0) { | ||
15 | config->focus_wrapping = WRAP_FORCE; | 14 | config->focus_wrapping = WRAP_FORCE; |
16 | } else { | 15 | } else { |
17 | return cmd_results_new(CMD_INVALID, "force_focus_wrapping", | 16 | config->focus_wrapping = WRAP_YES; |
18 | "Expected 'force_focus_wrapping yes|no'"); | ||
19 | } | 17 | } |
20 | 18 | ||
21 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 19 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/fullscreen.c b/sway/commands/fullscreen.c index 0b5beaa2..b423fd23 100644 --- a/sway/commands/fullscreen.c +++ b/sway/commands/fullscreen.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
6 | #include "sway/tree/view.h" | 6 | #include "sway/tree/view.h" |
7 | #include "sway/tree/layout.h" | 7 | #include "sway/tree/layout.h" |
8 | #include "util.h" | ||
8 | 9 | ||
9 | struct cmd_results *cmd_fullscreen(int argc, char **argv) { | 10 | struct cmd_results *cmd_fullscreen(int argc, char **argv) { |
10 | struct cmd_results *error = NULL; | 11 | struct cmd_results *error = NULL; |
@@ -18,17 +19,10 @@ struct cmd_results *cmd_fullscreen(int argc, char **argv) { | |||
18 | "Only views can fullscreen"); | 19 | "Only views can fullscreen"); |
19 | } | 20 | } |
20 | struct sway_view *view = container->sway_view; | 21 | struct sway_view *view = container->sway_view; |
21 | bool wants_fullscreen; | 22 | bool wants_fullscreen = !view->is_fullscreen; |
22 | 23 | ||
23 | if (argc == 0 || strcmp(argv[0], "toggle") == 0) { | 24 | if (argc) { |
24 | wants_fullscreen = !view->is_fullscreen; | 25 | wants_fullscreen = parse_boolean(argv[0], view->is_fullscreen); |
25 | } else if (strcmp(argv[0], "enable") == 0) { | ||
26 | wants_fullscreen = true; | ||
27 | } else if (strcmp(argv[0], "disable") == 0) { | ||
28 | wants_fullscreen = false; | ||
29 | } else { | ||
30 | return cmd_results_new(CMD_INVALID, "fullscreen", | ||
31 | "Expected 'fullscreen' or 'fullscreen <enable|disable|toggle>'"); | ||
32 | } | 26 | } |
33 | 27 | ||
34 | view_set_fullscreen(view, wants_fullscreen); | 28 | view_set_fullscreen(view, wants_fullscreen); |
diff --git a/sway/commands/input/drag_lock.c b/sway/commands/input/drag_lock.c index 9e32816f..f9ddeef2 100644 --- a/sway/commands/input/drag_lock.c +++ b/sway/commands/input/drag_lock.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,14 +19,10 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | if (parse_boolean(argv[0], true)) { |
22 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; | 23 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; |
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; | ||
25 | } else { | 24 | } else { |
26 | free_input_config(new_config); | 25 | new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; |
27 | return cmd_results_new(CMD_INVALID, "drag_lock", | ||
28 | "Expected 'drag_lock <enabled|disabled>'"); | ||
29 | } | 26 | } |
30 | 27 | ||
31 | apply_input_config(new_config); | 28 | apply_input_config(new_config); |
diff --git a/sway/commands/input/dwt.c b/sway/commands/input/dwt.c index 73937507..15134268 100644 --- a/sway/commands/input/dwt.c +++ b/sway/commands/input/dwt.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_dwt(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_dwt(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -17,14 +18,10 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) { | |||
17 | struct input_config *new_config = | 18 | struct input_config *new_config = |
18 | new_input_config(current_input_config->identifier); | 19 | new_input_config(current_input_config->identifier); |
19 | 20 | ||
20 | if (strcasecmp(argv[0], "enabled") == 0) { | 21 | if (parse_boolean(argv[0], true)) { |
21 | new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; | 22 | new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED; |
22 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
23 | new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; | ||
24 | } else { | 23 | } else { |
25 | free_input_config(new_config); | 24 | new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED; |
26 | return cmd_results_new(CMD_INVALID, "dwt", | ||
27 | "Expected 'dwt <enabled|disabled>'"); | ||
28 | } | 25 | } |
29 | 26 | ||
30 | apply_input_config(new_config); | 27 | apply_input_config(new_config); |
diff --git a/sway/commands/input/left_handed.c b/sway/commands/input/left_handed.c index 769ce98c..e770043a 100644 --- a/sway/commands/input/left_handed.c +++ b/sway/commands/input/left_handed.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_left_handed(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_left_handed(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,15 +19,7 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | new_config->left_handed = parse_boolean(argv[0], true); |
22 | new_config->left_handed = 1; | ||
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->left_handed = 0; | ||
25 | } else { | ||
26 | free_input_config(new_config); | ||
27 | return cmd_results_new(CMD_INVALID, "left_handed", | ||
28 | "Expected 'left_handed <enabled|disabled>'"); | ||
29 | } | ||
30 | 23 | ||
31 | apply_input_config(new_config); | 24 | apply_input_config(new_config); |
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/input/middle_emulation.c b/sway/commands/input/middle_emulation.c index 7ca01629..414d4d2b 100644 --- a/sway/commands/input/middle_emulation.c +++ b/sway/commands/input/middle_emulation.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,15 +19,11 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | if (parse_boolean(argv[0], true)) { |
22 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; | 23 | new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED; |
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | 24 | } else { |
24 | new_config->middle_emulation = | 25 | new_config->middle_emulation = |
25 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; | 26 | LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED; |
26 | } else { | ||
27 | free_input_config(new_config); | ||
28 | return cmd_results_new(CMD_INVALID, "middle_emulation", | ||
29 | "Expected 'middle_emulation <enabled|disabled>'"); | ||
30 | } | 27 | } |
31 | 28 | ||
32 | apply_input_config(new_config); | 29 | apply_input_config(new_config); |
diff --git a/sway/commands/input/natural_scroll.c b/sway/commands/input/natural_scroll.c index 55236790..77c3ff00 100644 --- a/sway/commands/input/natural_scroll.c +++ b/sway/commands/input/natural_scroll.c | |||
@@ -3,6 +3,7 @@ | |||
3 | #include "sway/config.h" | 3 | #include "sway/config.h" |
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "util.h" | ||
6 | 7 | ||
7 | struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { | 8 | struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { |
8 | struct cmd_results *error = NULL; | 9 | struct cmd_results *error = NULL; |
@@ -18,15 +19,7 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | new_config->natural_scroll = parse_boolean(argv[0], true); |
22 | new_config->natural_scroll = 1; | ||
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->natural_scroll = 0; | ||
25 | } else { | ||
26 | free_input_config(new_config); | ||
27 | return cmd_results_new(CMD_INVALID, "natural_scroll", | ||
28 | "Expected 'natural_scroll <enabled|disabled>'"); | ||
29 | } | ||
30 | 23 | ||
31 | apply_input_config(new_config); | 24 | apply_input_config(new_config); |
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 25 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |
diff --git a/sway/commands/input/tap.c b/sway/commands/input/tap.c index a8d1a10c..ac3b8237 100644 --- a/sway/commands/input/tap.c +++ b/sway/commands/input/tap.c | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "sway/commands.h" | 4 | #include "sway/commands.h" |
5 | #include "sway/input/input-manager.h" | 5 | #include "sway/input/input-manager.h" |
6 | #include "log.h" | 6 | #include "log.h" |
7 | #include "util.h" | ||
7 | 8 | ||
8 | struct cmd_results *input_cmd_tap(int argc, char **argv) { | 9 | struct cmd_results *input_cmd_tap(int argc, char **argv) { |
9 | struct cmd_results *error = NULL; | 10 | struct cmd_results *error = NULL; |
@@ -18,14 +19,10 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) { | |||
18 | struct input_config *new_config = | 19 | struct input_config *new_config = |
19 | new_input_config(current_input_config->identifier); | 20 | new_input_config(current_input_config->identifier); |
20 | 21 | ||
21 | if (strcasecmp(argv[0], "enabled") == 0) { | 22 | if (parse_boolean(argv[0], true)) { |
22 | new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; | 23 | new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED; |
23 | } else if (strcasecmp(argv[0], "disabled") == 0) { | ||
24 | new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; | ||
25 | } else { | 24 | } else { |
26 | free_input_config(new_config); | 25 | new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED; |
27 | return cmd_results_new(CMD_INVALID, "tap", | ||
28 | "Expected 'tap <enabled|disabled>'"); | ||
29 | } | 26 | } |
30 | 27 | ||
31 | wlr_log(WLR_DEBUG, "apply-tap for device: %s", | 28 | wlr_log(WLR_DEBUG, "apply-tap for device: %s", |
diff --git a/sway/commands/output/dpms.c b/sway/commands/output/dpms.c index 0959ea6b..3492061e 100644 --- a/sway/commands/output/dpms.c +++ b/sway/commands/output/dpms.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include "sway/commands.h" | 1 | #include "sway/commands.h" |
2 | #include "sway/config.h" | 2 | #include "sway/config.h" |
3 | #include "util.h" | ||
3 | 4 | ||
4 | struct cmd_results *output_cmd_dpms(int argc, char **argv) { | 5 | struct cmd_results *output_cmd_dpms(int argc, char **argv) { |
5 | if (!config->handler_context.output_config) { | 6 | if (!config->handler_context.output_config) { |
@@ -9,13 +10,10 @@ struct cmd_results *output_cmd_dpms(int argc, char **argv) { | |||
9 | return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); | 10 | return cmd_results_new(CMD_INVALID, "output", "Missing dpms argument."); |
10 | } | 11 | } |
11 | 12 | ||
12 | if (strcmp(*argv, "on") == 0) { | 13 | if (parse_boolean(argv[0], true)) { |
13 | config->handler_context.output_config->dpms_state = DPMS_ON; | 14 | config->handler_context.output_config->dpms_state = DPMS_ON; |
14 | } else if (strcmp(*argv, "off") == 0) { | ||
15 | config->handler_context.output_config->dpms_state = DPMS_OFF; | ||
16 | } else { | 15 | } else { |
17 | return cmd_results_new(CMD_INVALID, "output", | 16 | config->handler_context.output_config->dpms_state = DPMS_OFF; |
18 | "Invalid dpms state, valid states are on/off."); | ||
19 | } | 17 | } |
20 | 18 | ||
21 | config->handler_context.leftovers.argc = argc - 1; | 19 | config->handler_context.leftovers.argc = argc - 1; |
diff --git a/sway/commands/show_marks.c b/sway/commands/show_marks.c index c7fdc538..434a0e27 100644 --- a/sway/commands/show_marks.c +++ b/sway/commands/show_marks.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include "list.h" | 7 | #include "list.h" |
8 | #include "log.h" | 8 | #include "log.h" |
9 | #include "stringop.h" | 9 | #include "stringop.h" |
10 | #include "util.h" | ||
10 | 11 | ||
11 | static void rebuild_marks_iterator(struct sway_container *con, void *data) { | 12 | static void rebuild_marks_iterator(struct sway_container *con, void *data) { |
12 | if (con->type == C_VIEW) { | 13 | if (con->type == C_VIEW) { |
@@ -20,14 +21,7 @@ struct cmd_results *cmd_show_marks(int argc, char **argv) { | |||
20 | return error; | 21 | return error; |
21 | } | 22 | } |
22 | 23 | ||
23 | if (strcmp(*argv, "yes") == 0) { | 24 | config->show_marks = parse_boolean(argv[0], config->show_marks); |
24 | config->show_marks = true; | ||
25 | } else if (strcmp(*argv, "no") == 0) { | ||
26 | config->show_marks = false; | ||
27 | } else { | ||
28 | return cmd_results_new(CMD_INVALID, "show_marks", | ||
29 | "Expected 'show_marks <yes|no>'"); | ||
30 | } | ||
31 | 25 | ||
32 | if (config->show_marks) { | 26 | if (config->show_marks) { |
33 | container_for_each_descendant_dfs(&root_container, | 27 | container_for_each_descendant_dfs(&root_container, |
diff --git a/sway/commands/urgent.c b/sway/commands/urgent.c index d199858a..51c497c4 100644 --- a/sway/commands/urgent.c +++ b/sway/commands/urgent.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "sway/tree/container.h" | 5 | #include "sway/tree/container.h" |
6 | #include "sway/tree/view.h" | 6 | #include "sway/tree/view.h" |
7 | #include "sway/tree/layout.h" | 7 | #include "sway/tree/layout.h" |
8 | #include "util.h" | ||
8 | 9 | ||
9 | struct cmd_results *cmd_urgent(int argc, char **argv) { | 10 | struct cmd_results *cmd_urgent(int argc, char **argv) { |
10 | struct cmd_results *error = NULL; | 11 | struct cmd_results *error = NULL; |
@@ -19,17 +20,12 @@ struct cmd_results *cmd_urgent(int argc, char **argv) { | |||
19 | } | 20 | } |
20 | struct sway_view *view = container->sway_view; | 21 | struct sway_view *view = container->sway_view; |
21 | 22 | ||
22 | if (strcmp(argv[0], "enable") == 0) { | 23 | if (strcmp(argv[0], "allow") == 0) { |
23 | view_set_urgent(view, true); | ||
24 | } else if (strcmp(argv[0], "disable") == 0) { | ||
25 | view_set_urgent(view, false); | ||
26 | } else if (strcmp(argv[0], "allow") == 0) { | ||
27 | view->allow_request_urgent = true; | 24 | view->allow_request_urgent = true; |
28 | } else if (strcmp(argv[0], "deny") == 0) { | 25 | } else if (strcmp(argv[0], "deny") == 0) { |
29 | view->allow_request_urgent = false; | 26 | view->allow_request_urgent = false; |
30 | } else { | 27 | } else { |
31 | return cmd_results_new(CMD_INVALID, "urgent", | 28 | view_set_urgent(view, parse_boolean(argv[0], view_is_urgent(view))); |
32 | "Expected 'urgent <enable|disable|allow|deny>'"); | ||
33 | } | 29 | } |
34 | 30 | ||
35 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 31 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); |