diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2012-01-14 23:48:51 -0500 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-01-16 15:36:27 -0500 |
commit | 5f07e937c8d421446763e3295df64b2afc1a354f (patch) | |
tree | 3bb262410c5f8eb2d4d47d86511484f815d770a3 /gdk | |
parent | 85da4ca5bde42af0d0f61b4e7194dd1e5d86874e (diff) | |
download | gtk+-5f07e937c8d421446763e3295df64b2afc1a354f.tar.gz |
wayland: Implement client side keyboard repeat
Diffstat (limited to 'gdk')
-rw-r--r-- | gdk/wayland/gdkdevice-wayland.c | 67 |
1 files changed, 63 insertions, 4 deletions
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 39b2417321..1e0080fa46 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -68,6 +68,9 @@ struct _GdkWaylandDevice uint32_t time; GdkWindow *pointer_grab_window; uint32_t pointer_grab_time; + guint32 repeat_timer; + guint32 repeat_key; + guint32 repeat_count; DataOffer *drag_offer; DataOffer *selection_offer; @@ -468,11 +471,13 @@ translate_keyboard_string (GdkEventKey *event) } } -static void -input_handle_key(void *data, struct wl_input_device *input_device, - uint32_t time, uint32_t key, uint32_t state) +static gboolean +keyboard_repeat (gpointer data); + +static gboolean +deliver_key_event(GdkWaylandDevice *device, + uint32_t time, uint32_t key, uint32_t state) { - GdkWaylandDevice *device = data; GdkEvent *event; uint32_t code, modifier, level; struct xkb_desc *xkb; @@ -515,6 +520,60 @@ input_handle_key(void *data, struct wl_input_device *input_device, "string %s, mods 0x%x", code, event->key.keyval, event->key.string, event->key.state)); + + device->repeat_count++; + device->repeat_key = key; + + if (state == 0) + { + if (device->repeat_timer) + { + g_source_remove (device->repeat_timer); + device->repeat_timer = 0; + } + return FALSE; + } + else if (modifier) + { + return FALSE; + } + else switch (device->repeat_count) + { + case 1: + if (device->repeat_timer) + { + g_source_remove (device->repeat_timer); + device->repeat_timer = 0; + } + + device->repeat_timer = + gdk_threads_add_timeout (400, keyboard_repeat, device); + return TRUE; + case 2: + device->repeat_timer = + gdk_threads_add_timeout (80, keyboard_repeat, device); + return FALSE; + default: + return TRUE; + } +} + +static gboolean +keyboard_repeat (gpointer data) +{ + GdkWaylandDevice *device = data; + + return deliver_key_event (device, device->time, device->repeat_key, 1); +} + +static void +input_handle_key(void *data, struct wl_input_device *input_device, + uint32_t time, uint32_t key, uint32_t state) +{ + GdkWaylandDevice *device = data; + + device->repeat_count = 0; + deliver_key_event (data, time, key, state); } static void |