aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorIvan Vizir <define-true-false@yandex.com>2013-10-02 22:46:47 +0300
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-07 12:02:15 +0200
commit118a4f143b9125f02a11d2c579cced4e37fb9d70 (patch)
tree712991e30f97508b6a39572b89a60539f0de3dd9 /src/imports
parenta8699963b98fe2d1dcc33658ac006100b69444b1 (diff)
Fix and change the way QQuickDwmFeatures works.
Made it update each DWM property separately but not all at once every time a property changes. Added manual test for DwmFeatures QML item. Added blurBehindEnabled property. Change-Id: Icfa6fb922be0ac4554c232ba4b41b71d0e7585ca Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/winextras/qquickdwmfeatures.cpp98
-rw-r--r--src/imports/winextras/qquickdwmfeatures_p.h4
-rw-r--r--src/imports/winextras/qquickdwmfeatures_p_p.h7
3 files changed, 81 insertions, 28 deletions
diff --git a/src/imports/winextras/qquickdwmfeatures.cpp b/src/imports/winextras/qquickdwmfeatures.cpp
index 0723d96..18f8216 100644
--- a/src/imports/winextras/qquickdwmfeatures.cpp
+++ b/src/imports/winextras/qquickdwmfeatures.cpp
@@ -116,7 +116,8 @@ void QQuickDwmFeatures::setTopGlassMargin(int margin)
return;
d->topMargin = margin;
- d->update();
+ if (window())
+ QtWin::extendFrameIntoClientArea(window(), d->leftMargin, d->topMargin, d->rightMargin, d->bottomMargin);
emit topGlassMarginChanged();
}
@@ -132,7 +133,8 @@ void QQuickDwmFeatures::setRightGlassMargin(int margin)
return;
d->rightMargin = margin;
- d->update();
+ if (window())
+ QtWin::extendFrameIntoClientArea(window(), d->leftMargin, d->topMargin, d->rightMargin, d->bottomMargin);
emit rightGlassMarginChanged();
}
@@ -148,8 +150,9 @@ void QQuickDwmFeatures::setBottomGlassMargin(int margin)
return;
d->bottomMargin = margin;
- d->update();
- emit rightGlassMarginChanged();
+ if (window())
+ QtWin::extendFrameIntoClientArea(window(), d->leftMargin, d->topMargin, d->rightMargin, d->bottomMargin);
+ emit bottomGlassMarginChanged();
}
/*!
@@ -164,7 +167,8 @@ void QQuickDwmFeatures::setLeftGlassMargin(int margin)
return;
d->leftMargin = margin;
- d->update();
+ if (window())
+ QtWin::extendFrameIntoClientArea(window(), d->leftMargin, d->topMargin, d->rightMargin, d->bottomMargin);
emit leftGlassMarginChanged();
}
@@ -193,6 +197,33 @@ int QQuickDwmFeatures::leftGlassMargin() const
}
/*!
+ \qmlproperty bool DwmFeatures::blurBehindEnabled
+
+ Specifies whether the blur behind the window client area is enabled.
+ */
+bool QQuickDwmFeatures::isBlurBehindEnabled() const
+{
+ Q_D(const QQuickDwmFeatures);
+ return d->blurBehindEnabled;
+}
+
+void QQuickDwmFeatures::setBlurBehindEnabled(bool enabled)
+{
+ Q_D(QQuickDwmFeatures);
+ if (d->blurBehindEnabled == enabled)
+ return;
+
+ d->blurBehindEnabled = enabled;
+ if (window()) {
+ if (d->blurBehindEnabled)
+ QtWin::enableBlurBehindWindow(window());
+ else
+ QtWin::disableBlurBehindWindow(window());
+ }
+ emit blurBehindEnabledChanged();
+}
+
+/*!
\qmlproperty bool DwmFeatures::excludedFromPeek
Specifies whether the window is excluded from Aero Peek.
@@ -214,7 +245,8 @@ void QQuickDwmFeatures::setExcludedFromPeek(bool exclude)
return;
d->peekExcluded = exclude;
- d->update();
+ if (window())
+ QtWin::setWindowExcludedFromPeek(window(), d->peekExcluded);
emit excludedFromPeekChanged();
}
@@ -240,7 +272,8 @@ void QQuickDwmFeatures::setPeekDisallowed(bool disallow)
return;
d->peekDisallowed = disallow;
- d->update();
+ if (window())
+ QtWin::setWindowDisallowPeek(window(), d->peekDisallowed);
emit peekDisallowedChanged();
}
@@ -265,14 +298,19 @@ void QQuickDwmFeatures::setFlip3DPolicy(QQuickWin::WindowFlip3DPolicy policy)
return;
d->flipPolicy = policy;
- d->update();
+ if (window())
+ QtWin::setWindowFlip3DPolicy(window(), static_cast<QtWin::WindowFlip3DPolicy>(d->flipPolicy));
emit flip3DPolicyChanged();
}
bool QQuickDwmFeatures::eventFilter(QObject *object, QEvent *event)
{
+ Q_D(QQuickDwmFeatures);
if (object == window()) {
if (event->type() == QWinEvent::CompositionChange) {
+ d->updateSurfaceFormat();
+ if (static_cast<QWinCompositionChangeEvent *>(event)->isCompositionEnabled())
+ d->updateAll();
emit compositionEnabledChanged();
} else if (event->type() == QWinEvent::ColorizationChange) {
emit colorizationColorChanged();
@@ -298,8 +336,9 @@ void QQuickDwmFeatures::itemChange(QQuickItem::ItemChange change, const QQuickIt
{
Q_D(QQuickDwmFeatures);
if (change == ItemSceneChange && data.window) {
- d->update();
+ d->updateAll();
data.window->installEventFilter(this);
+ d->originalSurfaceColor = data.window->color();
}
QQuickItem::itemChange(change, data);
}
@@ -308,31 +347,38 @@ void QQuickDwmFeatures::itemChange(QQuickItem::ItemChange change, const QQuickIt
QQuickDwmFeaturesPrivate::QQuickDwmFeaturesPrivate(QQuickDwmFeatures *parent) :
topMargin(0), rightMargin(0), bottomMargin(0), leftMargin(0),
+ blurBehindEnabled(false),
peekDisallowed(false), peekExcluded(false), flipPolicy(QQuickWin::FlipDefault),
- q_ptr(parent), formatSet(false)
+ q_ptr(parent)
{
}
-void QQuickDwmFeaturesPrivate::update()
+void QQuickDwmFeaturesPrivate::updateAll()
{
Q_Q(QQuickDwmFeatures);
QWindow *w = q->window();
if (w) {
- if (!formatSet) {
- formatSet = true;
- QSurfaceFormat format = w->format();
- format.setAlphaBufferSize(8);
- w->setFormat(format);
- q->window()->setColor(Qt::transparent);
- }
- if (peekExcluded)
- QtWin::setWindowExcludedFromPeek(w, peekExcluded);
- if (peekDisallowed)
- QtWin::setWindowDisallowPeek(w, peekDisallowed);
- if (flipPolicy != QQuickWin::FlipDefault)
- QtWin::setWindowFlip3DPolicy(w, static_cast<QtWin::WindowFlip3DPolicy>(flipPolicy));
- if (topMargin || rightMargin || bottomMargin || leftMargin)
- QtWin::extendFrameIntoClientArea(w, leftMargin, topMargin, rightMargin, bottomMargin);
+ updateSurfaceFormat();
+ QtWin::setWindowExcludedFromPeek(w, peekExcluded);
+ QtWin::setWindowDisallowPeek(w, peekDisallowed);
+ QtWin::setWindowFlip3DPolicy(w, static_cast<QtWin::WindowFlip3DPolicy>(flipPolicy));
+ if (blurBehindEnabled)
+ QtWin::enableBlurBehindWindow(w);
+ else
+ QtWin::disableBlurBehindWindow(w);
+ QtWin::extendFrameIntoClientArea(w, leftMargin, topMargin, rightMargin, bottomMargin);
+ }
+}
+
+void QQuickDwmFeaturesPrivate::updateSurfaceFormat()
+{
+ Q_Q(QQuickDwmFeatures);
+ if (q->window()) {
+ const bool compositionEnabled = q->isCompositionEnabled();
+ QSurfaceFormat format = q->window()->format();
+ format.setAlphaBufferSize(compositionEnabled ? 8 : 0);
+ q->window()->setFormat(format);
+ q->window()->setColor(compositionEnabled ? QColor(Qt::transparent) : originalSurfaceColor);
}
}
diff --git a/src/imports/winextras/qquickdwmfeatures_p.h b/src/imports/winextras/qquickdwmfeatures_p.h
index 5c8db12..0d61f64 100644
--- a/src/imports/winextras/qquickdwmfeatures_p.h
+++ b/src/imports/winextras/qquickdwmfeatures_p.h
@@ -63,6 +63,7 @@ class QQuickDwmFeatures : public QQuickItem
Q_PROPERTY(int rightGlassMargin READ rightGlassMargin WRITE setRightGlassMargin NOTIFY rightGlassMarginChanged)
Q_PROPERTY(int bottomGlassMargin READ bottomGlassMargin WRITE setBottomGlassMargin NOTIFY bottomGlassMarginChanged)
Q_PROPERTY(int leftGlassMargin READ leftGlassMargin WRITE setLeftGlassMargin NOTIFY leftGlassMarginChanged)
+ Q_PROPERTY(bool blurBehindEnabled READ isBlurBehindEnabled WRITE setBlurBehindEnabled NOTIFY blurBehindEnabledChanged)
Q_PROPERTY(bool excludedFromPeek READ isExcludedFromPeek WRITE setExcludedFromPeek NOTIFY excludedFromPeekChanged)
Q_PROPERTY(bool peekDisallowed READ isPeekDisallowed WRITE setPeekDisallowed NOTIFY peekDisallowedChanged)
Q_PROPERTY(QQuickWin::WindowFlip3DPolicy flip3DPolicy READ flip3DPolicy WRITE setFlip3DPolicy NOTIFY flip3DPolicyChanged)
@@ -85,6 +86,8 @@ public:
int rightGlassMargin() const;
int bottomGlassMargin() const;
int leftGlassMargin() const;
+ bool isBlurBehindEnabled() const;
+ void setBlurBehindEnabled(bool enabled);
bool isExcludedFromPeek() const;
void setExcludedFromPeek(bool exclude);
@@ -106,6 +109,7 @@ Q_SIGNALS:
void rightGlassMarginChanged();
void bottomGlassMarginChanged();
void leftGlassMarginChanged();
+ void blurBehindEnabledChanged();
void excludedFromPeekChanged();
void peekDisallowedChanged();
void flip3DPolicyChanged();
diff --git a/src/imports/winextras/qquickdwmfeatures_p_p.h b/src/imports/winextras/qquickdwmfeatures_p_p.h
index 747ea5e..7dbec7f 100644
--- a/src/imports/winextras/qquickdwmfeatures_p_p.h
+++ b/src/imports/winextras/qquickdwmfeatures_p_p.h
@@ -51,20 +51,23 @@ class QQuickDwmFeaturesPrivate
{
public:
QQuickDwmFeaturesPrivate(QQuickDwmFeatures *parent);
+
int topMargin;
int rightMargin;
int bottomMargin;
int leftMargin;
+ bool blurBehindEnabled;
bool peekDisallowed;
bool peekExcluded;
QQuickWin::WindowFlip3DPolicy flipPolicy;
+ QColor originalSurfaceColor;
- void update();
+ void updateAll();
+ void updateSurfaceFormat();
private:
QQuickDwmFeatures *q_ptr;
- bool formatSet;
Q_DECLARE_PUBLIC(QQuickDwmFeatures)
};