Further fixes to widget masking
authorMiikka Heikkinen <miikka.heikkinen@digia.com>
Wed, 27 Jun 2012 14:15:42 +0000 (17:15 +0300)
committerQt by Nokia <qt-info@nokia.com>
Thu, 28 Jun 2012 08:18:15 +0000 (10:18 +0200)
If mask was set to a widget before the widget was shown,
the mask was not applied.

Also, if toplevel widgets were set a mask in Windows, the mask was
applied to frame coordinates instead of client coordinates.

Ported relevant code from Qt4 to fix these issues.

Change-Id: Id6187cf4952b81b5b60c167e2fd284b7dc83ed9c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
src/plugins/platforms/windows/qwindowswindow.cpp
src/widgets/kernel/qwidget_qpa.cpp

index a7140a3..2b86113 100644 (file)
@@ -1392,6 +1392,13 @@ void QWindowsWindow::setMask(const QRegion &region)
          return;
     }
     const HRGN winRegion = qRegionToWinRegion(region);
+
+    // Mask is in client area coordinates, so offset it in case we have a frame
+    if (window()->isTopLevel()) {
+        const QMargins margins = frameMargins();
+        OffsetRgn(winRegion, margins.left(), margins.top());
+    }
+
     // SetWindowRgn takes ownership.
     if (!SetWindowRgn(m_data.hwnd, winRegion, true))
         DeleteObject(winRegion);
index 25d79fa..c524491 100644 (file)
@@ -151,6 +151,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
     // Check children and create windows for them if necessary
     q_createNativeChildrenAndSetParent(q);
 
+    if (extra && !extra->mask.isEmpty())
+        setMask_sys(extra->mask);
+
     // If widget is already shown, set window visible, too
     if (q->isVisible())
         win->setVisible(true);