aboutsummaryrefslogtreecommitdiff
path: root/input.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-04-20 16:23:20 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-04-20 16:23:20 +0000
commit0504a3e71a2ead60c8623daac1d61ac74ba6bfc6 (patch)
treeb14db599fb9a5cd8ad0ba160021e7c6ee3b7fba7 /input.c
parentcsi: implement CSI > 4n (reset modifyOtherKeys) (diff)
input: copy libxkbcommon’s keysym_is_modifier()
When determining whether a keysym is a modifier (to skip hiding the pointer when [mouse].hide-when-typing=yes), use the same matching logic xkbcommon does. This function, xkb_keysym_is_modifier() is unfortunately not part of the public API, which is why we copy it instead.
Diffstat (limited to 'input.c')
-rw-r--r--input.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/input.c b/input.c
index 9981ecee..e3dc1805 100644
--- a/input.c
+++ b/input.c
@@ -1253,6 +1253,18 @@ emit_escapes:
return term_to_slave(term, buf, sizeof(buf) - left);
}
+/* Copied from libxkbcommon (internal function) */
+static bool
+keysym_is_modifier(xkb_keysym_t keysym)
+{
+ return
+ (keysym >= XKB_KEY_Shift_L && keysym <= XKB_KEY_Hyper_R) ||
+ /* libX11 only goes upto XKB_KEY_ISO_Level5_Lock. */
+ (keysym >= XKB_KEY_ISO_Lock && keysym <= XKB_KEY_ISO_Last_Group_Lock) ||
+ keysym == XKB_KEY_Mode_switch ||
+ keysym == XKB_KEY_Num_Lock;
+}
+
static void
key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
uint32_t key, uint32_t state)
@@ -1277,17 +1289,7 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->kbd.xkb_state, key);
- if (pressed && term->conf->mouse.hide_when_typing &&
-
- /* TODO: better way to detect modifiers */
- sym != XKB_KEY_Shift_L && sym != XKB_KEY_Shift_R &&
- sym != XKB_KEY_Control_L && sym != XKB_KEY_Control_R &&
- sym != XKB_KEY_Alt_L && sym != XKB_KEY_Alt_R &&
- sym != XKB_KEY_ISO_Level3_Shift &&
- sym != XKB_KEY_Super_L && sym != XKB_KEY_Super_R &&
- sym != XKB_KEY_Meta_L && sym != XKB_KEY_Meta_R &&
- sym != XKB_KEY_Menu)
- {
+ if (pressed && term->conf->mouse.hide_when_typing && !keysym_is_modifier(sym)) {
seat->pointer.hidden = true;
term_xcursor_update_for_seat(term, seat);
}