summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey Berla <corey@berla.me>2022-08-23 20:32:31 -0700
committerCorey Berla <corey@berla.me>2022-08-23 20:32:31 -0700
commit485e28ec444e3528bc7cf17c8b101baa81fc9e23 (patch)
treef654c758e2d89baecee47acbd898d95f5cd63b89
parent55b9c1d89f12be1719df1982b17d493f7f4faf5b (diff)
downloadnautilus-wip/corey/list-base-click.tar.gz
list-base: Make view click pressed event controller betterwip/corey/list-base-click
Our view click handling has an unnecessary workaround to deal with the propagation from item clicks. We set the flag deny_background_click when an item is clicked, and then clear it on release/stop. This is a little hard to follow and I think might be contributing to problems such a quasi-activated state for some items. Set the propagation phase to TARGET on the view. This works out of the box for the GridView. ColumnView is implemented using a child ListView, so we have to get that by looking at the child's silbing.
-rw-r--r--src/nautilus-list-base.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 568070d1b..b3f34f78d 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -45,7 +45,6 @@ struct _NautilusListBasePrivate
gboolean single_click_mode;
gboolean activate_on_release;
- gboolean deny_background_click;
GdkDragAction drag_item_action;
GdkDragAction drag_view_action;
@@ -359,7 +358,6 @@ on_item_click_pressed (GtkGestureClick *gesture,
selection_mode = (modifiers & (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
/* Before anything else, store event state to be read by other handlers. */
- priv->deny_background_click = TRUE;
priv->activate_on_release = (priv->single_click_mode &&
button == GDK_BUTTON_PRIMARY &&
n_press == 1 &&
@@ -427,7 +425,6 @@ on_item_click_released (GtkGestureClick *gesture,
rubberband_set_state (self, TRUE);
priv->activate_on_release = FALSE;
- priv->deny_background_click = FALSE;
}
static void
@@ -440,7 +437,6 @@ on_item_click_stopped (GtkGestureClick *gesture,
rubberband_set_state (self, TRUE);
priv->activate_on_release = FALSE;
- priv->deny_background_click = FALSE;
}
static void
@@ -451,18 +447,10 @@ on_view_click_pressed (GtkGestureClick *gesture,
gpointer user_data)
{
NautilusListBase *self = user_data;
- NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
guint button;
GdkModifierType modifiers;
gboolean selection_mode;
- if (priv->deny_background_click)
- {
- /* Item was clicked. */
- gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
- return;
- }
-
/* We are overriding many of the gestures for the views so let's make sure to
* grab the focus in order to make rubberbanding and background click work */
gtk_widget_grab_focus (GTK_WIDGET (self));
@@ -990,10 +978,6 @@ real_begin_loading (NautilusFilesView *files_view)
nautilus_files_view_update_context_menus (files_view);
nautilus_files_view_update_toolbar_menus (files_view);
- /* When double clicking on an item this deny_background_click can persist
- * because the new view interrupts the gesture sequence, so lets reset it.*/
- priv->deny_background_click = FALSE;
-
/* When DnD is used to navigate between directories, the normal callbacks
* are ignored. Update DnD variables here upon navigating to a directory*/
if (gtk_drop_target_get_current_drop (priv->view_drop_target) != NULL)
@@ -1756,16 +1740,25 @@ nautilus_list_base_setup_gestures (NautilusListBase *self)
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
GtkEventController *controller;
GtkDropTarget *drop_target;
+ GtkWidget *view_ui = nautilus_list_base_get_view_ui (self);
+
+ if (GTK_IS_COLUMN_VIEW (view_ui))
+ {
+ /* ListView is the top-most widget in a ColumnView */
+ view_ui = gtk_widget_get_next_sibling (gtk_widget_get_first_child (view_ui));
+ }
controller = GTK_EVENT_CONTROLLER (gtk_gesture_click_new ());
- gtk_widget_add_controller (GTK_WIDGET (self), controller);
+ gtk_widget_add_controller (view_ui, controller);
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (controller), 0);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_TARGET);
g_signal_connect (controller, "pressed",
G_CALLBACK (on_view_click_pressed), self);
controller = GTK_EVENT_CONTROLLER (gtk_gesture_long_press_new ());
- gtk_widget_add_controller (GTK_WIDGET (self), controller);
+ gtk_widget_add_controller (view_ui, controller);
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller), TRUE);
+ gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_TARGET);
g_signal_connect (controller, "pressed",
G_CALLBACK (on_view_longpress_pressed), self);