From 847b3261fcb400488bb54bea9557a797c653b048 Mon Sep 17 00:00:00 2001 From: Corey Berla Date: Tue, 29 Nov 2022 14:58:29 -0800 Subject: [PATCH] treeexpander: Toggle expand on release instead of pressed With the introduction of the hide-expander property, I noticed that the active state would persist in many cases because the release signal was never emitted. In gtk3 tree expanders, expanded on release. gtk4 expanded on press to match window explorer. Per irc chat, the designers didn't have a strong preference for press or release. In order to keep consistency and fix this bug, let's move back to release. --- gtk/gtktreeexpander.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gtk/gtktreeexpander.c b/gtk/gtktreeexpander.c index cde27a330d..d2cce546a3 100644 --- a/gtk/gtktreeexpander.c +++ b/gtk/gtktreeexpander.c @@ -127,8 +127,6 @@ gtk_tree_expander_click_gesture_pressed (GtkGestureClick *gesture, { GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); - gtk_widget_activate_action (widget, "listitem.toggle-expand", NULL); - gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_ACTIVE, FALSE); @@ -143,8 +141,12 @@ gtk_tree_expander_click_gesture_released (GtkGestureClick *gesture, double y, gpointer unused) { - gtk_widget_unset_state_flags (gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)), - GTK_STATE_FLAG_ACTIVE); + GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); + + gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_ACTIVE); + + if (gtk_widget_contains (widget, x, y)) + gtk_widget_activate_action (widget, "listitem.toggle-expand", NULL); gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); }