From 4d88c957905e7f6b2c8188d218ca22b3e6986fe4 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Thu, 27 Dec 2018 00:32:15 -0500 Subject: hide_cursor: change to a seat subcommand This makes hide_cursor a seat subcommand, which allows for seat specific timeouts. --- sway/commands/hide_cursor.c | 33 --------------------------------- sway/commands/seat.c | 1 + sway/commands/seat/hide_cursor.c | 29 +++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 33 deletions(-) delete mode 100644 sway/commands/hide_cursor.c create mode 100644 sway/commands/seat/hide_cursor.c (limited to 'sway/commands') diff --git a/sway/commands/hide_cursor.c b/sway/commands/hide_cursor.c deleted file mode 100644 index 3778fcff..00000000 --- a/sway/commands/hide_cursor.c +++ /dev/null @@ -1,33 +0,0 @@ -#define _POSIX_C_SOURCE 200809L -#include -#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); -} diff --git a/sway/commands/seat.c b/sway/commands/seat.c index 56acd204..3e7ffed9 100644 --- a/sway/commands/seat.c +++ b/sway/commands/seat.c @@ -10,6 +10,7 @@ static struct cmd_handler seat_handlers[] = { { "attach", seat_cmd_attach }, { "cursor", seat_cmd_cursor }, { "fallback", seat_cmd_fallback }, + { "hide_cursor", seat_cmd_hide_cursor }, }; struct cmd_results *cmd_seat(int argc, char **argv) { diff --git a/sway/commands/seat/hide_cursor.c b/sway/commands/seat/hide_cursor.c new file mode 100644 index 00000000..343573b5 --- /dev/null +++ b/sway/commands/seat/hide_cursor.c @@ -0,0 +1,29 @@ +#define _POSIX_C_SOURCE 200809L +#include +#include "sway/commands.h" +#include "sway/config.h" +#include "sway/input/seat.h" +#include "stringop.h" + +struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) { + struct cmd_results *error = NULL; + if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) { + return error; + } + if (!config->handler_context.seat_config) { + return cmd_results_new(CMD_FAILURE, "hide_cursor", "No seat defined"); + } + + 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->handler_context.seat_config->hide_cursor_timeout = timeout; + + return cmd_results_new(CMD_SUCCESS, NULL, NULL); +} -- cgit v1.2.3