forked from AuroraMiddleware/gtk
Merge branch 'wip/antoniof/listbase-rubberband-better-fix' into 'main'
listbase: Cancel rubberband if not handling drag See merge request GNOME/gtk!4831
This commit is contained in:
commit
ae097d9674
@ -1572,25 +1572,16 @@ gtk_list_base_start_rubberband (GtkListBase *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_list_base_stop_rubberband (GtkListBase *self,
|
gtk_list_base_apply_rubberband_selection (GtkListBase *self,
|
||||||
gboolean modify,
|
gboolean modify,
|
||||||
gboolean extend)
|
gboolean extend)
|
||||||
{
|
{
|
||||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||||
GtkListItemManagerItem *item;
|
|
||||||
GtkSelectionModel *model;
|
GtkSelectionModel *model;
|
||||||
|
|
||||||
if (!priv->rubberband)
|
if (!priv->rubberband)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (item = gtk_list_item_manager_get_first (priv->item_manager);
|
|
||||||
item != NULL;
|
|
||||||
item = gtk_rb_tree_node_get_next (item))
|
|
||||||
{
|
|
||||||
if (item->widget)
|
|
||||||
gtk_widget_unset_state_flags (item->widget, GTK_STATE_FLAG_ACTIVE);
|
|
||||||
}
|
|
||||||
|
|
||||||
model = gtk_list_item_manager_get_model (priv->item_manager);
|
model = gtk_list_item_manager_get_model (priv->item_manager);
|
||||||
if (model != NULL)
|
if (model != NULL)
|
||||||
{
|
{
|
||||||
@ -1651,6 +1642,24 @@ gtk_list_base_stop_rubberband (GtkListBase *self,
|
|||||||
gtk_bitset_unref (mask);
|
gtk_bitset_unref (mask);
|
||||||
gtk_bitset_unref (rubberband_selection);
|
gtk_bitset_unref (rubberband_selection);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_list_base_stop_rubberband (GtkListBase *self)
|
||||||
|
{
|
||||||
|
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||||
|
GtkListItemManagerItem *item;
|
||||||
|
|
||||||
|
if (!priv->rubberband)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (item = gtk_list_item_manager_get_first (priv->item_manager);
|
||||||
|
item != NULL;
|
||||||
|
item = gtk_rb_tree_node_get_next (item))
|
||||||
|
{
|
||||||
|
if (item->widget)
|
||||||
|
gtk_widget_unset_state_flags (item->widget, GTK_STATE_FLAG_ACTIVE);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_list_item_tracker_free (priv->item_manager, priv->rubberband->start_tracker);
|
gtk_list_item_tracker_free (priv->item_manager, priv->rubberband->start_tracker);
|
||||||
g_clear_pointer (&priv->rubberband->widget, gtk_widget_unparent);
|
g_clear_pointer (&priv->rubberband->widget, gtk_widget_unparent);
|
||||||
@ -1763,14 +1772,23 @@ gtk_list_base_drag_end (GtkGestureDrag *gesture,
|
|||||||
GtkListBase *self)
|
GtkListBase *self)
|
||||||
{
|
{
|
||||||
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
|
||||||
|
GdkEventSequence *sequence;
|
||||||
gboolean modify, extend;
|
gboolean modify, extend;
|
||||||
|
|
||||||
if (!priv->rubberband)
|
if (!priv->rubberband)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
sequence = gtk_gesture_get_last_updated_sequence (GTK_GESTURE (gesture));
|
||||||
|
if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
|
||||||
|
{
|
||||||
|
gtk_list_base_stop_rubberband (self);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_list_base_drag_update (gesture, offset_x, offset_y, self);
|
gtk_list_base_drag_update (gesture, offset_x, offset_y, self);
|
||||||
get_selection_modifiers (GTK_GESTURE (gesture), &modify, &extend);
|
get_selection_modifiers (GTK_GESTURE (gesture), &modify, &extend);
|
||||||
gtk_list_base_stop_rubberband (self, modify, extend);
|
gtk_list_base_apply_rubberband_selection (self, modify, extend);
|
||||||
|
gtk_list_base_stop_rubberband (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user