forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
a9c9678e1f
commit
33e7774743
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user