From: Paul Cornett Date: Sat, 15 Mar 2008 18:11:08 +0000 (+0000) Subject: use a different method to prevent an early size_allocate, X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/390f44afb6076b672fc673ef9e0c89f018ea7e75 use a different method to prevent an early size_allocate, 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 --- diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index ef016719cd..5d90d3a9be 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -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)