From 565553ee980e925bbd8b3cdaeea0eb9f453d7dfd Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 18 Mar 2026 16:55:56 +0100 Subject: [PATCH] Make default background color transparent in wxOSX This is needed for translucency effects, desktop background images changing the toplevel window background tint. Also don't erase background when no background color is specified. Closes #26301. --- include/wx/osx/window.h | 8 ++++++++ src/osx/window_osx.cpp | 14 +++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/wx/osx/window.h b/include/wx/osx/window.h index 3f867c66a5..58bcf0acb1 100644 --- a/include/wx/osx/window.h +++ b/include/wx/osx/window.h @@ -133,6 +133,14 @@ public: #endif + virtual wxVisualAttributes GetDefaultAttributes() const override + { + return GetClassDefaultAttributes(GetWindowVariant()); + } + + static wxVisualAttributes + GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); + // implementation from now on // -------------------------- diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 252ed51639..34b71b8d29 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -1538,6 +1538,17 @@ wxWindowMac::AlwaysShowScrollbars(bool hflag, bool vflag) DoUpdateScrollbarVisibility(); } +/* static */ wxVisualAttributes +wxWindowMac::GetClassDefaultAttributes(wxWindowVariant variant) +{ + // it is important to return valid values for all attributes from here, + // GetXXX() below rely on this + wxVisualAttributes attrs = wxWindowBase::GetClassDefaultAttributes(variant); + attrs.colBg = wxTransparentColour; + + return attrs; +} + // // we draw borders and grow boxes, are already set up and clipped in the current port / cgContextRef // our own window origin is at leftOrigin/rightOrigin @@ -2002,9 +2013,10 @@ bool wxWindowMac::MacDoRedraw( long time ) eevent.SetEventObject( this ); if ( ProcessWindowEvent( eevent ) ) break; - +#ifdef __WXOSX_IPHONE__ if (!UseBgCol()) dc.Clear(); +#endif } if ( UseBgCol() )