diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 476b68a76a..bdb117d5eb 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -443,6 +443,8 @@ protected: #ifdef __WXGTK3__ static GdkWindow* GTKFindWindow(GtkWidget* widget); static void GTKFindWindow(GtkWidget* widget, wxArrayGdkWindows& windows); + + bool m_needSizeEvent; #endif private: diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index b29852875a..53d59d6088 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -1020,9 +1020,7 @@ bool wxTopLevelWindowGTK::Show( bool show ) // size_allocate signals occur in reverse order (bottom to top). // Things work better if the initial wxSizeEvents are sent (from the // top down), before the initial size_allocate signals occur. - wxSizeEvent event(GetSize(), GetId()); - event.SetEventObject(this); - HandleWindowEvent(event); + SendSizeEvent(); #ifdef __WXGTK3__ GTKSizeRevalidate(); @@ -1031,6 +1029,14 @@ bool wxTopLevelWindowGTK::Show( bool show ) bool change = base_type::Show(show); +#ifdef __WXGTK3__ + if (m_needSizeEvent) + { + m_needSizeEvent = false; + SendSizeEvent(); + } +#endif + if (change && !show) { // make sure window has a non-default position, so when it is shown @@ -1325,15 +1331,20 @@ void wxTopLevelWindowGTK::GTKUpdateDecorSize(const DecorSize& decorSize) // gtk_widget_show() was deferred, do it now m_deferShow = false; DoGetClientSize(&m_clientWidth, &m_clientHeight); - wxSizeEvent sizeEvent(GetSize(), GetId()); - sizeEvent.SetEventObject(this); - HandleWindowEvent(sizeEvent); + SendSizeEvent(); #ifdef __WXGTK3__ GTKSizeRevalidate(); #endif gtk_widget_show(m_widget); +#ifdef __WXGTK3__ + if (m_needSizeEvent) + { + m_needSizeEvent = false; + SendSizeEvent(); + } +#endif wxShowEvent showEvent(GetId(), true); showEvent.SetEventObject(this); HandleWindowEvent(showEvent); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 77cf551c34..e4738bd352 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2472,6 +2472,7 @@ void wxWindowGTK::Init() #ifdef __WXGTK3__ m_paintContext = NULL; m_styleProvider = NULL; + m_needSizeEvent = false; #endif m_isScrolling = false; @@ -3059,8 +3060,15 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags DoMoveWindow(x, y, width, height); } - if ((sizeChange && !m_nativeSizeEvent) || (sizeFlags & wxSIZE_FORCE_EVENT)) + if (((sizeChange +#ifdef __WXGTK3__ + || m_needSizeEvent +#endif + ) && !m_nativeSizeEvent) || (sizeFlags & wxSIZE_FORCE_EVENT)) { +#ifdef __WXGTK3__ + m_needSizeEvent = false; +#endif // update these variables to keep size_allocate handler // from sending another size event for this change DoGetClientSize(&m_clientWidth, &m_clientHeight); @@ -4865,6 +4873,15 @@ void wxWindowGTK::GTKSizeRevalidate() { win->InvalidateBestSize(); gs_sizeRevalidateList = g_list_delete_link(gs_sizeRevalidateList, p); + for (;;) + { + win = win->m_parent; + if (win == NULL || win->m_needSizeEvent) + break; + win->m_needSizeEvent = true; + if (win->IsTopLevel()) + break; + } } } }