From 287ee5e4c7d15273d2f18a6aa77409bb35b1f9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Thu, 31 Dec 2020 14:00:43 +0100 Subject: [PATCH] Fix window background tinting on macOS 11 macOS 11 has an option (on by default) to tint window backgrounds with wallpaper colors. This means that standard window background color is not a constant anymore and can change as the window is moved across the screen. The key to supporting this is to _not set background color_ internally to what we think is the correct default color, or to repaint backgrounds. Let the OS handle the default behavior instead. Closes https://github.com/wxWidgets/wxWidgets/pull/2158 --- src/generic/splitter.cpp | 26 +++++++++++++++++++++----- src/osx/carbon/frame.cpp | 1 - src/osx/nonownedwnd_osx.cpp | 2 -- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 0a8512278c..dc4732baf2 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -31,6 +31,10 @@ #include "wx/settings.h" #endif +#ifdef __WXOSX__ + #include "wx/osx/private/available.h" +#endif + #include "wx/renderer.h" #include @@ -175,11 +179,23 @@ void wxSplitterWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) { wxPaintDC dc(this); #ifdef __WXOSX__ - // as subpanels might have a transparent background we must erase the background - // at least on OSX, otherwise traces of the sash will remain - // test with: splitter sample->replace right window - dc.Clear(); -#endif + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_16 + if ( WX_IS_MACOS_AVAILABLE(10, 16) ) + { + // Nothing to do: since macOS 10.14, views are layer-backed or using a shared + // layer and explicitly clearing the background isn't needed. This only + // started mattering here with macOS 11 (aka 10.16 when built with older SDK), + // where we must avoid explicitly painting window backgrounds + } + else + #endif + { + // as subpanels might have a transparent background we must erase the background + // at least on OSX, otherwise traces of the sash will remain + // test with: splitter sample->replace right window + dc.Clear(); + } +#endif // __WXOSX__ DrawSash(dc); } diff --git a/src/osx/carbon/frame.cpp b/src/osx/carbon/frame.cpp index 67d8616303..25ee3616a2 100644 --- a/src/osx/carbon/frame.cpp +++ b/src/osx/carbon/frame.cpp @@ -129,7 +129,6 @@ void wxFrame::PositionStatusBar() // Responds to colour changes, and passes event on to children. void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { - SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); Refresh(); #if wxUSE_STATUSBAR diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index 470b8ea7ca..81938b9a92 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -152,8 +152,6 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, wxWindowCreateEvent event(this); HandleWindowEvent(event); - SetBackgroundColour(wxSystemSettings::GetColour( wxSYS_COLOUR_APPWORKSPACE )); - if ( parent ) parent->AddChild(this);