[gtk] Automatically set :active state on button press/release



commit 1b504a3303b60b82f3b240d87ac01bd6a2178914
Author: Timm Bäder <mail baedert org>
Date:   Fri Jan 25 05:39:04 2019 +0100

    Automatically set :active state on button press/release

 gtk/gtkmain.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a26044b8cb..25d39d785d 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1553,6 +1553,24 @@ is_pointing_event (GdkEvent *event)
     }
 }
 
+static inline void
+set_widget_active_state (GtkWidget       *target,
+                         const gboolean   release)
+{
+  GtkWidget *w;
+
+  w = target;
+  while (w)
+    {
+      if (release)
+        gtk_widget_unset_state_flags (w, GTK_STATE_FLAG_ACTIVE);
+      else
+        gtk_widget_set_state_flags (w, GTK_STATE_FLAG_ACTIVE, FALSE);
+
+      w = gtk_widget_get_parent (w);
+    }
+}
+
 static GtkWidget *
 handle_pointing_event (GdkEvent *event)
 {
@@ -1641,6 +1659,9 @@ handle_pointing_event (GdkEvent *event)
                                           GDK_CROSSING_UNGRAB);
           gtk_window_maybe_update_cursor (toplevel, NULL, device);
         }
+
+      set_widget_active_state (target, event->any.type == GDK_BUTTON_RELEASE);
+
       break;
     case GDK_SCROLL:
     case GDK_TOUCHPAD_PINCH:


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