mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
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.
This commit is contained in:
parent
8485cdaaaa
commit
0504a3e71a
1 changed files with 13 additions and 11 deletions
24
input.c
24
input.c
|
|
@ -1253,6 +1253,18 @@ emit_escapes:
|
||||||
return term_to_slave(term, buf, sizeof(buf) - left);
|
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
|
static void
|
||||||
key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
|
key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
|
||||||
uint32_t key, uint32_t state)
|
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);
|
xkb_keysym_t sym = xkb_state_key_get_one_sym(seat->kbd.xkb_state, key);
|
||||||
|
|
||||||
if (pressed && term->conf->mouse.hide_when_typing &&
|
if (pressed && term->conf->mouse.hide_when_typing && !keysym_is_modifier(sym)) {
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
|
||||||
seat->pointer.hidden = true;
|
seat->pointer.hidden = true;
|
||||||
term_xcursor_update_for_seat(term, seat);
|
term_xcursor_update_for_seat(term, seat);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue