From c60eb134fd3e2ea56848ecd5f6d57930a25c8272 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 20 Apr 2008 22:44:17 +0000 Subject: [PATCH] fix child window redraw glitches during scrolling (bug 1944002) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@53277 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/win_gtk.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index f3099fdbbd..562ec2f8a9 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -682,21 +682,41 @@ gtk_pizza_allocate_child (GtkPizza *pizza, gtk_widget_size_allocate (child->widget, &allocation); } +typedef struct { + GdkWindow* window; + int dx, dy; +} AdjustData; + +// Adjust allocations for all widgets using the GdkWindow which was just scrolled +static void scroll_adjust(GtkWidget* widget, void* data) +{ + const AdjustData* p = data; + if (widget->window == p->window) + { + widget->allocation.x += p->dx; + widget->allocation.y += p->dy; + // GtkFrame requires a queue_resize, otherwise parts of + // the frame newly exposed by the scroll are not drawn. + // To be safe, do it for all widgets. + gtk_widget_queue_resize(widget); + if (GTK_IS_CONTAINER(widget)) + gtk_container_forall(GTK_CONTAINER(widget), scroll_adjust, data); + } +} + void gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) { - GList *tmp_list; - pizza->m_xoffset += dx; pizza->m_yoffset += dy; if (pizza->bin_window) - gdk_window_scroll( pizza->bin_window, -dx, -dy ); - - for (tmp_list = pizza->children; tmp_list; tmp_list = tmp_list->next) { - GtkPizzaChild *child = tmp_list->data; - gtk_widget_queue_resize(child->widget); + AdjustData data = { pizza->bin_window, -dx, -dy }; + gdk_window_scroll( pizza->bin_window, -dx, -dy ); + // Adjust child allocations. Doing a queue_resize on the children is not + // enough, sometimes they redraw in the wrong place during fast scrolling. + gtk_container_forall(GTK_CONTAINER(pizza), scroll_adjust, &data); } }