[gtk/wip/carlosg/gesture-state-in-entries: 1/3] gtksearchentry: Consume click events after pressing on icon




commit 90edb7641584a23ae1979dcb960c3c862f4596e2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Aug 23 15:30:21 2021 +0200

    gtksearchentry: Consume click events after pressing on icon
    
    This results in user actions, so the gesture should consume the
    events.

 gtk/gtksearchentry.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c
index 6a9d3c8969..ebee742622 100644
--- a/gtk/gtksearchentry.c
+++ b/gtk/gtksearchentry.c
@@ -490,6 +490,16 @@ gtk_search_entry_accessible_init (GtkAccessibleInterface *iface)
   iface->get_platform_state = gtk_search_entry_accessible_get_platform_state;
 }
 
+static void
+gtk_search_entry_icon_press (GtkGestureClick *press,
+                             int              n_press,
+                             double           x,
+                             double           y,
+                             GtkSearchEntry  *entry)
+{
+  gtk_gesture_set_state (GTK_GESTURE (press), GTK_EVENT_SEQUENCE_CLAIMED);
+}
+
 static void
 gtk_search_entry_icon_release (GtkGestureClick *press,
                                int              n_press,
@@ -601,6 +611,7 @@ gtk_search_entry_init (GtkSearchEntry *entry)
   gtk_widget_set_child_visible (entry->icon, FALSE);
 
   press = gtk_gesture_click_new ();
+  g_signal_connect (press, "pressed", G_CALLBACK (gtk_search_entry_icon_press), entry);
   g_signal_connect (press, "released", G_CALLBACK (gtk_search_entry_icon_release), entry);
   gtk_widget_add_controller (entry->icon, GTK_EVENT_CONTROLLER (press));
 


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