From 687267b9db69ff312953c1c45fab044c1b0cc042 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Mon, 6 Jul 2020 23:13:33 -0700 Subject: [PATCH] Fix the default background color reported for toplevel windows with GTK3 See #18811 --- include/wx/gtk/toplevel.h | 1 + src/gtk/toplevel.cpp | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/include/wx/gtk/toplevel.h b/include/wx/gtk/toplevel.h index 037a7498cb..19227ffa3f 100644 --- a/include/wx/gtk/toplevel.h +++ b/include/wx/gtk/toplevel.h @@ -74,6 +74,7 @@ public: virtual void SetLabel(const wxString& label) wxOVERRIDE { SetTitle( label ); } virtual wxString GetLabel() const wxOVERRIDE { return GetTitle(); } + virtual wxVisualAttributes GetDefaultAttributes() const wxOVERRIDE; virtual bool SetTransparent(wxByte alpha) wxOVERRIDE; virtual bool CanSetTransparent() wxOVERRIDE; diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index d7f94d8b3a..74c6ed2e1b 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -35,6 +35,7 @@ #include "wx/gtk/private.h" #include "wx/gtk/private/gtk3-compat.h" +#include "wx/gtk/private/stylecontext.h" #include "wx/gtk/private/win_gtk.h" #ifdef GDK_WINDOWING_X11 @@ -1815,3 +1816,12 @@ bool wxTopLevelWindowGTK::CanSetTransparent() "Composite", &opcode, &event, &error); #endif } + +wxVisualAttributes wxTopLevelWindowGTK::GetDefaultAttributes() const +{ + wxVisualAttributes attrs(GetClassDefaultAttributes()); +#ifdef __WXGTK3__ + wxGtkStyleContext().AddWindow().Bg(attrs.colBg); +#endif + return attrs; +}