Fix wxPreferencesPage rendering in macOS dark mode

In 10.14's dark mode, all views are layer-backed and the assumption that child
windows are redrawn with their parent may not be correct. Change Refresh() to
explicitly refresh child windows too.

Also explicitly refresh the page before showing it in wxPreferences, because
otherwise generic windows wouldn't be drawn correctly.
This commit is contained in:
Václav Slavík
2018-09-16 14:16:26 +02:00
committed by Václav Slavík
parent 398e8744bd
commit 81ef669c6d
2 changed files with 22 additions and 0 deletions

View File

@@ -151,6 +151,10 @@ private:
info->win->Show();
SetTitle(info->page->GetName());
// Refresh the page to ensure everything is drawn in 10.14's dark mode;
// without it, generic controls aren't shown at all
info->win->Refresh();
// TODO: Preferences window may have some pages resizeable and some
// non-resizable on OS X; the whole window is or is not resizable
// depending on which page is selected.

View File

@@ -3024,12 +3024,30 @@ void wxWidgetCocoaImpl::GetContentArea( int&left, int &top, int &width, int &hei
}
}
static void SetSubviewsNeedDisplay( NSView *view )
{
for ( NSView *sub in view.subviews )
{
if ( !sub.layer )
continue;
[sub setNeedsDisplay:YES];
SetSubviewsNeedDisplay(sub);
}
}
void wxWidgetCocoaImpl::SetNeedsDisplay( const wxRect* where )
{
if ( where )
[m_osxView setNeedsDisplayInRect:wxToNSRect(m_osxView, *where )];
else
[m_osxView setNeedsDisplay:YES];
// Layer-backed views (which are all in Mojave's Dark Mode) may not have
// their children implicitly redrawn with the parent. For compatibility,
// do it manually here:
if ( m_osxView.layer )
SetSubviewsNeedDisplay(m_osxView);
}
bool wxWidgetCocoaImpl::GetNeedsDisplay() const