aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands
diff options
context:
space:
mode:
authorLibravatar Tamir Zahavi-Brunner <tamir.z3@gmail.com>2020-09-07 01:44:13 +0300
committerLibravatar Simon Ser <contact@emersion.fr>2020-10-30 09:59:54 +0100
commit96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3 (patch)
treeac763cde133816f3bd8218eccbc352416ce88a5f /sway/commands
parentoutput: Revert implementation of evacuate_sticky() (diff)
downloadsway-96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3.tar.gz
sway-96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3.tar.zst
sway-96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3.zip
hide_cursor: Add an option to hide when typing
Add an option for the `hide_cursor` command to hide the cursor when typing, i.e. whenever a key is pressed.
Diffstat (limited to 'sway/commands')
-rw-r--r--sway/commands/seat/hide_cursor.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/sway/commands/seat/hide_cursor.c b/sway/commands/seat/hide_cursor.c
index 3bfce697..e09b82d9 100644
--- a/sway/commands/seat/hide_cursor.c
+++ b/sway/commands/seat/hide_cursor.c
@@ -3,26 +3,48 @@
3#include "sway/commands.h" 3#include "sway/commands.h"
4#include "sway/config.h" 4#include "sway/config.h"
5#include "sway/input/seat.h" 5#include "sway/input/seat.h"
6#include "sway/input/cursor.h"
7#include "sway/server.h"
6#include "stringop.h" 8#include "stringop.h"
9#include "util.h"
7 10
8struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) { 11struct cmd_results *seat_cmd_hide_cursor(int argc, char **argv) {
9 struct cmd_results *error = NULL; 12 struct cmd_results *error = NULL;
10 if ((error = checkarg(argc, "hide_cursor", EXPECTED_EQUAL_TO, 1))) { 13 if ((error = checkarg(argc, "hide_cursor", EXPECTED_AT_LEAST, 1))) {
11 return error; 14 return error;
12 } 15 }
13 if (!config->handler_context.seat_config) { 16 if ((error = checkarg(argc, "hide_cursor", EXPECTED_AT_MOST, 2))) {
17 return error;
18 }
19 struct seat_config *seat_config = config->handler_context.seat_config;
20 if (!seat_config) {
14 return cmd_results_new(CMD_FAILURE, "No seat defined"); 21 return cmd_results_new(CMD_FAILURE, "No seat defined");
15 } 22 }
16 23
17 char *end; 24 if (argc == 1) {
18 int timeout = strtol(argv[0], &end, 10); 25 char *end;
19 if (*end) { 26 int timeout = strtol(argv[0], &end, 10);
20 return cmd_results_new(CMD_INVALID, "Expected an integer timeout"); 27 if (*end) {
21 } 28 return cmd_results_new(CMD_INVALID, "Expected an integer timeout");
22 if (timeout < 100 && timeout != 0) { 29 }
23 timeout = 100; 30 if (timeout < 100 && timeout != 0) {
31 timeout = 100;
32 }
33 seat_config->hide_cursor_timeout = timeout;
34 } else {
35 if (strcmp(argv[0], "when-typing") != 0) {
36 return cmd_results_new(CMD_INVALID,
37 "Expected 'hide_cursor <timeout>|when-typing [enable|disable]'");
38 }
39 seat_config->hide_cursor_when_typing = parse_boolean(argv[1], true) ?
40 HIDE_WHEN_TYPING_ENABLE : HIDE_WHEN_TYPING_DISABLE;
41
42 // Invalidate all the caches for this config
43 struct sway_seat *seat = NULL;
44 wl_list_for_each(seat, &server.input->seats, link) {
45 seat->cursor->hide_when_typing = HIDE_WHEN_TYPING_DEFAULT;
46 }
24 } 47 }
25 config->handler_context.seat_config->hide_cursor_timeout = timeout;
26 48
27 return cmd_results_new(CMD_SUCCESS, NULL); 49 return cmd_results_new(CMD_SUCCESS, NULL);
28} 50}