[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - include/vcl vcl/headless vcl/inc vcl/osx vcl/qt5 vcl/source vcl/unx vcl/win

Michael Weghorn (via logerrit) logerrit at kemper.freedesktop.org
Tue Aug 25 13:04:45 UTC 2020


 include/vcl/outdev.hxx                      |    3 +-
 include/vcl/window.hxx                      |    2 +
 vcl/headless/CustomWidgetDraw.cxx           |    3 +-
 vcl/inc/FileDefinitionWidgetDraw.hxx        |    3 +-
 vcl/inc/WidgetDrawInterface.hxx             |    6 +++--
 vcl/inc/headless/CustomWidgetDraw.hxx       |    3 +-
 vcl/inc/qt5/Qt5Graphics_Controls.hxx        |    3 +-
 vcl/inc/quartz/salgdi.h                     |    2 -
 vcl/inc/salgdi.hxx                          |    3 +-
 vcl/inc/unx/gtk/gtkgdi.hxx                  |    5 ++--
 vcl/inc/win/salgdi.h                        |    2 -
 vcl/osx/salnativewidgets.cxx                |    3 +-
 vcl/qt5/Qt5Graphics_Controls.cxx            |    3 +-
 vcl/source/control/edit.cxx                 |   18 +++++++++++------
 vcl/source/gdi/FileDefinitionWidgetDraw.cxx |    3 +-
 vcl/source/gdi/salgdilayout.cxx             |    7 +++---
 vcl/source/outdev/nativecontrols.cxx        |    5 ++--
 vcl/source/window/brdwin.cxx                |    5 +++-
 vcl/source/window/paint.cxx                 |    8 ++++++-
 vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx   |   29 +++++++++++++++++++++++++++-
 vcl/win/gdi/salnativewidgets-luna.cxx       |    3 +-
 21 files changed, 89 insertions(+), 30 deletions(-)

New commits:
commit 1d8c0009f61ee716c6b51e397bc6bdf954273573
Author:     Michael Weghorn <m.weghorn at posteo.de>
AuthorDate: Mon Aug 24 17:18:03 2020 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Tue Aug 25 15:04:09 2020 +0200

    tdf#136094 Handle background color in drawNativeControl
    
    Make gtk3's 'GtkSalGraphics::drawNativeControl'
    take into account a control's background color,
    if any is explicitly set:
    
    Set background/fill color (in 'Edit::ApplySettings')
    also for the case where the control is drawn "natively",
    but don't draw the background in the generic 'Window::Erase'
    method for the case of native drawing; instead handle it when
    drawing the control itself.
    
    This adds an additional parameter to pass the background color to the
    relevant '{d,D}rawNativeControl' methods (defaulting to 'COL_AUTO')
    and implements the required handling to apply the background color
    for the gtk3 case.
    
    qt5/kf5 will probably be handled in an upcoming commit as well.
    
    Windows as well as the "gen" VCL plugin were not affected by the
    issue, so remain unchanged and just ignore the new parameter.
    
    In a quick test on on macOS, the rendering of the controls
    in the sample doc was broken beyond just the missing background
    colors (s. screenshot attached to tdf#136094); the behavior there
    also remains unchanged by this patch, the new parameter is ignored
    for now.
    
    Change-Id: I01923a504fea2367ae96032104f09099e35f410e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101284
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>
    Tested-by: Michael Weghorn <m.weghorn at posteo.de>
    (cherry picked from commit 2c9052802ea411dffbf5906c4914611fcbfbc6a5)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101166

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index cd3c84d13305..b8d3c86d072f 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1972,7 +1972,8 @@ public:
                                     const tools::Rectangle& rControlRegion,
                                     ControlState nState,
                                     const ImplControlValue& aValue,
-                                    const OUString& aCaption );
+                                    const OUString& aCaption,
+                                    const Color& rBackgroundColor = COL_AUTO );
 
     /** Query the native control's actual drawing region (including adornment)
      */
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index d23b34e397dd..1312d6abb546 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -413,6 +413,7 @@ const char* ImplDbgCheckWindow( const void* pObj );
 namespace vcl { class Window; }
 namespace vcl { class Cursor; }
 class Dialog;
+class Edit;
 class WindowImpl;
 class PaintHelper;
 class VclSizeGroup;
@@ -478,6 +479,7 @@ class VCL_DLLPUBLIC Window : public ::OutputDevice
     friend class ::SystemWindow;
     friend class ::WorkWindow;
     friend class ::Dialog;
+    friend class ::Edit;
     friend class ::MessBox;
     friend class ::MessageDialog;
     friend class ::DockingWindow;
diff --git a/vcl/headless/CustomWidgetDraw.cxx b/vcl/headless/CustomWidgetDraw.cxx
index 677c575b96bb..f2a15bb10c9d 100644
--- a/vcl/headless/CustomWidgetDraw.cxx
+++ b/vcl/headless/CustomWidgetDraw.cxx
@@ -67,7 +67,8 @@ bool CustomWidgetDraw::hitTestNativeControl(ControlType /*eType*/, ControlPart /
 bool CustomWidgetDraw::drawNativeControl(ControlType eType, ControlPart ePart,
                                          const tools::Rectangle& rControlRegion,
                                          ControlState eState, const ImplControlValue& rValue,
-                                         const OUString& /*aCaptions*/)
+                                         const OUString& /*aCaptions*/,
+                                         const Color& /*rBackgroundColor*/)
 {
     if (!s_pWidgetImplementation)
         return false;
diff --git a/vcl/inc/FileDefinitionWidgetDraw.hxx b/vcl/inc/FileDefinitionWidgetDraw.hxx
index 7e3d398fb0f8..e1aa5d06733c 100644
--- a/vcl/inc/FileDefinitionWidgetDraw.hxx
+++ b/vcl/inc/FileDefinitionWidgetDraw.hxx
@@ -42,7 +42,8 @@ public:
 
     bool drawNativeControl(ControlType eType, ControlPart ePart,
                            const tools::Rectangle& rBoundingControlRegion, ControlState eState,
-                           const ImplControlValue& aValue, const OUString& aCaptions) override;
+                           const ImplControlValue& aValue, const OUString& aCaptions,
+                           const Color& rBackgroundColor) override;
 
     bool getNativeControlRegion(ControlType eType, ControlPart ePart,
                                 const tools::Rectangle& rBoundingControlRegion, ControlState eState,
diff --git a/vcl/inc/WidgetDrawInterface.hxx b/vcl/inc/WidgetDrawInterface.hxx
index 2c882950b03a..78d5d7625491 100644
--- a/vcl/inc/WidgetDrawInterface.hxx
+++ b/vcl/inc/WidgetDrawInterface.hxx
@@ -58,12 +58,13 @@ public:
      * @param [in] eState The general state of the control (enabled, focused, etc.).
      * @param [in] aValue Addition control specific information.
      * @param [in] aCaption  A caption or title string (like button text etc.).
+     * @param [in] rBackgroundColor Background color for the control (may be COL_AUTO)
      * @return true, if the control could be drawn.
      */
     virtual inline bool drawNativeControl(ControlType eType, ControlPart ePart,
                                           const tools::Rectangle& rBoundingControlRegion,
                                           ControlState eState, const ImplControlValue& aValue,
-                                          const OUString& aCaptions);
+                                          const OUString& aCaptions, const Color& rBackgroundColor);
 
     /**
      * Get the native control regions for the control part.
@@ -103,7 +104,8 @@ bool WidgetDrawInterface::hitTestNativeControl(ControlType, ControlPart, const t
 }
 
 bool WidgetDrawInterface::drawNativeControl(ControlType, ControlPart, const tools::Rectangle&,
-                                            ControlState, const ImplControlValue&, const OUString&)
+                                            ControlState, const ImplControlValue&, const OUString&,
+                                            const Color& /*rBackgroundColor*/)
 {
     return false;
 }
diff --git a/vcl/inc/headless/CustomWidgetDraw.hxx b/vcl/inc/headless/CustomWidgetDraw.hxx
index 7abd8445ddbe..ada66ec4f0a0 100644
--- a/vcl/inc/headless/CustomWidgetDraw.hxx
+++ b/vcl/inc/headless/CustomWidgetDraw.hxx
@@ -37,7 +37,8 @@ public:
 
     bool drawNativeControl(ControlType eType, ControlPart ePart,
                            const tools::Rectangle& rBoundingControlRegion, ControlState eState,
-                           const ImplControlValue& aValue, const OUString& aCaptions) override;
+                           const ImplControlValue& aValue, const OUString& aCaptions,
+                           const Color& rBackgroundColor) override;
 
     bool getNativeControlRegion(ControlType eType, ControlPart ePart,
                                 const tools::Rectangle& rBoundingControlRegion, ControlState eState,
diff --git a/vcl/inc/qt5/Qt5Graphics_Controls.hxx b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
index 2676fa6413a4..8d9d5a11da45 100644
--- a/vcl/inc/qt5/Qt5Graphics_Controls.hxx
+++ b/vcl/inc/qt5/Qt5Graphics_Controls.hxx
@@ -45,7 +45,8 @@ public:
                               bool& rIsInside) override;
     bool drawNativeControl(ControlType nType, ControlPart nPart,
                            const tools::Rectangle& rControlRegion, ControlState nState,
-                           const ImplControlValue& aValue, const OUString& aCaption) override;
+                           const ImplControlValue& aValue, const OUString& aCaption,
+                           const Color& rBackgroundColor) override;
     bool getNativeControlRegion(ControlType nType, ControlPart nPart,
                                 const tools::Rectangle& rControlRegion, ControlState nState,
                                 const ImplControlValue& aValue, const OUString& aCaption,
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index 338878e79529..f3c38884910b 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -302,7 +302,7 @@ protected:
                                                   const Point& aPos, bool& rIsInside ) override;
     virtual bool            drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
                                                ControlState nState, const ImplControlValue& aValue,
-                                               const OUString& aCaption ) override;
+                                               const OUString& aCaption, const Color& rBackgroundColor ) override;
     virtual bool            getNativeControlRegion( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState,
                                                     const ImplControlValue& aValue, const OUString& aCaption,
                                                     tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override;
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 6b5899a4ce10..b51bef97587f 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -367,7 +367,8 @@ public:
                                     ControlState nState,
                                     const ImplControlValue& aValue,
                                     const OUString& aCaption,
-                                    const OutputDevice *pOutDev );
+                                    const OutputDevice *pOutDev,
+                                    const Color& rBackgroundColor = COL_AUTO );
 
     /**
      * @see WidgetDrawInterface::getNativeControlRegion
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index cd9cf4c5b562..ce35398d85cd 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -105,7 +105,8 @@ protected:
     virtual bool        drawNativeControl( ControlType nType, ControlPart nPart,
                                                const tools::Rectangle& rControlRegion,
                                                ControlState nState, const ImplControlValue& aValue,
-                                               const OUString& rCaption ) override;
+                                               const OUString& rCaption,
+                                               const Color& rBackgroundColor ) override;
     virtual bool        getNativeControlRegion( ControlType nType, ControlPart nPart,
                                                     const tools::Rectangle& rControlRegion,
                                                     ControlState nState,
@@ -272,7 +273,7 @@ protected:
                                               const Point& aPos, bool& rIsInside ) override;
     virtual bool        drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
                                            ControlState nState, const ImplControlValue& aValue,
-                                           const OUString& rCaption ) override;
+                                           const OUString& rCaption, const Color& rBackgroundColor ) override;
     virtual bool        getNativeControlRegion( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState,
                                                 const ImplControlValue& aValue, const OUString& rCaption,
                                                 tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index d6d8dea14c24..dbae724c8b15 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -270,7 +270,7 @@ protected:
                                               const Point& aPos, bool& rIsInside ) override;
     virtual bool        drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
                                            ControlState nState, const ImplControlValue& aValue,
-                                           const OUString& aCaption ) override;
+                                           const OUString& aCaption, const Color& rBackgroundColor ) override;
     virtual bool        getNativeControlRegion( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion, ControlState nState,
                                                 const ImplControlValue& aValue, const OUString& aCaption,
                                                 tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion ) override;
diff --git a/vcl/osx/salnativewidgets.cxx b/vcl/osx/salnativewidgets.cxx
index 5248251480c5..220107173e0d 100644
--- a/vcl/osx/salnativewidgets.cxx
+++ b/vcl/osx/salnativewidgets.cxx
@@ -255,7 +255,8 @@ bool AquaSalGraphics::drawNativeControl(ControlType nType,
                                         const tools::Rectangle &rControlRegion,
                                         ControlState nState,
                                         const ImplControlValue &aValue,
-                                        const OUString &)
+                                        const OUString &,
+                                        const Color&)
 {
     bool bOK = false;
     if (!CheckContext())
diff --git a/vcl/qt5/Qt5Graphics_Controls.cxx b/vcl/qt5/Qt5Graphics_Controls.cxx
index ff8537764bd9..951990cbbd49 100644
--- a/vcl/qt5/Qt5Graphics_Controls.cxx
+++ b/vcl/qt5/Qt5Graphics_Controls.cxx
@@ -192,7 +192,8 @@ void lcl_fullQStyleOptionTabWidgetFrame(QStyleOptionTabWidgetFrame& option)
 bool Qt5Graphics_Controls::drawNativeControl(ControlType type, ControlPart part,
                                              const tools::Rectangle& rControlRegion,
                                              ControlState nControlState,
-                                             const ImplControlValue& value, const OUString&)
+                                             const ImplControlValue& value, const OUString&,
+                                             const Color& /*rBackgroundColor*/)
 {
     bool nativeSupport = isNativeControlSupported(type, part);
     if (!nativeSupport)
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 8cb0a06594fa..9d1596b0605c 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -374,17 +374,23 @@ void Edit::ApplySettings(vcl::RenderContext& rRenderContext)
     Color aTextColor = rStyleSettings.GetFieldTextColor();
     ApplyControlForeground(rRenderContext, aTextColor);
 
-    if (ImplUseNativeBorder(rRenderContext, GetStyle()))
+    if (IsControlBackground())
+    {
+        rRenderContext.SetBackground(GetControlBackground());
+        rRenderContext.SetFillColor(GetControlBackground());
+
+        if (ImplUseNativeBorder(rRenderContext, GetStyle()))
+        {
+            // indicates that no non-native drawing of background should take place
+            mpWindowImpl->mnNativeBackground = ControlPart::Entire;
+        }
+    }
+    else if (ImplUseNativeBorder(rRenderContext, GetStyle()))
     {
         // Transparent background
         rRenderContext.SetBackground();
         rRenderContext.SetFillColor();
     }
-    else if (IsControlBackground())
-    {
-        rRenderContext.SetBackground(GetControlBackground());
-        rRenderContext.SetFillColor(GetControlBackground());
-    }
     else
     {
         rRenderContext.SetBackground(rStyleSettings.GetFieldColor());
diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
index 0eb0484d4cbe..e503e813879c 100644
--- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
+++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx
@@ -518,7 +518,8 @@ bool FileDefinitionWidgetDraw::drawNativeControl(ControlType eType, ControlPart
                                                  const tools::Rectangle& rControlRegion,
                                                  ControlState eState,
                                                  const ImplControlValue& rValue,
-                                                 const OUString& /*aCaptions*/)
+                                                 const OUString& /*aCaptions*/,
+                                                 const Color& /*rBackgroundColor*/)
 {
     bool bOldAA = m_rGraphics.getAntiAliasB2DDraw();
     m_rGraphics.setAntiAliasB2DDraw(true);
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index de11058e4507..f6a1ff917404 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -822,7 +822,8 @@ void SalGraphics::mirror( ImplControlValue& rVal, const OutputDevice* pOutDev )
 
 bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
                                                 ControlState nState, const ImplControlValue& aValue,
-                                                const OUString& aCaption, const OutputDevice *pOutDev)
+                                                const OUString& aCaption, const OutputDevice *pOutDev,
+                                                const Color& rBackgroundColor)
 {
     bool bRet = false;
     tools::Rectangle aControlRegion(rControlRegion);
@@ -834,10 +835,10 @@ bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const
         mirror(aControlRegion, pOutDev);
         std::unique_ptr< ImplControlValue > mirrorValue( aValue.clone());
         mirror( *mirrorValue, pOutDev );
-        bRet = forWidget()->drawNativeControl(nType, nPart, aControlRegion, nState, *mirrorValue, aCaption);
+        bRet = forWidget()->drawNativeControl(nType, nPart, aControlRegion, nState, *mirrorValue, aCaption, rBackgroundColor);
     }
     else
-        bRet = forWidget()->drawNativeControl(nType, nPart, aControlRegion, nState, aValue, aCaption);
+        bRet = forWidget()->drawNativeControl(nType, nPart, aControlRegion, nState, aValue, aCaption, rBackgroundColor);
 
     if (bRet && m_pWidgetDraw)
         handleDamage(aControlRegion);
diff --git a/vcl/source/outdev/nativecontrols.cxx b/vcl/source/outdev/nativecontrols.cxx
index 51d4f2882ccc..03d49f99c122 100644
--- a/vcl/source/outdev/nativecontrols.cxx
+++ b/vcl/source/outdev/nativecontrols.cxx
@@ -289,7 +289,8 @@ bool OutputDevice::DrawNativeControl( ControlType nType,
                             const tools::Rectangle& rControlRegion,
                             ControlState nState,
                             const ImplControlValue& aValue,
-                            const OUString& aCaption )
+                            const OUString& aCaption,
+                            const Color& rBackgroundColor )
 {
     assert(!is_double_buffered_window());
 
@@ -315,7 +316,7 @@ bool OutputDevice::DrawNativeControl( ControlType nType,
     std::shared_ptr< ImplControlValue > aScreenCtrlValue( TransformControlValue( aValue, *this ) );
     tools::Rectangle screenRegion( ImplLogicToDevicePixel( rControlRegion ) );
 
-    bool bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this );
+    bool bRet = mpGraphics->DrawNativeControl(nType, nPart, screenRegion, nState, *aScreenCtrlValue, aCaption, this, rBackgroundColor );
 
     return bRet;
 }
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 1b436b544700..a462876f885f 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -700,7 +700,10 @@ void ImplSmallBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, c
             aCtrlRegion=aContentRgn;
         }
 
-        bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, aCtrlPart, aCtrlRegion, nState, aControlValue, OUString());
+        Color aBackgroundColor = COL_AUTO;
+        if (pCtrl->IsControlBackground())
+            aBackgroundColor = pCtrl->GetBackgroundColor();
+        bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, aCtrlPart, aCtrlRegion, nState, aControlValue, OUString(), aBackgroundColor);
 
         // if the native theme draws the spinbuttons in one call, make sure the proper settings
         // are passed, this might force a redraw though... (TODO: improve)
diff --git a/vcl/source/window/paint.cxx b/vcl/source/window/paint.cxx
index 6e6b8b4bfe6c..107bbe9297ac 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -1632,7 +1632,13 @@ void Window::Erase(vcl::RenderContext& rRenderContext)
     bool bNativeOK = false;
 
     ControlPart aCtrlPart = ImplGetWindowImpl()->mnNativeBackground;
-    if (aCtrlPart != ControlPart::NONE && ! IsControlBackground())
+
+    if (aCtrlPart == ControlPart::Entire && IsControlBackground())
+    {
+        // nothing to do here; background is drawn in corresponding drawNativeControl implementation
+        bNativeOK = true;
+    }
+    else if (aCtrlPart != ControlPart::NONE && ! IsControlBackground())
     {
         tools::Rectangle aCtrlRegion(Point(), GetOutputSizePixel());
         ControlState nState = ControlState::NONE;
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 716d5316203a..8ab9f5cc4617 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -2313,7 +2313,7 @@ void GtkSalGraphics::handleDamage(const tools::Rectangle& rDamagedRegion)
 
 bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const tools::Rectangle& rControlRegion,
                                             ControlState nState, const ImplControlValue& rValue,
-                                            const OUString&)
+                                            const OUString&, const Color& rBackgroundColor)
 {
     RenderType renderType = nPart == ControlPart::Focus ? RenderType::Focus : RenderType::BackgroundAndFrame;
     GtkStyleContext *context = nullptr;
@@ -2564,6 +2564,20 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
         gtk_style_context_add_class(context, styleClass);
     }
 
+    // apply background in style, if explicitly set
+    // note: for more complex controls that use multiple styles for their elements,
+    // background may have to be applied for more of those as well (s. case RenderType::Combobox below)
+    GtkCssProvider* pBgCssProvider = nullptr;
+    if (rBackgroundColor != COL_AUTO)
+    {
+        const OUString sColorCss = "* { background-color: #" + rBackgroundColor.AsRGBHexString() + "; }";
+        const OString aResult = OUStringToOString(sColorCss, RTL_TEXTENCODING_UTF8);
+        pBgCssProvider =  gtk_css_provider_new();
+        gtk_css_provider_load_from_data(pBgCssProvider, aResult.getStr(), aResult.getLength(), nullptr);
+        gtk_style_context_add_provider(context, GTK_STYLE_PROVIDER(pBgCssProvider),
+                                       GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    }
+
     switch(renderType)
     {
     case RenderType::Background:
@@ -2615,7 +2629,16 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
         PaintSpinButton(flags, cr, rControlRegion, nPart, rValue);
         break;
     case RenderType::Combobox:
+        if (pBgCssProvider)
+        {
+            gtk_style_context_add_provider(mpComboboxEntryStyle, GTK_STYLE_PROVIDER(pBgCssProvider),
+                                           GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+        }
         PaintCombobox(flags, cr, rControlRegion, nType, nPart);
+        if (pBgCssProvider)
+        {
+            gtk_style_context_remove_provider(mpComboboxEntryStyle, GTK_STYLE_PROVIDER(pBgCssProvider));
+        }
         break;
     case RenderType::Icon:
         gtk_style_context_save (context);
@@ -2694,6 +2717,10 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
     {
         gtk_style_context_remove_class(context, styleClass);
     }
+    if (pBgCssProvider)
+    {
+        gtk_style_context_remove_provider(context, GTK_STYLE_PROVIDER(pBgCssProvider));
+    }
     aContextState.restore();
 
     cairo_destroy(cr); // unref
diff --git a/vcl/win/gdi/salnativewidgets-luna.cxx b/vcl/win/gdi/salnativewidgets-luna.cxx
index 84a9bda35ec3..f39e93c8c2d5 100644
--- a/vcl/win/gdi/salnativewidgets-luna.cxx
+++ b/vcl/win/gdi/salnativewidgets-luna.cxx
@@ -1150,7 +1150,8 @@ bool WinSalGraphics::drawNativeControl( ControlType nType,
                                         const tools::Rectangle& rControlRegion,
                                         ControlState nState,
                                         const ImplControlValue& aValue,
-                                        const OUString& aCaption )
+                                        const OUString& aCaption,
+                                        const Color& /*rBackgroundColor*/ )
 {
     bool bOk = false;
     HTHEME hTheme = nullptr;


More information about the Libreoffice-commits mailing list