From 33e77747433f3d9ef474227e5dd01426476d8fe1 Mon Sep 17 00:00:00 2001 From: Corey Berla Date: Wed, 7 Dec 2022 10:25:09 -1000 Subject: [PATCH] columnviewtitle: Prevent header clicks from propagating The header in GtkColumnView has multiple event handlers there is a ::pressed handler in GtkColumnView for resizing the columns in CAPTURE as well as a motion and drag controller. The ::release handler is in GtkColumnViewTitle. We can't claim the event in the existing handlers because then the ::release handler will never get called. Currently, however, all clicks get propagated to the ColumnView from the header which can be problematic. Since we don't usually want the clicks from the header handled on the view, claim it in the BUBBLE phase. Fixes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5425 --- gtk/gtkcolumnviewtitle.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gtk/gtkcolumnviewtitle.c b/gtk/gtkcolumnviewtitle.c index 8b9987a62d..6c7f729f95 100644 --- a/gtk/gtkcolumnviewtitle.c +++ b/gtk/gtkcolumnviewtitle.c @@ -250,6 +250,18 @@ click_released_cb (GtkGestureClick *gesture, show_menu (self, x, y); } +static void +click_pressed_cb (GtkGestureClick *gesture, + int n_press, + double x, + double y, + GtkColumnView *self) +{ + /* Claim the state here to prevent propagation, the event controllers in + * GtkColumView have already been handled in the CAPTURE phase */ + gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED); +} + static void gtk_column_view_title_init (GtkColumnViewTitle *self) { @@ -272,6 +284,7 @@ gtk_column_view_title_init (GtkColumnViewTitle *self) gesture = gtk_gesture_click_new (); gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0); g_signal_connect (gesture, "released", G_CALLBACK (click_released_cb), self); + g_signal_connect (gesture, "pressed", G_CALLBACK (click_pressed_cb), self); gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (gesture)); }