diff options
Diffstat (limited to 'sway/commands/seat')
-rw-r--r-- | sway/commands/seat/attach.c | 6 | ||||
-rw-r--r-- | sway/commands/seat/cursor.c | 30 | ||||
-rw-r--r-- | sway/commands/seat/fallback.c | 4 | ||||
-rw-r--r-- | sway/commands/seat/hide_cursor.c | 7 |
4 files changed, 22 insertions, 25 deletions
diff --git a/sway/commands/seat/attach.c b/sway/commands/seat/attach.c index 0fb17f1d..1e509a58 100644 --- a/sway/commands/seat/attach.c +++ b/sway/commands/seat/attach.c | |||
@@ -10,16 +10,16 @@ struct cmd_results *seat_cmd_attach(int argc, char **argv) { | |||
10 | return error; | 10 | return error; |
11 | } | 11 | } |
12 | if (!config->handler_context.seat_config) { | 12 | if (!config->handler_context.seat_config) { |
13 | return cmd_results_new(CMD_FAILURE, "attach", "No seat defined"); | 13 | return cmd_results_new(CMD_FAILURE, "No seat defined"); |
14 | } | 14 | } |
15 | 15 | ||
16 | struct seat_attachment_config *attachment = seat_attachment_config_new(); | 16 | struct seat_attachment_config *attachment = seat_attachment_config_new(); |
17 | if (!attachment) { | 17 | if (!attachment) { |
18 | return cmd_results_new(CMD_FAILURE, "attach", | 18 | return cmd_results_new(CMD_FAILURE, |
19 | "Failed to allocate seat attachment config"); | 19 | "Failed to allocate seat attachment config"); |
20 | } | 20 | } |
21 | attachment->identifier = strdup(argv[0]); | 21 | attachment->identifier = strdup(argv[0]); |
22 | list_add(config->handler_context.seat_config->attachments, attachment); | 22 | list_add(config->handler_context.seat_config->attachments, attachment); |
23 | 23 | ||
24 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 24 | return cmd_results_new(CMD_SUCCESS, NULL); |
25 | } | 25 | } |
diff --git a/sway/commands/seat/cursor.c b/sway/commands/seat/cursor.c index 8d9e426a..4f805b22 100644 --- a/sway/commands/seat/cursor.c +++ b/sway/commands/seat/cursor.c | |||
@@ -10,7 +10,7 @@ | |||
10 | static struct cmd_results *press_or_release(struct sway_cursor *cursor, | 10 | static struct cmd_results *press_or_release(struct sway_cursor *cursor, |
11 | char *action, char *button_str); | 11 | char *action, char *button_str); |
12 | 12 | ||
13 | static const char *expected_syntax = "Expected 'cursor <move> <x> <y>' or " | 13 | static const char expected_syntax[] = "Expected 'cursor <move> <x> <y>' or " |
14 | "'cursor <set> <x> <y>' or " | 14 | "'cursor <set> <x> <y>' or " |
15 | "'curor <press|release> <button[1-9]|event-name-or-code>'"; | 15 | "'curor <press|release> <button[1-9]|event-name-or-code>'"; |
16 | 16 | ||
@@ -18,7 +18,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
18 | int argc, char **argv) { | 18 | int argc, char **argv) { |
19 | if (strcasecmp(argv[0], "move") == 0) { | 19 | if (strcasecmp(argv[0], "move") == 0) { |
20 | if (argc < 3) { | 20 | if (argc < 3) { |
21 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 21 | return cmd_results_new(CMD_INVALID, expected_syntax); |
22 | } | 22 | } |
23 | int delta_x = strtol(argv[1], NULL, 10); | 23 | int delta_x = strtol(argv[1], NULL, 10); |
24 | int delta_y = strtol(argv[2], NULL, 10); | 24 | int delta_y = strtol(argv[2], NULL, 10); |
@@ -26,7 +26,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
26 | cursor_rebase(cursor); | 26 | cursor_rebase(cursor); |
27 | } else if (strcasecmp(argv[0], "set") == 0) { | 27 | } else if (strcasecmp(argv[0], "set") == 0) { |
28 | if (argc < 3) { | 28 | if (argc < 3) { |
29 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 29 | return cmd_results_new(CMD_INVALID, expected_syntax); |
30 | } | 30 | } |
31 | // map absolute coords (0..1,0..1) to root container coords | 31 | // map absolute coords (0..1,0..1) to root container coords |
32 | float x = strtof(argv[1], NULL) / root->width; | 32 | float x = strtof(argv[1], NULL) / root->width; |
@@ -35,7 +35,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
35 | cursor_rebase(cursor); | 35 | cursor_rebase(cursor); |
36 | } else { | 36 | } else { |
37 | if (argc < 2) { | 37 | if (argc < 2) { |
38 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 38 | return cmd_results_new(CMD_INVALID, expected_syntax); |
39 | } | 39 | } |
40 | struct cmd_results *error = NULL; | 40 | struct cmd_results *error = NULL; |
41 | if ((error = press_or_release(cursor, argv[0], argv[1]))) { | 41 | if ((error = press_or_release(cursor, argv[0], argv[1]))) { |
@@ -43,7 +43,7 @@ static struct cmd_results *handle_command(struct sway_cursor *cursor, | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 46 | return cmd_results_new(CMD_SUCCESS, NULL); |
47 | } | 47 | } |
48 | 48 | ||
49 | struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | 49 | struct cmd_results *seat_cmd_cursor(int argc, char **argv) { |
@@ -53,18 +53,17 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | |||
53 | } | 53 | } |
54 | struct seat_config *sc = config->handler_context.seat_config; | 54 | struct seat_config *sc = config->handler_context.seat_config; |
55 | if (!sc) { | 55 | if (!sc) { |
56 | return cmd_results_new(CMD_FAILURE, "cursor", "No seat defined"); | 56 | return cmd_results_new(CMD_FAILURE, "No seat defined"); |
57 | } | 57 | } |
58 | 58 | ||
59 | if (config->reading || !config->active) { | 59 | if (config->reading || !config->active) { |
60 | return cmd_results_new(CMD_DEFER, NULL, NULL); | 60 | return cmd_results_new(CMD_DEFER, NULL); |
61 | } | 61 | } |
62 | 62 | ||
63 | if (strcmp(sc->name, "*") != 0) { | 63 | if (strcmp(sc->name, "*") != 0) { |
64 | struct sway_seat *seat = input_manager_get_seat(sc->name); | 64 | struct sway_seat *seat = input_manager_get_seat(sc->name); |
65 | if (!seat) { | 65 | if (!seat) { |
66 | return cmd_results_new(CMD_FAILURE, "cursor", | 66 | return cmd_results_new(CMD_FAILURE, "Failed to get seat"); |
67 | "Failed to get seat"); | ||
68 | } | 67 | } |
69 | error = handle_command(seat->cursor, argc, argv); | 68 | error = handle_command(seat->cursor, argc, argv); |
70 | } else { | 69 | } else { |
@@ -77,7 +76,7 @@ struct cmd_results *seat_cmd_cursor(int argc, char **argv) { | |||
77 | } | 76 | } |
78 | } | 77 | } |
79 | 78 | ||
80 | return error ? error : cmd_results_new(CMD_SUCCESS, NULL, NULL); | 79 | return error ? error : cmd_results_new(CMD_SUCCESS, NULL); |
81 | } | 80 | } |
82 | 81 | ||
83 | static struct cmd_results *press_or_release(struct sway_cursor *cursor, | 82 | static struct cmd_results *press_or_release(struct sway_cursor *cursor, |
@@ -89,14 +88,14 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor, | |||
89 | } else if (strcasecmp(action, "release") == 0) { | 88 | } else if (strcasecmp(action, "release") == 0) { |
90 | state = WLR_BUTTON_RELEASED; | 89 | state = WLR_BUTTON_RELEASED; |
91 | } else { | 90 | } else { |
92 | return cmd_results_new(CMD_INVALID, "cursor", expected_syntax); | 91 | return cmd_results_new(CMD_INVALID, expected_syntax); |
93 | } | 92 | } |
94 | 93 | ||
95 | char *message = NULL; | 94 | char *message = NULL; |
96 | button = get_mouse_button(button_str, &message); | 95 | button = get_mouse_button(button_str, &message); |
97 | if (message) { | 96 | if (message) { |
98 | struct cmd_results *error = | 97 | struct cmd_results *error = |
99 | cmd_results_new(CMD_INVALID, "cursor", message); | 98 | cmd_results_new(CMD_INVALID, message); |
100 | free(message); | 99 | free(message); |
101 | return error; | 100 | return error; |
102 | } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN | 101 | } else if (button == SWAY_SCROLL_UP || button == SWAY_SCROLL_DOWN |
@@ -117,11 +116,10 @@ static struct cmd_results *press_or_release(struct sway_cursor *cursor, | |||
117 | .delta_discrete = delta | 116 | .delta_discrete = delta |
118 | }; | 117 | }; |
119 | dispatch_cursor_axis(cursor, &event); | 118 | dispatch_cursor_axis(cursor, &event); |
120 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 119 | return cmd_results_new(CMD_SUCCESS, NULL); |
121 | } else if (!button) { | 120 | } else if (!button) { |
122 | return cmd_results_new(CMD_INVALID, "curor", | 121 | return cmd_results_new(CMD_INVALID, "Unknown button %s", button_str); |
123 | "Unknown button %s", button_str); | ||
124 | } | 122 | } |
125 | dispatch_cursor_button(cursor, NULL, 0, button, state); | 123 | dispatch_cursor_button(cursor, NULL, 0, button, state); |
126 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 124 | return cmd_results_new(CMD_SUCCESS, NULL); |
127 | } | 125 | } |
diff --git a/sway/commands/seat/fallback.c b/sway/commands/seat/fallback.c index 8f1ab12c..0330c353 100644 --- a/sway/commands/seat/fallback.c +++ b/sway/commands/seat/fallback.c | |||
@@ -8,11 +8,11 @@ struct cmd_results *seat_cmd_fallback(int argc, char **argv) { | |||
8 | return error; | 8 | return error; |
9 | } | 9 | } |
10 | if (!config->handler_context.seat_config) { | 10 | if (!config->handler_context.seat_config) { |
11 | return cmd_results_new(CMD_FAILURE, "fallback", "No seat defined"); | 11 | return cmd_results_new(CMD_FAILURE, "No seat defined"); |
12 | } | 12 | } |
13 | 13 | ||
14 | config->handler_context.seat_config->fallback = | 14 | config->handler_context.seat_config->fallback = |
15 | parse_boolean(argv[0], false); | 15 | parse_boolean(argv[0], false); |
16 | 16 | ||
17 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 17 | return cmd_results_new(CMD_SUCCESS, NULL); |
18 | } | 18 | } |
diff --git a/sway/commands/seat/hide_cursor.c b/sway/commands/seat/hide_cursor.c index 343573b5..3bfce697 100644 --- a/sway/commands/seat/hide_cursor.c +++ b/sway/commands/seat/hide_cursor.c | |||
@@ -11,19 +11,18 @@ struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) { | |||
11 | return error; | 11 | return error; |
12 | } | 12 | } |
13 | if (!config->handler_context.seat_config) { | 13 | if (!config->handler_context.seat_config) { |
14 | return cmd_results_new(CMD_FAILURE, "hide_cursor", "No seat defined"); | 14 | return cmd_results_new(CMD_FAILURE, "No seat defined"); |
15 | } | 15 | } |
16 | 16 | ||
17 | char *end; | 17 | char *end; |
18 | int timeout = strtol(argv[0], &end, 10); | 18 | int timeout = strtol(argv[0], &end, 10); |
19 | if (*end) { | 19 | if (*end) { |
20 | return cmd_results_new(CMD_INVALID, "hide_cursor", | 20 | return cmd_results_new(CMD_INVALID, "Expected an integer timeout"); |
21 | "Expected an integer timeout"); | ||
22 | } | 21 | } |
23 | if (timeout < 100 && timeout != 0) { | 22 | if (timeout < 100 && timeout != 0) { |
24 | timeout = 100; | 23 | timeout = 100; |
25 | } | 24 | } |
26 | config->handler_context.seat_config->hide_cursor_timeout = timeout; | 25 | config->handler_context.seat_config->hide_cursor_timeout = timeout; |
27 | 26 | ||
28 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | 27 | return cmd_results_new(CMD_SUCCESS, NULL); |
29 | } | 28 | } |