[gtk+] wayland: Trivial refactor



commit cfeed32c4e0471e9c11a4f5a68c8a0844e471c6d
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Aug 31 10:54:07 2015 -0400

    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 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 9b190f2..3a9c334 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");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]