diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index d213cc8dc1..42755f40ca 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -53,6 +53,7 @@ #endif // wxUSE_LIBHILDON2 #ifdef __WXGTK3__ +extern GList* wx_sizeEventList; void wxGTKSizeRevalidate(wxWindow*); #endif @@ -1049,9 +1050,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__ wxGTKSizeRevalidate(this); @@ -1060,6 +1059,14 @@ bool wxTopLevelWindowGTK::Show( bool show ) bool change = base_type::Show(show); +#ifdef __WXGTK3__ + if (GList* p = g_list_find(wx_sizeEventList, this)) + { + wx_sizeEventList = g_list_delete_link(wx_sizeEventList, p); + SendSizeEvent(); + } +#endif + if (change && !show) { // make sure window has a non-default position, so when it is shown @@ -1366,15 +1373,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__ wxGTKSizeRevalidate(this); #endif gtk_widget_show(m_widget); +#ifdef __WXGTK3__ + if (GList* p = g_list_find(wx_sizeEventList, this)) + { + wx_sizeEventList = g_list_delete_link(wx_sizeEventList, p); + SendSizeEvent(); + } +#endif wxShowEvent showEvent(GetId(), true); showEvent.SetEventObject(this); HandleWindowEvent(showEvent); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index ab56baa7f2..41fffb4bce 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -222,6 +222,7 @@ int g_lastButtonNumber = 0; #ifdef __WXGTK3__ static GList* gs_sizeRevalidateList; static GSList* gs_queueResizeList; +GList* wx_sizeEventList; static bool gs_inSizeAllocate; void wxGTKSizeRevalidate(wxWindow*); #endif @@ -2583,7 +2584,8 @@ wxWindowGTK::~wxWindowGTK() if (m_styleProvider) g_object_unref(m_styleProvider); - gs_sizeRevalidateList = g_list_remove(gs_sizeRevalidateList, this); + gs_sizeRevalidateList = g_list_remove_all(gs_sizeRevalidateList, this); + wx_sizeEventList = g_list_remove(wx_sizeEventList, this); #endif gs_needCursorResetMap.erase(this); @@ -2924,11 +2926,18 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (height == -1) height = m_height; - const bool sizeChange = m_width != width || m_height != height; + bool sizeChange = m_width != width || m_height != height; if (sizeChange) m_useCachedClientSize = false; +#ifdef __WXGTK3__ + if (GList* p = g_list_find(wx_sizeEventList, this)) + { + sizeChange = true; + wx_sizeEventList = g_list_delete_link(wx_sizeEventList, p); + } +#endif if (sizeChange || m_x != x || m_y != y) { m_x = x; @@ -4738,6 +4747,15 @@ void wxGTKSizeRevalidate(wxWindow* tlw) { win->InvalidateBestSize(); gs_sizeRevalidateList = g_list_delete_link(gs_sizeRevalidateList, p); + for (;;) + { + win = win->GetParent(); + if (win == NULL || g_list_find(wx_sizeEventList, win)) + break; + wx_sizeEventList = g_list_prepend(wx_sizeEventList, win); + if (win->IsTopLevel()) + break; + } } } } @@ -4772,14 +4790,14 @@ bool wxWindowGTK::SetFont( const wxFont &font ) // invalidate the best size right before the style cache is updated, so any // subsequent best size requests use the correct font. if (gtk_check_version(3,8,0) == NULL) - gs_sizeRevalidateList = g_list_append(gs_sizeRevalidateList, this); + gs_sizeRevalidateList = g_list_prepend(gs_sizeRevalidateList, this); else if (gtk_check_version(3,6,0) == NULL) { wxWindow* tlw = wxGetTopLevelParent(static_cast(this)); if (tlw->m_widget && gtk_widget_get_visible(tlw->m_widget)) g_idle_add_full(GTK_PRIORITY_RESIZE - 1, before_resize, this, NULL); else - gs_sizeRevalidateList = g_list_append(gs_sizeRevalidateList, this); + gs_sizeRevalidateList = g_list_prepend(gs_sizeRevalidateList, this); } #endif