From 3cc04de73ed7750a93d47779767db7a850c48bf4 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 20 Apr 2012 16:05:13 +0000 Subject: [PATCH] defer queue-resize until after size-allocate processing, to keep it from being ignored by GTK3 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/window.cpp | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 6018aa3..45e8a8b 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2564,6 +2564,27 @@ bool wxWindowGTK::Destroy() return wxWindowBase::Destroy(); } +static GSList* gs_queueResizeList; + +extern "C" { +static gboolean queue_resize(void*) +{ + gdk_threads_enter(); + for (GSList* p = gs_queueResizeList; p; p = p->next) + { + if (p->data) + { + gtk_widget_queue_resize(GTK_WIDGET(p->data)); + g_object_remove_weak_pointer(G_OBJECT(p->data), &p->data); + } + } + g_slist_free(gs_queueResizeList); + gs_queueResizeList = NULL; + gdk_threads_leave(); + return false; +} +} + void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) { GtkWidget* parent = gtk_widget_get_parent(m_widget); @@ -2572,8 +2593,19 @@ void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) WX_PIZZA(parent)->move(m_widget, x, y); gtk_widget_set_size_request(m_widget, width, height); } - else - gtk_widget_queue_resize(m_widget); + + // With GTK3, gtk_widget_queue_resize() is ignored while a size-allocate + // is in progress. This situation is common in wxWidgets, since + // size-allocate can generate wxSizeEvent and size event handlers often + // call SetSize(), directly or indirectly. Work around this by deferring + // the queue-resize until after size-allocate processing is finished. + if (g_slist_find(gs_queueResizeList, m_widget) == NULL) + { + if (gs_queueResizeList == NULL) + g_idle_add_full(GTK_PRIORITY_RESIZE, queue_resize, NULL, NULL); + gs_queueResizeList = g_slist_prepend(gs_queueResizeList, m_widget); + g_object_add_weak_pointer(G_OBJECT(m_widget), &gs_queueResizeList->data); + } } void wxWindowGTK::ConstrainSize() -- 2.7.4