[gtk/try-to-fix-list-scrolling] listbase: Don't hand out invalid positions




commit 34e365e11a87cce53f243bccaff00da236894089
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Nov 2 08:07:56 2020 -0500

    listbase: Don't hand out invalid positions
    
    gtk_list_base_get_position_from_allocation relies on
    the rbtree allocations being valid, and thus can't really
    be used more than once before doing a size_allocate. We
    generally queue a resize when we invalidate the rbtree
    in response to handling input events, so we can use the
    resize_needed flag as a proxy for the tree being invalid.
    
    This change prevents the jumpy scrolling that is currently
    happening when we manage to get two scroll events during
    a single frame cycle, where the scrollbar sometimes jumps
    to the other end of a long list.

 gtk/gtklistbase.c | 3 +++
 1 file changed, 3 insertions(+)
---
diff --git a/gtk/gtklistbase.c b/gtk/gtklistbase.c
index ed4f84ad2a..73d401c075 100644
--- a/gtk/gtklistbase.c
+++ b/gtk/gtklistbase.c
@@ -132,6 +132,9 @@ gtk_list_base_get_position_from_allocation (GtkListBase           *self,
                                             guint                 *pos,
                                             cairo_rectangle_int_t *area)
 {
+  if (widget->priv->resize_needed)
+    return FALSE;
+
   return GTK_LIST_BASE_GET_CLASS (self)->get_position_from_allocation (self, across, along, pos, area);
 }
 


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