keyboard: Implement key repeat for keybindings

It seems that every Wayland client is expected to implement its own
key-repeat logic, rather than doing it server-side as in X11.  This
means that labwc also has to implement its own key-repeat logic for
compositor keybindings.

This is a very simplistic timer-based implementation.  It doesn't
attempt to synthesize accurate timestamps, and may lag depending
on system load, but it appears to get the job done.

v2: Use server->wl_event_loop
v3: Comments and formatting
This commit is contained in:
John Lindgren 2022-11-02 16:37:24 -04:00 committed by Johan Malm
parent b163045fa9
commit 3b55b31070
3 changed files with 62 additions and 5 deletions

View file

@ -88,6 +88,10 @@ struct keyboard {
bool is_virtual;
struct wl_listener modifier;
struct wl_listener key;
/* key repeat for compositor keybinds */
uint32_t keybind_repeat_keycode;
int32_t keybind_repeat_rate;
struct wl_event_source *keybind_repeat;
};
struct seat {
@ -533,6 +537,7 @@ struct view *desktop_focused_view(struct server *server);
void desktop_focus_topmost_mapped_view(struct server *server);
bool isfocusable(struct view *view);
void keyboard_cancel_keybind_repeat(struct keyboard *keyboard);
void keyboard_key_notify(struct wl_listener *listener, void *data);
void keyboard_modifiers_notify(struct wl_listener *listener, void *data);
void keyboard_init(struct seat *seat);