]> git.saurik.com Git - wxWidgets.git/commitdiff
defer queue-resize until after size-allocate processing, to keep it from being ignore...
authorPaul Cornett <paulcor@bullseye.com>
Fri, 20 Apr 2012 16:05:13 +0000 (16:05 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Fri, 20 Apr 2012 16:05:13 +0000 (16:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71246 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/window.cpp

index 6018aa3489421684d910a071161381ee85b0af36..45e8a8b7083189cda51f4942641f5fe6eb780a7c 100644 (file)
@@ -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()