aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/seat
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-12-27 12:06:35 -0500
committerLibravatar Brian Ashworth <bosrsf04@gmail.com>2018-12-29 22:02:19 -0500
commit6ec2983d9636250c69f95e4edeb03519e873e833 (patch)
tree40dffb6a9fdfda11e51de4580f090561ab8a7d92 /sway/commands/seat
parentRevamp seat configs (diff)
downloadsway-6ec2983d9636250c69f95e4edeb03519e873e833.tar.gz
sway-6ec2983d9636250c69f95e4edeb03519e873e833.tar.zst
sway-6ec2983d9636250c69f95e4edeb03519e873e833.zip
seat_cmd_cursor: work on seat name provided
Instead of simulating events on the current seat, this makes it so seat_cmd_cursor respects the seat name provided by `seat <name> cursor <args>`. It also adds support for simulating events on all seats when the wildcard is given. This also defers the command when reading the config, which allows the user to set the initial position of the cursor when the command is included in the config file.
Diffstat (limited to 'sway/commands/seat')
-rw-r--r--sway/commands/seat/cursor.c49
1 files changed, 37 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 "
17 "'cursor <set> <x> <y>' or " 17 "'cursor <set> <x> <y>' or "
18 "'curor <press|release> <left|right|1|2|3...>'"; 18 "'curor <press|release> <left|right|1|2|3...>'";
19 19
20struct cmd_results *seat_cmd_cursor(int argc, char **argv) { 20static struct cmd_results *handle_command(struct sway_cursor *cursor,
21 struct cmd_results *error = NULL; 21 int argc, char **argv) {
22 if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
23 return error;
24 }
25 struct sway_seat *seat = config->handler_context.seat;
26 if (!seat) {
27 return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
28 }
29
30 struct sway_cursor *cursor = seat->cursor;
31
32 if (strcasecmp(argv[0], "move") == 0) { 22 if (strcasecmp(argv[0], "move") == 0) {
33 if (argc < 3) { 23 if (argc < 3) {
34 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 24 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
@@ -50,6 +40,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
50 if (argc < 2) { 40 if (argc < 2) {
51 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); 41 return cmd_results_new(CMD_INVALID, "cursor", expected_syntax);
52 } 42 }
43 struct cmd_results *error = NULL;
53 if ((error = press_or_release(cursor, argv[0], argv[1]))) { 44 if ((error = press_or_release(cursor, argv[0], argv[1]))) {
54 return error; 45 return error;
55 } 46 }
@@ -58,6 +49,40 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
58 return cmd_results_new(CMD_SUCCESS, NULL, NULL); 49 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
59} 50}
60 51
52struct cmd_results *seat_cmd_cursor(int argc, char **argv) {
53 struct cmd_results *error = NULL;
54 if ((error = checkarg(argc, "cursor", EXPECTED_AT_LEAST, 2))) {
55 return error;
56 }
57 struct seat_config *sc = config->handler_context.seat_config;
58 if (!sc) {
59 return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined");
60 }
61
62 if (config->reading || !config->active) {
63 return cmd_results_new(CMD_DEFER, NULL, NULL);
64 }
65
66 if (strcmp(sc->name, "*") != 0) {
67 struct sway_seat *seat = input_manager_get_seat(sc->name);
68 if (!seat) {
69 return cmd_results_new(CMD_FAILURE, "cursor",
70 "Failed to get seat");
71 }
72 error = handle_command(seat->cursor, argc, argv);
73 } else {
74 struct sway_seat *seat = NULL;
75 wl_list_for_each(seat, &server.input->seats, link) {
76 error = handle_command(seat->cursor, argc, argv);
77 if ((error && error->status != CMD_SUCCESS)) {
78 break;
79 }
80 }
81 }
82
83 return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL);
84}
85
61static struct cmd_results *press_or_release(struct sway_cursor *cursor, 86static struct cmd_results *press_or_release(struct sway_cursor *cursor,
62 char *action, char *button_str) { 87 char *action, char *button_str) {
63 enum wlr_button_state state; 88 enum wlr_button_state state;