mirror of
https://github.com/labwc/labwc.git
synced 2025-11-01 22:58:47 -04:00
keyboard: include pressed modifiers in bound set
This prevents applications from seeing and handling the release event for a modifier key that was part of a keybinding (e.g. Firefox displays its menu bar for a lone Alt press + release).
This commit is contained in:
parent
fe9491443c
commit
98bf316ee6
3 changed files with 18 additions and 5 deletions
|
|
@ -19,7 +19,7 @@
|
|||
uint32_t *key_state_pressed_sent_keycodes(void);
|
||||
int key_state_nr_pressed_sent_keycodes(void);
|
||||
|
||||
void key_state_set_pressed(uint32_t keycode, bool ispressed);
|
||||
void key_state_set_pressed(uint32_t keycode, bool is_pressed, bool is_modifier);
|
||||
void key_state_store_pressed_key_as_bound(uint32_t keycode);
|
||||
bool key_state_corresponding_press_event_was_bound(uint32_t keycode);
|
||||
void key_state_bound_key_remove(uint32_t keycode);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct key_array {
|
|||
int nr_keys;
|
||||
};
|
||||
|
||||
static struct key_array pressed, bound, pressed_sent;
|
||||
static struct key_array pressed, pressed_mods, bound, pressed_sent;
|
||||
|
||||
static bool
|
||||
key_present(struct key_array *array, uint32_t keycode)
|
||||
|
|
@ -69,12 +69,16 @@ key_state_nr_pressed_sent_keycodes(void)
|
|||
}
|
||||
|
||||
void
|
||||
key_state_set_pressed(uint32_t keycode, bool ispressed)
|
||||
key_state_set_pressed(uint32_t keycode, bool is_pressed, bool is_modifier)
|
||||
{
|
||||
if (ispressed) {
|
||||
if (is_pressed) {
|
||||
add_key(&pressed, keycode);
|
||||
if (is_modifier) {
|
||||
add_key(&pressed_mods, keycode);
|
||||
}
|
||||
} else {
|
||||
remove_key(&pressed, keycode);
|
||||
remove_key(&pressed_mods, keycode);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,6 +86,15 @@ void
|
|||
key_state_store_pressed_key_as_bound(uint32_t keycode)
|
||||
{
|
||||
add_key(&bound, keycode);
|
||||
/*
|
||||
* Also store any pressed modifiers as bound. This prevents
|
||||
* applications from seeing and handling the release event for
|
||||
* a modifier key that was part of a keybinding (e.g. Firefox
|
||||
* displays its menu bar for a lone Alt press + release).
|
||||
*/
|
||||
for (int i = 0; i < pressed_mods.nr_keys; ++i) {
|
||||
add_key(&bound, pressed_mods.keys[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ handle_compositor_keybindings(struct keyboard *keyboard,
|
|||
}
|
||||
|
||||
key_state_set_pressed(event->keycode,
|
||||
event->state == WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||
event->state == WL_KEYBOARD_KEY_STATE_PRESSED, is_modifier);
|
||||
|
||||
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue