From 191f724631e50b50f94b8ae227752fb07ed7fac3 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Wed, 29 Apr 2020 08:48:16 -0500 Subject: [PATCH] Bug 2406 - Mac: (Catalina) No transparency in docking-icon. Backported upstream fix for: https://trac.wxwidgets.org/ticket/18257 --- src/osx/cocoa/nonownedwnd.mm | 6 ------ src/osx/cocoa/window.mm | 13 ++++++++++++- src/osx/nonownedwnd_osx.cpp | 9 ++++++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index 9291601699..76d8b30157 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -739,12 +739,6 @@ long style, long extraStyle, const wxString& WXUNUSED(name) ) [m_macWindow setDelegate:controller]; - if ( ( style & wxFRAME_SHAPED) ) - { - [m_macWindow setOpaque:NO]; - [m_macWindow setAlphaValue:1.0]; - } - if ( !(style & wxFRAME_TOOL_WINDOW) ) [m_macWindow setHidesOnDeactivate:NO]; } diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index a298a1abc5..f181021128 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -4984,7 +4984,15 @@ void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col ) if ( [targetView respondsToSelector:@selector(setBackgroundColor:) ] ) { - [targetView setBackgroundColor: col.OSXGetNSColor()]; + wxWindow* peer = GetWXPeer(); + if ( peer->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT ) + { + wxTopLevelWindow* toplevel = wxDynamicCast(peer,wxTopLevelWindow); + + if ( toplevel == NULL || toplevel->GetShape().IsEmpty() ) + [targetView setBackgroundColor: + col.IsOk() ? col.OSXGetNSColor() : nil]; + } } } @@ -4995,6 +5003,9 @@ bool wxWidgetCocoaImpl::SetBackgroundStyle( wxBackgroundStyle style ) if ( [m_osxView respondsToSelector:@selector(setOpaque:) ] ) { [m_osxView setOpaque: opaque]; + + if ( style == wxBG_STYLE_TRANSPARENT ) + [m_osxView setBackgroundColor:[NSColor clearColor]]; } return true ; diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index d14c023855..7e9ca9c84f 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -256,7 +256,10 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) if ( !wxWindow::SetBackgroundColour(c) && m_hasBgCol ) return false ; - if ( GetBackgroundStyle() != wxBG_STYLE_CUSTOM ) + // only set the native background color if the toplevel window's + // background is not supposed to be transparent, otherwise the + // transparency is lost + if ( GetBackgroundStyle() != wxBG_STYLE_PAINT && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT) { if ( m_nowpeer ) return m_nowpeer->SetBackgroundColour(c); @@ -511,6 +514,10 @@ bool wxNonOwnedWindow::DoSetRegionShape(const wxRegion& region) { m_shape = region; + // set the native content view to transparency, this is an implementation detail + // no reflected in the wx BackgroundStyle + GetPeer()->SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); + return m_nowpeer->SetShape(region); }