[gtk+/wip/matthiasc/kill-event-signals: 101/126] entry completion: Stop using ::focus-out-event



commit 018d165b6197fda10bd7bf7eb2003bdf5f7c28c5
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 6 12:03:30 2018 -0500

    entry completion: Stop using ::focus-out-event
    
    We can just use ::event.

 gtk/gtkentrycompletion.c |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 671a276..109053b 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -2566,6 +2566,19 @@ completion_insert_text_callback (GtkEntry           *entry,
     }
 }
 
+static gboolean
+maybe_accept_completion (GtkEntry *entry,
+                         GdkEvent *event)
+{
+  gboolean focus_in;
+
+  if (gdk_event_get_event_type (event) == GDK_FOCUS_CHANGE &&
+      gdk_event_get_focus_in (event, &focus_in) && !focus_in)
+    accept_completion_callback (entry);
+
+  return GDK_EVENT_PROPAGATE;
+}
+
 static void
 connect_completion_signals (GtkEntryCompletion *completion)
 {
@@ -2582,8 +2595,8 @@ connect_completion_signals (GtkEntryCompletion *completion)
                       G_CALLBACK (clear_completion_callback), completion);
     g_signal_connect (completion->priv->entry, "activate",
                       G_CALLBACK (accept_completion_callback), completion);
-    g_signal_connect (completion->priv->entry, "focus-out-event",
-                      G_CALLBACK (accept_completion_callback), completion);
+    g_signal_connect (completion->priv->entry, "event",
+                      G_CALLBACK (maybe_accept_completion), completion);
 }
 
 static void
@@ -2643,6 +2656,8 @@ disconnect_completion_signals (GtkEntryCompletion *completion)
                                         G_CALLBACK (clear_completion_callback), completion);
   g_signal_handlers_disconnect_by_func (completion->priv->entry,
                                         G_CALLBACK (accept_completion_callback), completion);
+  g_signal_handlers_disconnect_by_func (completion->priv->entry,
+                                        G_CALLBACK (maybe_accept_completion), completion);
 }
 
 void


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