Partial workaround for stale styling information with GTK3

We can trigger size events when we know the style cache has been updated.
See #16088
This commit is contained in:
Paul Cornett
2016-11-01 23:18:26 -07:00
parent 3b4ee5a031
commit 101c43d0aa
3 changed files with 37 additions and 7 deletions

View File

@@ -443,6 +443,8 @@ protected:
#ifdef __WXGTK3__ #ifdef __WXGTK3__
static GdkWindow* GTKFindWindow(GtkWidget* widget); static GdkWindow* GTKFindWindow(GtkWidget* widget);
static void GTKFindWindow(GtkWidget* widget, wxArrayGdkWindows& windows); static void GTKFindWindow(GtkWidget* widget, wxArrayGdkWindows& windows);
bool m_needSizeEvent;
#endif #endif
private: private:

View File

@@ -1020,9 +1020,7 @@ bool wxTopLevelWindowGTK::Show( bool show )
// size_allocate signals occur in reverse order (bottom to top). // size_allocate signals occur in reverse order (bottom to top).
// Things work better if the initial wxSizeEvents are sent (from the // Things work better if the initial wxSizeEvents are sent (from the
// top down), before the initial size_allocate signals occur. // top down), before the initial size_allocate signals occur.
wxSizeEvent event(GetSize(), GetId()); SendSizeEvent();
event.SetEventObject(this);
HandleWindowEvent(event);
#ifdef __WXGTK3__ #ifdef __WXGTK3__
GTKSizeRevalidate(); GTKSizeRevalidate();
@@ -1031,6 +1029,14 @@ bool wxTopLevelWindowGTK::Show( bool show )
bool change = base_type::Show(show); bool change = base_type::Show(show);
#ifdef __WXGTK3__
if (m_needSizeEvent)
{
m_needSizeEvent = false;
SendSizeEvent();
}
#endif
if (change && !show) if (change && !show)
{ {
// make sure window has a non-default position, so when it is shown // 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 // gtk_widget_show() was deferred, do it now
m_deferShow = false; m_deferShow = false;
DoGetClientSize(&m_clientWidth, &m_clientHeight); DoGetClientSize(&m_clientWidth, &m_clientHeight);
wxSizeEvent sizeEvent(GetSize(), GetId()); SendSizeEvent();
sizeEvent.SetEventObject(this);
HandleWindowEvent(sizeEvent);
#ifdef __WXGTK3__ #ifdef __WXGTK3__
GTKSizeRevalidate(); GTKSizeRevalidate();
#endif #endif
gtk_widget_show(m_widget); gtk_widget_show(m_widget);
#ifdef __WXGTK3__
if (m_needSizeEvent)
{
m_needSizeEvent = false;
SendSizeEvent();
}
#endif
wxShowEvent showEvent(GetId(), true); wxShowEvent showEvent(GetId(), true);
showEvent.SetEventObject(this); showEvent.SetEventObject(this);
HandleWindowEvent(showEvent); HandleWindowEvent(showEvent);

View File

@@ -2472,6 +2472,7 @@ void wxWindowGTK::Init()
#ifdef __WXGTK3__ #ifdef __WXGTK3__
m_paintContext = NULL; m_paintContext = NULL;
m_styleProvider = NULL; m_styleProvider = NULL;
m_needSizeEvent = false;
#endif #endif
m_isScrolling = false; 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); 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 // update these variables to keep size_allocate handler
// from sending another size event for this change // from sending another size event for this change
DoGetClientSize(&m_clientWidth, &m_clientHeight); DoGetClientSize(&m_clientWidth, &m_clientHeight);
@@ -4865,6 +4873,15 @@ void wxWindowGTK::GTKSizeRevalidate()
{ {
win->InvalidateBestSize(); win->InvalidateBestSize();
gs_sizeRevalidateList = g_list_delete_link(gs_sizeRevalidateList, p); 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;
}
} }
} }
} }