aboutsummaryrefslogtreecommitdiff
path: root/sway/input
diff options
context:
space:
mode:
authorTamir Zahavi-Brunner <tamir.z3@gmail.com>2020-09-07 01:44:13 +0300
committerSimon Ser <contact@emersion.fr>2020-10-30 09:59:54 +0100
commit96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3 (patch)
treeac763cde133816f3bd8218eccbc352416ce88a5f /sway/input
parent4799cb09606ba8b3cc3969c24637b3c6c9eac485 (diff)
downloadsway-96578aa91e9856bfb3e2d26fb7a625ff7c9b79e3.tar.xz
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/input')
-rw-r--r--sway/input/cursor.c26
-rw-r--r--sway/input/keyboard.c5
2 files changed, 31 insertions, 0 deletions
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index e47410a5..b168afc5 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -253,6 +253,32 @@ int cursor_get_timeout(struct sway_cursor *cursor) {
return timeout;
}
+void cursor_notify_key_press(struct sway_cursor *cursor) {
+ if (cursor->hidden) {
+ return;
+ }
+
+ if (cursor->hide_when_typing == HIDE_WHEN_TYPING_DEFAULT) {
+ // No cached value, need to lookup in the seat_config
+ const struct seat_config *seat_config = seat_get_config(cursor->seat);
+ if (!seat_config) {
+ seat_config = seat_get_config_by_name("*");
+ if (!seat_config) {
+ return;
+ }
+ }
+ cursor->hide_when_typing = seat_config->hide_cursor_when_typing;
+ // The default is currently disabled
+ if (cursor->hide_when_typing == HIDE_WHEN_TYPING_DEFAULT) {
+ cursor->hide_when_typing = HIDE_WHEN_TYPING_DISABLE;
+ }
+ }
+
+ if (cursor->hide_when_typing == HIDE_WHEN_TYPING_ENABLE) {
+ cursor_hide(cursor);
+ }
+}
+
static enum sway_input_idle_source idle_source_from_device(
struct wlr_input_device *device) {
switch (device->type) {
diff --git a/sway/input/keyboard.c b/sway/input/keyboard.c
index 541fc90d..ae30e83a 100644
--- a/sway/input/keyboard.c
+++ b/sway/input/keyboard.c
@@ -13,6 +13,7 @@
#include "sway/input/input-manager.h"
#include "sway/input/keyboard.h"
#include "sway/input/seat.h"
+#include "sway/input/cursor.h"
#include "sway/ipc-server.h"
#include "log.h"
@@ -392,6 +393,10 @@ static void handle_key_event(struct sway_keyboard *keyboard,
keyboard_shortcuts_inhibitor_get_for_focused_surface(seat);
bool shortcuts_inhibited = sway_inhibitor && sway_inhibitor->inhibitor->active;
+ if (event->state == WLR_KEY_PRESSED) {
+ cursor_notify_key_press(seat->cursor);
+ }
+
// Identify new keycode, raw keysym(s), and translated keysym(s)
struct key_info keyinfo;
update_keyboard_state(keyboard, event->keycode, event->state, &keyinfo);