From 1b504a3303b60b82f3b240d87ac01bd6a2178914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 25 Jan 2019 05:39:04 +0100 Subject: [PATCH] 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: