From 169fb2c7f5994d883eea4fb7a82bd711ff025aaf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 8 Apr 2016 22:15:56 +0200 Subject: [PATCH] Fix background for children of windows with RTL layout in wxMSW To correctly compute the brush origin offset for painting background of a child in a window using RTL layout, we need to offset it by the child origin i.e. its _right_ top corner in this case and not the left top corner as we did before. Conveniently, although not very explicitly, MapWindowPoints() already takes care of this for us if we just pass it both the left and right points, but we wrongly passed it only a single one, so it couldn't work its magic in this case. Change this to fix the drawing artefacts which appeared over wxNotebook children with transparent background (e.g. wxStaticText) due to the use of wrong origin before. --- src/msw/window.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 01c9d59584..5be1dbca19 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4888,7 +4888,13 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child) RECT rc; ::GetWindowRect(GetHwndOf(child), &rc); - ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 1); + // It is important to pass both points to MapWindowPoints() as in + // addition to converting them to our coordinate system, this function + // will also exchange the left and right coordinates if this window + // uses RTL layout, which is exactly what we need here as the child + // window origin is its _right_ top corner in this case and not the + // left one. + ::MapWindowPoints(NULL, GetHwnd(), (POINT *)&rc, 2); int x = rc.left, y = rc.top;