From e484a2db1926374311ec4327605e8935d04ac873 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Thu, 8 Nov 2018 15:04:42 +0100 Subject: [PATCH] force subview refresh on macOS 10.14 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit even on dark mode not all NSViews have their own layer, therefore don’t take that as a condition, because a child of such a view still might be layer-backed and need an explicit redraw. Avoid spurious redraws for not visible windows (especiall important for not-yet fully constructed views or views during destruction) --- src/osx/cocoa/window.mm | 13 +++++++++---- src/osx/window_osx.cpp | 2 ++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 3695a1b185..45cfdd7c37 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2575,8 +2575,11 @@ void wxWidgetCocoaImpl::SetVisibility( bool visible ) [m_osxView setHidden:(visible ? NO:YES)]; // trigger redraw upon shown for layer-backed views - if( m_osxView.layer && !m_osxView.isHiddenOrHasHiddenAncestor ) - SetNeedsDisplay(NULL); +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) ) + if( !m_osxView.isHiddenOrHasHiddenAncestor ) + SetNeedsDisplay(NULL); +#endif } double wxWidgetCocoaImpl::GetContentScaleFactor() const @@ -3032,7 +3035,7 @@ static void SetSubviewsNeedDisplay( NSView *view ) { for ( NSView *sub in view.subviews ) { - if ( sub.isHidden || !sub.layer ) + if ( sub.isHidden ) continue; [sub setNeedsDisplay:YES]; @@ -3050,8 +3053,10 @@ void wxWidgetCocoaImpl::SetNeedsDisplay( const wxRect* where ) // 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 ) +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14 + if ( wxPlatformInfo::Get().CheckOSVersion(10, 14 ) ) SetSubviewsNeedDisplay(m_osxView); +#endif } bool wxWidgetCocoaImpl::GetNeedsDisplay() const diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index a8242fc83c..be965a4890 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1919,6 +1919,8 @@ void wxWindowMac::MacUpdateClippedRects() const bool wxWindowMac::MacDoRedraw( long time ) { bool handled = false ; + if ( !IsShownOnScreen() ) + return handled; wxRegion formerUpdateRgn = m_updateRegion; wxRegion clientUpdateRgn = formerUpdateRgn;