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
This commit is contained in:
Václav Slavík
2020-12-31 14:00:43 +01:00
committed by Vadim Zeitlin
parent bc4f78598d
commit 287ee5e4c7
3 changed files with 21 additions and 8 deletions

View File

@@ -31,6 +31,10 @@
#include "wx/settings.h"
#endif
#ifdef __WXOSX__
#include "wx/osx/private/available.h"
#endif
#include "wx/renderer.h"
#include <stdlib.h>
@@ -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);
}

View File

@@ -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

View File

@@ -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);