mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
keyboard: simplify key state handling
We used to store both `pressed` keys and `bound` keys and derive `pressed_sent` keys from them, which are notified to the client when switching focus. But I think this was overengineered and we can remove `pressed` keys and `bound` keys. Instead we now directly modify `pressed_sent` keys just before calling `wlr_seat_keyboard_notify_key()`. Technically we could even remove `pressed_sent` keys as they are duplicated in wlr_seat->keyboard_state.keyboard->keycodes, but we keep `pressed_sent` keys as it is easier to access. The only place which required `bound` keys was `handle_modifiers()`. This function checked `bound` keys to keep widnow switcher alive when Alt-Tab is pressed and only the Alt modifier is released. The window switcher is then finished when Tab key is released. I replaced the check with `(seat->keyboard_group->keyboard.num_keycodes > 0)`. This slightly changes the behavior; when Alt-Tab and any other key e.g. X are pressed and Tab key and Alt modifier are released, the window switcher is now kept alive. But I don't think this breaks any workflows for users.
This commit is contained in:
parent
98b3d911eb
commit
885db240f3
5 changed files with 33 additions and 125 deletions
|
|
@ -2,9 +2,6 @@
|
|||
#ifndef LABWC_KEY_STATE_H
|
||||
#define LABWC_KEY_STATE_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
struct seat;
|
||||
|
||||
/*
|
||||
|
|
@ -16,18 +13,4 @@ struct seat;
|
|||
void key_state_indicator_update(struct seat *seat);
|
||||
void key_state_indicator_toggle(void);
|
||||
|
||||
/**
|
||||
* key_state_pressed_sent_keycodes - generate array of pressed+sent keys
|
||||
* Note: The array is generated by subtracting any bound keys from _all_ pressed
|
||||
* keys (because bound keys were not forwarded to clients).
|
||||
*/
|
||||
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 is_pressed);
|
||||
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);
|
||||
int key_state_nr_bound_keys(void);
|
||||
|
||||
#endif /* LABWC_KEY_STATE_H */
|
||||
|
|
|
|||
|
|
@ -83,6 +83,9 @@ struct seat {
|
|||
|
||||
struct lab_set bound_buttons;
|
||||
|
||||
/* Keys that have been pressed and not consumed by compositor actions */
|
||||
struct lab_set pressed_sent_keys;
|
||||
|
||||
struct {
|
||||
bool active;
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue