[libdazzle] shortcuts: check event first



commit d8daaa9c7221e2a4072cdaa60f745121c2b2c19b
Author: Christian Hergert <chergert redhat com>
Date:   Mon Jul 17 03:43:36 2017 -0700

    shortcuts: check event first
    
    The event is a cheap operation, do it up front.

 src/shortcuts/dzl-shortcut-manager.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/shortcuts/dzl-shortcut-manager.c b/src/shortcuts/dzl-shortcut-manager.c
index 467717e..bee9972 100644
--- a/src/shortcuts/dzl-shortcut-manager.c
+++ b/src/shortcuts/dzl-shortcut-manager.c
@@ -671,6 +671,10 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
   if (self == NULL)
     self = dzl_shortcut_manager_get_default ();
 
+  /* We don't support anything but key-press */
+  if (event->type != GDK_KEY_PRESS)
+    DZL_RETURN (GDK_EVENT_PROPAGATE);
+
   if (toplevel == NULL)
     {
       gpointer user_data;
@@ -682,9 +686,6 @@ dzl_shortcut_manager_handle_event (DzlShortcutManager *self,
       g_return_val_if_fail (GTK_IS_WINDOW (toplevel), FALSE);
     }
 
-  if (event->type != GDK_KEY_PRESS)
-    DZL_RETURN (GDK_EVENT_PROPAGATE);
-
   g_assert (DZL_IS_SHORTCUT_MANAGER (self));
   g_assert (GTK_IS_WINDOW (toplevel));
   g_assert (event != NULL);


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