From cfeed32c4e0471e9c11a4f5a68c8a0844e471c6d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 31 Aug 2015 10:54:07 -0400 Subject: [PATCH] wayland: Trivial refactor Break out a stop_key_repeat function instead of open-coding this in several places. --- gdk/wayland/gdkdevice-wayland.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c index 9b190f2277..3a9c334e33 100644 --- a/gdk/wayland/gdkdevice-wayland.c +++ b/gdk/wayland/gdkdevice-wayland.c @@ -1333,6 +1333,16 @@ get_key_repeat (GdkWaylandDeviceData *device, return repeat; } +static void +stop_key_repeat (GdkWaylandDeviceData *device) +{ + if (device->repeat_timer) + { + g_source_remove (device->repeat_timer); + device->repeat_timer = 0; + } +} + static gboolean deliver_key_event (GdkWaylandDeviceData *device, uint32_t time_, @@ -1387,11 +1397,7 @@ deliver_key_event (GdkWaylandDeviceData *device, if (state == 0) { - if (device->repeat_timer) - { - g_source_remove (device->repeat_timer); - device->repeat_timer = 0; - } + stop_key_repeat (device); return FALSE; } else @@ -1399,11 +1405,7 @@ deliver_key_event (GdkWaylandDeviceData *device, switch (device->repeat_count) { case 1: - if (device->repeat_timer) - { - g_source_remove (device->repeat_timer); - device->repeat_timer = 0; - } + stop_key_repeat (device); device->repeat_timer = gdk_threads_add_timeout (delay, keyboard_repeat, device); g_source_set_name_by_id (device->repeat_timer, "[gtk+] keyboard_repeat");