aboutsummaryrefslogtreecommitdiff
path: root/sway/commands/input
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/input')
-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
6 files changed, 16 insertions, 42 deletions
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 @@
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
+#include "util.h"
struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -18,14 +19,10 @@ struct cmd_results *input_cmd_drag_lock(int argc, char **argv) {
struct input_config *new_config =
new_input_config(current_input_config->identifier);
- if (strcasecmp(argv[0], "enabled") == 0) {
+ if (parse_boolean(argv[0], true)) {
new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
- } else if (strcasecmp(argv[0], "disabled") == 0) {
- new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
} else {
- free_input_config(new_config);
- return cmd_results_new(CMD_INVALID, "drag_lock",
- "Expected 'drag_lock <enabled|disabled>'");
+ new_config->drag_lock = LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
}
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 @@
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
+#include "util.h"
struct cmd_results *input_cmd_dwt(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -17,14 +18,10 @@ struct cmd_results *input_cmd_dwt(int argc, char **argv) {
struct input_config *new_config =
new_input_config(current_input_config->identifier);
- if (strcasecmp(argv[0], "enabled") == 0) {
+ if (parse_boolean(argv[0], true)) {
new_config->dwt = LIBINPUT_CONFIG_DWT_ENABLED;
- } else if (strcasecmp(argv[0], "disabled") == 0) {
- new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
} else {
- free_input_config(new_config);
- return cmd_results_new(CMD_INVALID, "dwt",
- "Expected 'dwt <enabled|disabled>'");
+ new_config->dwt = LIBINPUT_CONFIG_DWT_DISABLED;
}
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 @@
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
+#include "util.h"
struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -18,15 +19,7 @@ struct cmd_results *input_cmd_left_handed(int argc, char **argv) {
struct input_config *new_config =
new_input_config(current_input_config->identifier);
- if (strcasecmp(argv[0], "enabled") == 0) {
- new_config->left_handed = 1;
- } else if (strcasecmp(argv[0], "disabled") == 0) {
- new_config->left_handed = 0;
- } else {
- free_input_config(new_config);
- return cmd_results_new(CMD_INVALID, "left_handed",
- "Expected 'left_handed <enabled|disabled>'");
- }
+ new_config->left_handed = parse_boolean(argv[0], true);
apply_input_config(new_config);
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 @@
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
+#include "util.h"
struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -18,15 +19,11 @@ struct cmd_results *input_cmd_middle_emulation(int argc, char **argv) {
struct input_config *new_config =
new_input_config(current_input_config->identifier);
- if (strcasecmp(argv[0], "enabled") == 0) {
+ if (parse_boolean(argv[0], true)) {
new_config->middle_emulation = LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED;
- } else if (strcasecmp(argv[0], "disabled") == 0) {
+ } else {
new_config->middle_emulation =
LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
- } else {
- free_input_config(new_config);
- return cmd_results_new(CMD_INVALID, "middle_emulation",
- "Expected 'middle_emulation <enabled|disabled>'");
}
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 @@
#include "sway/config.h"
#include "sway/commands.h"
#include "sway/input/input-manager.h"
+#include "util.h"
struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -18,15 +19,7 @@ struct cmd_results *input_cmd_natural_scroll(int argc, char **argv) {
struct input_config *new_config =
new_input_config(current_input_config->identifier);
- if (strcasecmp(argv[0], "enabled") == 0) {
- new_config->natural_scroll = 1;
- } else if (strcasecmp(argv[0], "disabled") == 0) {
- new_config->natural_scroll = 0;
- } else {
- free_input_config(new_config);
- return cmd_results_new(CMD_INVALID, "natural_scroll",
- "Expected 'natural_scroll <enabled|disabled>'");
- }
+ new_config->natural_scroll = parse_boolean(argv[0], true);
apply_input_config(new_config);
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 @@
#include "sway/commands.h"
#include "sway/input/input-manager.h"
#include "log.h"
+#include "util.h"
struct cmd_results *input_cmd_tap(int argc, char **argv) {
struct cmd_results *error = NULL;
@@ -18,14 +19,10 @@ struct cmd_results *input_cmd_tap(int argc, char **argv) {
struct input_config *new_config =
new_input_config(current_input_config->identifier);
- if (strcasecmp(argv[0], "enabled") == 0) {
+ if (parse_boolean(argv[0], true)) {
new_config->tap = LIBINPUT_CONFIG_TAP_ENABLED;
- } else if (strcasecmp(argv[0], "disabled") == 0) {
- new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
} else {
- free_input_config(new_config);
- return cmd_results_new(CMD_INVALID, "tap",
- "Expected 'tap <enabled|disabled>'");
+ new_config->tap = LIBINPUT_CONFIG_TAP_DISABLED;
}
wlr_log(WLR_DEBUG, "apply-tap for device: %s",