From b56caf5f4e50d867bfef4b9090b1fba130284688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 25 Feb 2013 08:54:30 +0100 Subject: Introduced QWindow::setMask() to expose existing platform functionality. Task-number: QTBUG-28555 Change-Id: I2c649b6d9e9dc69be246cb7658b3edbe9682b1bf Reviewed-by: Friedemann Kleint Reviewed-by: Gunnar Sletta --- src/gui/kernel/qwindow.cpp | 33 +++++++++++++++++++++++++++ src/gui/kernel/qwindow.h | 3 +++ src/gui/kernel/qwindow_p.h | 1 + tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 17 ++++++++++++++ 4 files changed, 54 insertions(+) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index 69ae30389e..33fd4954eb 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -790,6 +790,39 @@ qreal QWindow::opacity() const return d->opacity; } +/*! + Sets the mask of the window. + + The mask is a hint to the windowing system that the application does not + want to receive mouse or touch input outside the given \a region. + + The window manager may or may not choose to display any areas of the window + not included in the mask, thus it is the application's responsibility to + clear to transparent the areas that are not part of the mask. + + Setting the mask before the window has been created has no effect. +*/ +void QWindow::setMask(const QRegion ®ion) +{ + Q_D(QWindow); + if (!d->platformWindow) + return; + d->platformWindow->setMask(region); + d->mask = region; +} + +/*! + Returns the mask set on the window. + + The mask is a hint to the windowing system that the application does not + want to receive mouse or touch input outside the given region. +*/ +QRegion QWindow::mask() const +{ + Q_D(const QWindow); + return d->mask; +} + /*! Requests the window to be activated, i.e. receive keyboard focus. diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index 4b8f0ca3e7..0842e9ceb6 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -163,6 +163,9 @@ public: void setOpacity(qreal level); qreal opacity() const; + void setMask(const QRegion ®ion); + QRegion mask() const; + void requestActivate(); bool isActive() const; diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h index bcbface370..e92f37c34f 100644 --- a/src/gui/kernel/qwindow_p.h +++ b/src/gui/kernel/qwindow_p.h @@ -143,6 +143,7 @@ public: PositionPolicy positionPolicy; Qt::ScreenOrientation contentOrientation; qreal opacity; + QRegion mask; QSize minimumSize; QSize maximumSize; diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 02f8584f72..b67920737e 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -77,6 +77,7 @@ private slots: void tabletEvents(); void windowModality_QTBUG27039(); void visibility(); + void mask(); void initTestCase() { @@ -1119,6 +1120,22 @@ void tst_QWindow::visibility() spy.clear(); } +void tst_QWindow::mask() +{ + QRegion mask = QRect(10, 10, 800 - 20, 600 - 20); + + QWindow window; + window.resize(800, 600); + window.setMask(mask); + + QCOMPARE(window.mask(), QRegion()); + + window.create(); + window.setMask(mask); + + QCOMPARE(window.mask(), mask); +} + #include QTEST_MAIN(tst_QWindow) -- cgit v1.2.3