aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-23 15:04:46 -0400
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-07-23 21:33:17 -0400
commit863914ec9574eb58cb0746d59f216997c4863cdf (patch)
treeaaddd8ae854d1dde4b50cfd4ef470c1acf83b6ce
parentMerge pull request #2342 from RyanDwyer/update-cursor (diff)
downloadsway-863914ec9574eb58cb0746d59f216997c4863cdf.tar.gz
sway-863914ec9574eb58cb0746d59f216997c4863cdf.tar.zst
sway-863914ec9574eb58cb0746d59f216997c4863cdf.zip
Switch to using a function to parse booleans
-rw-r--r--common/util.c15
-rw-r--r--include/util.h8
-rw-r--r--sway/commands/focus_follows_mouse.c4
-rw-r--r--sway/commands/focus_wrapping.c12
-rw-r--r--sway/commands/force_focus_wrapping.c8
-rw-r--r--sway/commands/fullscreen.c14
-rw-r--r--sway/commands/input/drag_lock.c9
-rw-r--r--sway/commands/input/dwt.c9
-rw-r--r--sway/commands/input/left_handed.c11
-rw-r--r--sway/commands/input/middle_emulation.c9
-rw-r--r--sway/commands/input/natural_scroll.c11
-rw-r--r--sway/commands/input/tap.c9
-rw-r--r--sway/commands/output/dpms.c8
-rw-r--r--sway/commands/show_marks.c10
-rw-r--r--sway/commands/urgent.c10
15 files changed, 62 insertions, 85 deletions
diff --git a/common/util.c b/common/util.c
index e8a88772..33a0c77e 100644
--- a/common/util.c
+++ b/common/util.c
@@ -123,6 +123,21 @@ uint32_t parse_color(const char *color) {
123 return res; 123 return res;
124} 124}
125 125
126bool parse_boolean(const char *boolean, const bool current) {
127 if (strcmp(boolean, "1") == 0
128 || strcmp(boolean, "yes") == 0
129 || strcmp(boolean, "on") == 0
130 || strcmp(boolean, "true") == 0
131 || strcmp(boolean, "enable") == 0
132 || strcmp(boolean, "enabled") == 0
133 || strcmp(boolean, "active") == 0) {
134 return true;
135 } else if (strcmp(boolean, "toggle") == 0) {
136 return !current;
137 }
138 return false;
139}
140
126char* resolve_path(const char* path) { 141char* resolve_path(const char* path) {
127 struct stat sb; 142 struct stat sb;
128 ssize_t r; 143 ssize_t r;
diff --git a/include/util.h b/include/util.h
index f68deae8..40f2c7b1 100644
--- a/include/util.h
+++ b/include/util.h
@@ -51,6 +51,14 @@ pid_t get_parent_pid(pid_t pid);
51uint32_t parse_color(const char *color); 51uint32_t parse_color(const char *color);
52 52
53/** 53/**
54 * Given a string that represents a boolean, return the boolean value. This
55 * function also takes in the current boolean value to support toggling. If
56 * toggling is not desired, pass in true for current so that toggling values
57 * get parsed as not true.
58 */
59bool parse_boolean(const char *boolean, const bool current);
60
61/**
54 * Given a path string, recurseively resolves any symlinks to their targets 62 * Given a path string, recurseively resolves any symlinks to their targets
55 * (which may be a file, directory) and returns the result. 63 * (which may be a file, directory) and returns the result.
56 * argument is returned. Caller must free the returned buffer. 64 * argument is returned. Caller must free the returned buffer.
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
5struct cmd_results *cmd_focus_follows_mouse(int argc, char **argv) { 6struct 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
5struct cmd_results *cmd_focus_wrapping(int argc, char **argv) { 6struct 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
5struct cmd_results *cmd_force_focus_wrapping(int argc, char **argv) { 6struct 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
9struct cmd_results *cmd_fullscreen(int argc, char **argv) { 10struct 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
7struct cmd_results *input_cmd_drag_lock(int argc, char **argv) { 8struct 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
7struct cmd_results *input_cmd_dwt(int argc, char **argv) { 8struct 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
7struct cmd_results *input_cmd_left_handed(int argc, char **argv) { 8struct 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
7struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) { 8struct 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
7struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) { 8struct 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
8struct cmd_results *input_cmd_tap(int argc, char **argv) { 9struct 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
4struct cmd_results *output_cmd_dpms(int argc, char **argv) { 5struct 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
11static void rebuild_marks_iterator(struct sway_container *con, void *data) { 12static 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
9struct cmd_results *cmd_urgent(int argc, char **argv) { 10struct 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);