]> git.saurik.com Git - wxWidgets.git/commitdiff
use a different method to prevent an early size_allocate,
authorPaul Cornett <paulcor@bullseye.com>
Sat, 15 Mar 2008 18:11:08 +0000 (18:11 +0000)
committerPaul Cornett <paulcor@bullseye.com>
Sat, 15 Mar 2008 18:11:08 +0000 (18:11 +0000)
removing child has undesirable size effects, such as unsetting the default widget

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52552 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/gtk/toplevel.cpp

index ef016719cd71181ea620f7e9f34dc747aed7c073..5d90d3a9be3b0302a028f55ff7ded780c56fc1d9 100644 (file)
@@ -774,22 +774,16 @@ bool wxTopLevelWindowGTK::Show( bool show )
         // what wxWidgets expects it to be without an obvious change in the
         // window size immediately after it becomes visible.
 
-        // Realize m_widget, so m_widget->window can be used. Realizing causes
-        // the widget tree to be size_allocated, which generates size events in
-        // the wrong order. So temporarily remove child from m_widget while
-        // realizing.
-        GtkWidget* child = GTK_BIN(m_widget)->child;
-        if (child)
-        {
-            g_object_ref(child);
-            gtk_container_remove(GTK_CONTAINER(m_widget), child);
-        }
+        // Realize m_widget, so m_widget->window can be used. Realizing normally
+        // causes the widget tree to be size_allocated, which generates size
+        // events in the wrong order. However, the size_allocates will not be
+        // done if the allocation is not the default (1,1).
+        const int alloc_width = m_widget->allocation.width;
+        if (alloc_width == 1)
+            m_widget->allocation.width = 2;
         gtk_widget_realize(m_widget);
-        if (child)
-        {
-            gtk_container_add(GTK_CONTAINER(m_widget), child);
-            g_object_unref(child);
-        }
+        if (alloc_width == 1)
+            m_widget->allocation.width = 1;
 
         m_deferShow =
         deferShow = gdk_x11_screen_supports_net_wm_hint(
@@ -1004,11 +998,8 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const wxSize& decorSize)
             m_height += diff.y;
             if (m_width  < 0) m_width  = 0;
             if (m_height < 0) m_height = 0;
-            if (!m_deferShow)
-            {
-                m_oldClientWidth = 0;
-                gtk_widget_queue_resize(m_wxwindow);
-            }
+            m_oldClientWidth = 0;
+            gtk_widget_queue_resize(m_wxwindow);
         }
     }
     if (m_deferShow)