diff options
author | Tamir Zahavi-Brunner <tamir.z3@gmail.com> | 2020-09-07 01:44:13 +0300 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2020-10-30 09:59:54 +0100 |
commit | 96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3 (patch) | |
tree | ac763cde133816f3bd8218eccbc352416ce88a5f /include | |
parent | output: Revert implementation of evacuate_sticky() (diff) | |
download | sway-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 'include')
-rw-r--r-- | include/sway/config.h | 7 | ||||
-rw-r--r-- | include/sway/input/cursor.h | 6 |
2 files changed, 13 insertions, 0 deletions
diff --git a/include/sway/config.h b/include/sway/config.h index 473f723b..59f22ae2 100644 --- a/include/sway/config.h +++ b/include/sway/config.h | |||
@@ -181,6 +181,12 @@ struct seat_attachment_config { | |||
181 | // TODO other things are configured here for some reason | 181 | // TODO other things are configured here for some reason |
182 | }; | 182 | }; |
183 | 183 | ||
184 | enum seat_config_hide_cursor_when_typing { | ||
185 | HIDE_WHEN_TYPING_DEFAULT, // the default is currently disabled | ||
186 | HIDE_WHEN_TYPING_ENABLE, | ||
187 | HIDE_WHEN_TYPING_DISABLE, | ||
188 | }; | ||
189 | |||
184 | enum seat_config_allow_constrain { | 190 | enum seat_config_allow_constrain { |
185 | CONSTRAIN_DEFAULT, // the default is currently enabled | 191 | CONSTRAIN_DEFAULT, // the default is currently enabled |
186 | CONSTRAIN_ENABLE, | 192 | CONSTRAIN_ENABLE, |
@@ -216,6 +222,7 @@ struct seat_config { | |||
216 | int fallback; // -1 means not set | 222 | int fallback; // -1 means not set |
217 | list_t *attachments; // list of seat_attachment configs | 223 | list_t *attachments; // list of seat_attachment configs |
218 | int hide_cursor_timeout; | 224 | int hide_cursor_timeout; |
225 | enum seat_config_hide_cursor_when_typing hide_cursor_when_typing; | ||
219 | enum seat_config_allow_constrain allow_constrain; | 226 | enum seat_config_allow_constrain allow_constrain; |
220 | enum seat_config_shortcuts_inhibit shortcuts_inhibit; | 227 | enum seat_config_shortcuts_inhibit shortcuts_inhibit; |
221 | enum seat_keyboard_grouping keyboard_grouping; | 228 | enum seat_keyboard_grouping keyboard_grouping; |
diff --git a/include/sway/input/cursor.h b/include/sway/input/cursor.h index 4c130faf..ca3c6f4b 100644 --- a/include/sway/input/cursor.h +++ b/include/sway/input/cursor.h | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <wlr/types/wlr_pointer_gestures_v1.h> | 6 | #include <wlr/types/wlr_pointer_gestures_v1.h> |
7 | #include <wlr/types/wlr_surface.h> | 7 | #include <wlr/types/wlr_surface.h> |
8 | #include "sway/input/seat.h" | 8 | #include "sway/input/seat.h" |
9 | #include "config.h" | ||
9 | 10 | ||
10 | #define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32 | 11 | #define SWAY_CURSOR_PRESSED_BUTTONS_CAP 32 |
11 | 12 | ||
@@ -68,6 +69,10 @@ struct sway_cursor { | |||
68 | 69 | ||
69 | struct wl_event_source *hide_source; | 70 | struct wl_event_source *hide_source; |
70 | bool hidden; | 71 | bool hidden; |
72 | // This field is just a cache of the field in seat_config in order to avoid | ||
73 | // costly seat_config lookups on every keypress. HIDE_WHEN_TYPING_DEFAULT | ||
74 | // indicates that there is no cached value. | ||
75 | enum seat_config_hide_cursor_when_typing hide_when_typing; | ||
71 | 76 | ||
72 | size_t pressed_button_count; | 77 | size_t pressed_button_count; |
73 | }; | 78 | }; |
@@ -94,6 +99,7 @@ void cursor_handle_activity(struct sway_cursor *cursor, | |||
94 | struct wlr_input_device *device); | 99 | struct wlr_input_device *device); |
95 | void cursor_unhide(struct sway_cursor *cursor); | 100 | void cursor_unhide(struct sway_cursor *cursor); |
96 | int cursor_get_timeout(struct sway_cursor *cursor); | 101 | int cursor_get_timeout(struct sway_cursor *cursor); |
102 | void cursor_notify_key_press(struct sway_cursor *cursor); | ||
97 | 103 | ||
98 | void dispatch_cursor_button(struct sway_cursor *cursor, | 104 | void dispatch_cursor_button(struct sway_cursor *cursor, |
99 | struct wlr_input_device *device, uint32_t time_msec, uint32_t button, | 105 | struct wlr_input_device *device, uint32_t time_msec, uint32_t button, |