GtkListWidgetItem can intercept click gestures
Steps to reproduce
- Apply the following patch to the Application Launcher demo:
diff --git a/demos/gtk-demo/listview_applauncher.c b/demos/gtk-demo/listview_applauncher.c
index 3194e05e21..d9d09ae2c0 100644
--- a/demos/gtk-demo/listview_applauncher.c
+++ b/demos/gtk-demo/listview_applauncher.c
@@ -38,6 +38,16 @@ create_application_list (void)
return G_LIST_MODEL (store);
}
+static void
+pressed (GtkGestureClick *gesture,
+ int n_press,
+ double x,
+ double y,
+ GtkWidget *box)
+{
+ printf("pressed!\n");
+}
+
/* This is the function we use for setting up new listitems to display.
* We add just an GtkImage and a GtkLabel here to display the application's
* icon and name, as this is just a simple demo.
@@ -49,6 +59,7 @@ setup_listitem_cb (GtkListItemFactory *factory,
GtkWidget *box;
GtkWidget *image;
GtkWidget *label;
+ GtkGesture *gesture;
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
image = gtk_image_new ();
@@ -57,6 +68,12 @@ setup_listitem_cb (GtkListItemFactory *factory,
label = gtk_label_new ("");
gtk_box_append (GTK_BOX (box), label);
gtk_list_item_set_child (list_item, box);
+
+ gesture = gtk_gesture_click_new();
+ gtk_gesture_single_set_button(GTK_GESTURE_SINGLE(gesture), 3);
+ gtk_widget_add_controller(box, GTK_EVENT_CONTROLLER(gesture));
+
+ g_signal_connect(gesture, "pressed", G_CALLBACK(pressed), box);
}
/* Here we need to prepare the listitem for displaying its item. We get the
- Launch the demo.
- Position the mouse precisely on the edge of one of the list items. Observe that the item is highlighted while hovered. Press right-click. The handler will not be triggered.
Current behavior
Right click gestures can be swallowed by the GtkListWidgetItems that contain widgets with a handler.
Expected outcome
I would expect the handler to be triggered, especially because the item is highlighted.
Version information
GTK version: 4.8.3 Arch Linux
Additional information
N/A