diff options
Diffstat (limited to 'sway/commands/hide_cursor.c')
-rw-r--r-- | sway/commands/hide_cursor.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/sway/commands/hide_cursor.c b/sway/commands/hide_cursor.c new file mode 100644 index 00000000..3778fcff --- /dev/null +++ b/sway/commands/hide_cursor.c | |||
@@ -0,0 +1,33 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include <string.h> | ||
3 | #include "sway/commands.h" | ||
4 | #include "sway/config.h" | ||
5 | #include "sway/input/cursor.h" | ||
6 | #include "sway/input/seat.h" | ||
7 | #include "stringop.h" | ||
8 | |||
9 | struct cmd_results *cmd_hide_cursor(int argc, char **argv) { | ||
10 | struct cmd_results *error = NULL; | ||
11 | if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) { | ||
12 | return error; | ||
13 | } | ||
14 | |||
15 | char *end; | ||
16 | int timeout = strtol(argv[0], &end, 10); | ||
17 | if (*end) { | ||
18 | return cmd_results_new(CMD_INVALID, "hide_cursor", | ||
19 | "Expected an integer timeout"); | ||
20 | } | ||
21 | if (timeout < 100 && timeout != 0) { | ||
22 | timeout = 100; | ||
23 | } | ||
24 | config->hide_cursor_timeout = timeout; | ||
25 | |||
26 | struct sway_seat *seat; | ||
27 | wl_list_for_each(seat, &server.input->seats, link) { | ||
28 | wl_event_source_timer_update(seat->cursor->hide_source, | ||
29 | config->hide_cursor_timeout); | ||
30 | } | ||
31 | |||
32 | return cmd_results_new(CMD_SUCCESS, NULL, NULL); | ||
33 | } | ||