[gtk/wip/antoniof/dont-rubberband-on-drag-end] listbase: Don't start rubberband on ::drag-end




commit dc4540fae98d4f707ce1030b0f8d161c987646e0
Author: António Fernandes <antoniojpfernandes gmail com>
Date:   Sat Jun 4 17:30:10 2022 +0000

    listbase: Don't start rubberband on ::drag-end
    
    GtkGestrureDrag::drag-end can be emitted when the pointer has just
    crossed the drag threshold and we have not started the rubberband yet.
    This happens if another gesture has claimed the event sequence earlier
    in the current event propagation chain.
    
    In such situation, our ::drag-end calls gtk_list_base_drag_update(),
    which proceeds to start the rubberband. That's obviously wrong.
    Additionally, it also tries to get modifiers from an event it we are
    already denied,  which obviously fails with criticals:
    
    `gdk_event_get_modifier_state: assertion 'GDK_IS_EVENT (event)' failed`
    
    Thus, if there is no rubberband when we receive ::drag-end, do nothing.

 gtk/gtklistbase.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index bf0657a04f..7d1d44963c 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -1721,8 +1721,12 @@ gtk_list_base_drag_end (GtkGestureDrag *gesture,
                         double          offset_y,
                         GtkListBase    *self)
 {
+  GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
   gboolean modify, extend;
 
+  if (!priv->rubberband)
+    return;
+
   gtk_list_base_drag_update (gesture, offset_x, offset_y, self);
   get_selection_modifiers (GTK_GESTURE (gesture), &modify, &extend);
   gtk_list_base_stop_rubberband (self, modify, extend);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]