aboutsummaryrefslogtreecommitdiff
path: root/sway/commands
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/seat/cursor.c49
-rw-r--r--sway/commands/tiling_drag_threshold.c22
2 files changed, 59 insertions, 12 deletions
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c
index 495c2338..b4728543 100644
--- a/sway/commands/seat/cursor.c
+++ b/sway/commands/seat/cursor.c
@@ -17,18 +17,8 @@ static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or "
"'cursor <set> <x> <y>' or "
"'curor <press|release> <left|right|1|2|3...>'";
-struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
- struct cmd_results *error = NULL;
- if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
- return error;
- }
- struct sway_seat *seat = config->handler_context.seat;
- if (!seat) {
- return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
- }
-
- struct sway_cursor *cursor = seat->cursor;
-
+static struct cmd_results *handle_command(struct sway_cursor *cursor,
+ int argc, char **argv) {
if (strcasecmp(argv[0], "move") == 0) {
if (argc < 3) {
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
@@ -50,6 +40,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
if (argc < 2) {
return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
}
+ struct cmd_results *error = NULL;
if ((error = press_or_release(cursor, argv[0], argv[1]))) {
return error;
}
@@ -58,6 +49,40 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
}
+struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
+ return error;
+ }
+ struct seat_config *sc = config->handler_context.seat_config;
+ if (!sc) {
+ return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
+ }
+
+ if (config->reading || !config->active) {
+ return cmd_results_new(CMD_DEFER, NULL, NULL);
+ }
+
+ if (strcmp(sc->name, "*") != 0) {
+ struct sway_seat *seat = input_manager_get_seat(sc->name);
+ if (!seat) {
+ return cmd_results_new(CMD_FAILURE, "cursor",
+ "Failed to get seat");
+ }
+ error = handle_command(seat->cursor, argc, argv);
+ } else {
+ struct sway_seat *seat = NULL;
+ wl_list_for_each(seat, &server.input->seats, link) {
+ error = handle_command(seat->cursor, argc, argv);
+ if ((error && error->status != CMD_SUCCESS)) {
+ break;
+ }
+ }
+ }
+
+ return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
+
static struct cmd_results *press_or_release(struct sway_cursor *cursor,
char *action, char *button_str) {
enum wlr_button_state state;
diff --git a/sway/commands/tiling_drag_threshold.c b/sway/commands/tiling_drag_threshold.c
new file mode 100644
index 00000000..6b0531c3
--- /dev/null
+++ b/sway/commands/tiling_drag_threshold.c
@@ -0,0 +1,22 @@
+#include <string.h>
+#include "sway/commands.h"
+#include "sway/config.h"
+#include "log.h"
+
+struct cmd_results *cmd_tiling_drag_threshold(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "tiling_drag_threshold", EXPECTED_EQUAL_TO, 1))) {
+ return error;
+ }
+
+ char *inv;
+ int value = strtol(argv[0], &inv, 10);
+ if (*inv != '\0' || value < 0) {
+ return cmd_results_new(CMD_INVALID, "tiling_drag_threshold",
+ "Invalid threshold specified");
+ }
+
+ config->tiling_drag_threshold = value;
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}