path: root/vcl/source/window
diff options
authorMichael Weghorn <>2020-08-24 17:18:03 +0200
committerMichael Weghorn <>2020-08-25 14:16:24 +0200
commit2c9052802ea411dffbf5906c4914611fcbfbc6a5 (patch)
treee6770ee575093376968135484b373b8d85155927 /vcl/source/window
parent041fd5a6b8c1f0002cfc693ef66daf28a86df371 (diff)
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: Reviewed-by: Michael Weghorn <> Tested-by: Michael Weghorn <>
Diffstat (limited to 'vcl/source/window')
2 files changed, 11 insertions, 2 deletions
diff --git a/vcl/source/window/brdwin.cxx b/vcl/source/window/brdwin.cxx
index 1d9d6cbec2f8..e59f2581747a 100644
--- a/vcl/source/window/brdwin.cxx
+++ b/vcl/source/window/brdwin.cxx
@@ -701,7 +701,10 @@ void ImplSmallBorderWindowView::DrawWindow(vcl::RenderContext& rRenderContext, c
- 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 670909e3bccb..80b2f85b2349 100644
--- a/vcl/source/window/paint.cxx
+++ b/vcl/source/window/paint.cxx
@@ -1603,7 +1603,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;