Blob Blame History Raw
From 41570cf09b171a6ee1f04d39dd72399e2726d381 Mon Sep 17 00:00:00 2001
From: Michael Weghorn <m.weghorn@posteo.de>
Date: Thu, 2 Mar 2023 12:56:13 +0100
Subject: [PATCH] tdf#152073 tdf#153895 basicide: Set bg color for border win

As described in the original commit to address tdf#152073
("Glitch rendering line numbers in Basic IDE editor (kf5 only)"),
the fact that the KDE Breeze style's frame border is partly
transparent was causing artifacts in the Basic IDE:

    commit 6f4b8b7cfe2907b7da46eec6951a0e09b836a6de
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Tue Jan 31 16:08:53 2023 +0100

        tdf#152073 qt: Draw background when drawing frame

        For native drawing of a frame (border), use
        the window background color as default color.

        As mentioned in commit f39f21d92ec83c3a5062f29dd26214fc83012c06
        ("tdf#138010 (IV) VclScrolledWindow: Use actual border width"),
        the Qt/KDE Breeze style uses a frame width of 2, with the
        actual 1 pixel border being surrounded by a 1 pixel
        padding/margin.

        Transparent background did not ensure that the 1 pixel
        padding/margin is repainted and could thus result
        in artifacts from what was painted to that location
        previously (s. the Basic IDE editor example from
        tdf#152073).

        [...]

However, there are cases when a transparent background
is actually wanted, like in the print dialog (tdf#153895).

Therefore, revert the original commit mentioned above
and explicitly set a background color for the border windows
of the involved windows in the Basic IDE instead, which is
in line with the alternative already mentioned in the above commit
("An alternative might be to explicitly draw the
background further up the call stack, [...]."), but enables
transparency in the qt5/qt6/kf5-specific drawing for
the frame again.

Change-Id: Ifb4deb80c6ae245ec630a4fdc23f675e5587836c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148117
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit 699a1745f30cc0e89d59c6fc6ea742da5ff0ccea)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148098
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
---
 basctl/source/basicide/baside2b.cxx         | 4 +++-
 basctl/source/basicide/linenumberwindow.cxx | 4 +++-
 vcl/qt5/QtGraphics_Controls.cxx             | 1 -
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index b5deee9b6a9e..5947c2208b16 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -252,7 +252,9 @@ EditorWindow::EditorWindow (vcl::Window* pParent, ModulWindow* pModulWindow) :
     pCodeCompleteWnd(VclPtr<CodeCompleteWindow>::Create(this))
 {
     set_id("EditorWindow");
-    SetBackground(Wallpaper(rModulWindow.GetLayout().GetSyntaxBackgroundColor()));
+    const Wallpaper aBackground(rModulWindow.GetLayout().GetSyntaxBackgroundColor());
+    SetBackground(aBackground);
+    GetWindow(GetWindowType::Border)->SetBackground(aBackground);
     SetPointer( PointerStyle::Text );
     SetHelpId( HID_BASICIDE_EDITORWINDOW );
 
diff --git a/basctl/source/basicide/linenumberwindow.cxx b/basctl/source/basicide/linenumberwindow.cxx
index 74ead4923863..24ee232c7c28 100644
--- a/basctl/source/basicide/linenumberwindow.cxx
+++ b/basctl/source/basicide/linenumberwindow.cxx
@@ -21,7 +21,9 @@ LineNumberWindow::LineNumberWindow(vcl::Window* pParent, ModulWindow* pModulWind
     , m_pModulWindow(pModulWindow)
     , m_nCurYOffset(0)
 {
-    SetBackground(Wallpaper(GetSettings().GetStyleSettings().GetWindowColor()));
+    const Wallpaper aBackground(GetSettings().GetStyleSettings().GetWindowColor());
+    SetBackground(aBackground);
+    GetWindow(GetWindowType::Border)->SetBackground(aBackground);
     m_FontColor = GetSettings().GetStyleSettings().GetWindowTextColor();
     m_nBaseWidth = GetTextWidth("8");
     m_nWidth = m_nBaseWidth * 3 + m_nBaseWidth / 2;
diff --git a/vcl/qt5/QtGraphics_Controls.cxx b/vcl/qt5/QtGraphics_Controls.cxx
index 71386a6bd5ea..c647152606e8 100644
--- a/vcl/qt5/QtGraphics_Controls.cxx
+++ b/vcl/qt5/QtGraphics_Controls.cxx
@@ -287,7 +287,6 @@ bool QtGraphics_Controls::drawNativeControl(ControlType type, ControlPart part,
                 break;
             }
             [[fallthrough]]; // QPalette::Window
-        case ControlType::Frame:
         case ControlType::Menubar:
         case ControlType::WindowBackground:
             m_image->fill(QApplication::palette().color(QPalette::Window).rgb());
-- 
2.39.2