From 1da92c2800fefebfc37e4bf495e9265af2b87e30 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 19 Jul 2015 22:18:58 -0400 Subject: [PATCH] GtkListBox: Improve focus scrolling We are trying to scroll the header in view together with the focus row. The way this is implemented works fine when scrolling up, but falls short when scrolling down. Fix this by making sure that both the row and the header bar visible. --- gtk/gtklistbox.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gtk/gtklistbox.c b/gtk/gtklistbox.c index 522e91f1eb..2aa372b169 100644 --- a/gtk/gtklistbox.c +++ b/gtk/gtklistbox.c @@ -1425,21 +1425,26 @@ ensure_row_visible (GtkListBox *box, { GtkListBoxPrivate *priv = BOX_PRIV (box); GtkWidget *header; - GtkWidget *widget; + gint y, height; GtkAllocation allocation; if (!priv->adjustment) return; + gtk_widget_get_allocation (GTK_WIDGET (row), &allocation); + y = allocation.y; + height = allocation.height; + /* If the row has a header, we want to ensure that it is visible as well. */ header = ROW_PRIV (row)->header; if (GTK_IS_WIDGET (header) && gtk_widget_is_drawable (header)) - widget = header; - else - widget = GTK_WIDGET (row); + { + gtk_widget_get_allocation (header, &allocation); + y = allocation.y; + height += allocation.height; + } - gtk_widget_get_allocation (widget, &allocation); - gtk_adjustment_clamp_page (priv->adjustment, allocation.y, allocation.y + allocation.height); + gtk_adjustment_clamp_page (priv->adjustment, y, y + height); } static void