diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index c59f374f32..a8ab324dd0 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -3311,7 +3311,7 @@ void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col ) wxWindow* peer = GetWXPeer(); if ( peer->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT ) { - wxTopLevelWindow* toplevel = wxDynamicCast(peer,wxTopLevelWindow); + wxNonOwnedWindow* toplevel = dynamic_cast(peer); if ( toplevel == nullptr || toplevel->GetShape().IsEmpty() ) [targetView setBackgroundColor: diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index c9781afe71..2781cbd70f 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -258,7 +258,9 @@ bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) // 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) + // we cannot set the background color on a shaped toplevel window + // otherwise we loose the shape and end up with a rectangular background + if ( GetBackgroundStyle() != wxBG_STYLE_PAINT && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT && GetShape().IsEmpty() ) { if ( m_nowpeer ) return m_nowpeer->SetBackgroundColour(c);