[gtk+/gtk-3-20] wayland: avoid jitter in keyboard repeat
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-3-20] wayland: avoid jitter in keyboard repeat
- Date: Thu, 5 May 2016 19:21:08 +0000 (UTC)
commit 113ce66151581b55a9c9c45161ed86d61cbe7d39
Author: Christian Hergert <chergert redhat com>
Date: Mon Apr 25 18:10:09 2016 -0700
wayland: avoid jitter in keyboard repeat
When synthesizing keyboard repeat, we can potentially drift further from
the mark depending on the timing of the frame callback and how long it
took to deliver the event.
This patch attempts to reduce this by tracking from a stable epoch the
time of our next keyboard repeat.
https://bugzilla.gnome.org/show_bug.cgi?id=765567
gdk/wayland/gdkdevice-wayland.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 3d3b4d6..db2a695 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -110,6 +110,7 @@ struct _GdkWaylandSeat
guint32 repeat_timer;
guint32 repeat_key;
guint32 repeat_count;
+ gint64 repeat_deadline;
GSettings *keyboard_settings;
guint cursor_timeout_id;
@@ -1726,6 +1727,9 @@ deliver_key_event (GdkWaylandSeat *seat,
GdkKeymap *keymap;
xkb_keysym_t sym;
guint delay, interval, timeout;
+ gint64 begin_time, now;
+
+ begin_time = g_get_monotonic_time ();
stop_key_repeat (seat);
@@ -1775,10 +1779,20 @@ deliver_key_event (GdkWaylandSeat *seat,
seat->repeat_count++;
seat->repeat_key = key;
+ interval *= 1000L;
+ delay *= 1000L;
+
+ now = g_get_monotonic_time ();
+
if (seat->repeat_count == 1)
- timeout = delay;
+ seat->repeat_deadline = begin_time + delay;
+ else if (seat->repeat_deadline + interval > now)
+ seat->repeat_deadline += interval;
else
- timeout = interval;
+ /* frame delay caused us to miss repeat deadline */
+ seat->repeat_deadline = now;
+
+ timeout = (seat->repeat_deadline - now) / 1000L;
seat->repeat_timer =
gdk_threads_add_timeout (timeout, keyboard_repeat, seat);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]