include/vcl/weld.hxx                |    2 ++
 svx/source/form/labelitemwindow.cxx |    2 +-
 vcl/inc/qt5/QtInstanceWidget.hxx    |    2 ++
 vcl/inc/salvtables.hxx              |    2 ++
 vcl/qt5/QtInstanceWidget.cxx        |   15 +++++++++++++++
 vcl/source/app/salvtables.cxx       |    6 ++++++
 vcl/unx/gtk3/gtkinst.cxx            |    5 +++++
 7 files changed, 33 insertions(+), 1 deletion(-)

New commits:
commit 87b3b8e6990b394baa74aec8701cd097f6c0c646
Author:     Noel Grandin <noel.gran...@collabora.co.uk>
AuthorDate: Wed May 28 14:41:29 2025 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Thu May 29 11:01:27 2025 +0200

    tdf#166321 Find bar: blank square with gen environment
    
    Regression from
        commit e0d4d178caff1414a9a21fa57f06bc8d4d2c389a
        Author: Noel Grandin <noel.gran...@collabora.co.uk>
        Date:   Mon Jan 13 15:03:05 2025 +0200
        Change alpha behavour of OutputDevice::SetFillColor
    
    Which exposed another place where COL_AUTO is troublesome.
    
    Previouslu, calling set_background(COL_AUTO) used to work
    because COL_AUTO has the same value as COL_TRANSPARENT,
    and calling
        OutputDevice::setBackground(COL_TRANSPARENT)
    would have the same effect as
        OutputDevice::setBackground()
    
    But that is no longer the case, especially when we are drawing to
    an OutputDevice which has no alpha layer.
    In that case, the alpha value is chopped off the Color object, and
    we are left with what is effectively COL_WHITE.
    
    So add some new weld API to make resetting the background to default
    less error-prone.
    
    Change-Id: I29987c4c343af40447ed847a617d6b0e9d673f48
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185968
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 02e8a97a387a..b78bb73092ee 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -369,6 +369,8 @@ public:
     //trying to use a custom color for a background is generally a bad idea. 
If your need
     //fits one of the above categories then that's a somewhat better choice
     virtual void set_background(const Color& rBackColor) = 0;
+    // reset to default background
+    virtual void set_background() = 0;
 
     virtual css::uno::Reference<css::datatransfer::dnd::XDropTarget> 
get_drop_target() = 0;
     virtual css::uno::Reference<css::datatransfer::clipboard::XClipboard> 
get_clipboard() const = 0;
diff --git a/svx/source/form/labelitemwindow.cxx 
b/svx/source/form/labelitemwindow.cxx
index eac9f68bb79b..2a32fe90f185 100644
--- a/svx/source/form/labelitemwindow.cxx
+++ b/svx/source/form/labelitemwindow.cxx
@@ -47,7 +47,7 @@ void LabelItemWindow::set_label(const OUString& rLabel, const 
LabelItemWindowTyp
     {
         m_xImage->hide();
         m_xLabel->set_font_color(COL_AUTO);
-        m_xBox->set_background(COL_AUTO);
+        m_xBox->set_background(); // reset to default
     }
     else if (eType == LabelItemWindowType::Info)
     {
diff --git a/vcl/inc/qt5/QtInstanceWidget.hxx b/vcl/inc/qt5/QtInstanceWidget.hxx
index cdce0ef3231c..3799f09815e4 100644
--- a/vcl/inc/qt5/QtInstanceWidget.hxx
+++ b/vcl/inc/qt5/QtInstanceWidget.hxx
@@ -173,6 +173,8 @@ public:
     void setFontColor(const Color& rFontColor);
     virtual void set_background(const Color& rBackColor) override;
 
+    virtual void set_background() override;
+
     virtual void draw(OutputDevice&, const Point&, const Size&) override;
 
     virtual bool eventFilter(QObject* pObject, QEvent* pEvent) override;
diff --git a/vcl/inc/salvtables.hxx b/vcl/inc/salvtables.hxx
index 04439f471dce..a057e67f96fa 100644
--- a/vcl/inc/salvtables.hxx
+++ b/vcl/inc/salvtables.hxx
@@ -397,6 +397,8 @@ public:
 
     virtual void set_background(const Color& rColor) override;
 
+    virtual void set_background() override;
+
     virtual void draw(OutputDevice& rOutput, const Point& rPos, const Size& 
rSizePixel) override;
 
     SystemWindow* getSystemWindow();
diff --git a/vcl/qt5/QtInstanceWidget.cxx b/vcl/qt5/QtInstanceWidget.cxx
index 112a16f23e5b..d60b37dafadf 100644
--- a/vcl/qt5/QtInstanceWidget.cxx
+++ b/vcl/qt5/QtInstanceWidget.cxx
@@ -751,6 +751,21 @@ void QtInstanceWidget::set_background(const Color& 
rBackColor)
     });
 }
 
+// reset to default
+void QtInstanceWidget::set_background()
+{
+    SolarMutexGuard g;
+
+    GetQtInstance().RunInMainThread([&] {
+        const QPalette::ColorRole eBgRole = getQWidget()->backgroundRole();
+        const QPalette aDefaultPalette = QApplication::palette(getQWidget());
+        QPalette aWidgetPalette = getQWidget()->palette();
+        aWidgetPalette.setColor(eBgRole, aDefaultPalette.color(eBgRole));
+        getQWidget()->setPalette(aWidgetPalette);
+        getQWidget()->setAutoFillBackground(false);
+    });
+}
+
 void QtInstanceWidget::draw(OutputDevice&, const Point&, const Size&)
 {
     assert(false && "Not implemented yet");
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 6c385d4213c1..8c94778ae86f 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -351,6 +351,12 @@ void SalInstanceWidget::set_background(const Color& rColor)
     }
 }
 
+void SalInstanceWidget::set_background()
+{
+    m_xWidget->SetControlBackground();
+    m_xWidget->SetBackground();
+}
+
 SalInstanceWidget::SalInstanceWidget(vcl::Window* pWidget, SalInstanceBuilder* 
pBuilder,
                                      bool bTakeOwnership)
     : m_xWidget(pWidget)
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 07cac1419e65..e88b41f16341 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -4243,6 +4243,11 @@ public:
         do_set_background(rColor);
     }
 
+    virtual void set_background() override
+    {
+        do_set_background(COL_AUTO); // reset to default
+    }
+
     virtual void set_toolbar_background() override
     {
         // no-op

Reply via email to