diff options
author | Brian Ashworth <bosrsf04@gmail.com> | 2018-12-17 15:37:15 -0500 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-12-25 13:31:56 +0100 |
commit | 5fca74a1f1704281e86114b567707486875c4e05 (patch) | |
tree | 706f16acd2cc9d1f45e7378bfa1cbe8082c2472e /sway/commands | |
parent | a223030b70c8e360f81b820244705e007e3ac1ec (diff) | |
download | sway-5fca74a1f1704281e86114b567707486875c4e05.tar.xz |
Implement hide_cursor <timeout> command
Allows the cursor to be hidden after a specified timeout in
milliseconds
Diffstat (limited to 'sway/commands')
-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 @@ +#define _POSIX_C_SOURCE 200809L +#include <string.h> +#include "sway/commands.h" +#include "sway/config.h" +#include "sway/input/cursor.h" +#include "sway/input/seat.h" +#include "stringop.h" + +struct cmd_results *cmd_hide_cursor(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) { + return error; + } + + char *end; + int timeout = strtol(argv[0], &end, 10); + if (*end) { + return cmd_results_new(CMD_INVALID, "hide_cursor", + "Expected an integer timeout"); + } + if (timeout < 100 && timeout != 0) { + timeout = 100; + } + config->hide_cursor_timeout = timeout; + + struct sway_seat *seat; + wl_list_for_each(seat, &server.input->seats, link) { + wl_event_source_timer_update(seat->cursor->hide_source, + config->hide_cursor_timeout); + } + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} |