diff options
-rw-r--r-- | src/imports/winextras/qquickdwmfeatures.cpp | 98 | ||||
-rw-r--r-- | src/imports/winextras/qquickdwmfeatures_p.h | 4 | ||||
-rw-r--r-- | src/imports/winextras/qquickdwmfeatures_p_p.h | 7 | ||||
-rw-r--r-- | tests/manual/dwmfeatures/dwmfeatures.qml | 149 | ||||
-rw-r--r-- | tests/manual/dwmfeatures/dwmfeatures.qmlproject | 16 |
5 files changed, 246 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) }; diff --git a/tests/manual/dwmfeatures/dwmfeatures.qml b/tests/manual/dwmfeatures/dwmfeatures.qml new file mode 100644 index 0000000..2e805d7 --- /dev/null +++ b/tests/manual/dwmfeatures/dwmfeatures.qml @@ -0,0 +1,149 @@ +/**************************************************************************** + ** + ** Copyright (C) 2013 Ivan Vizir <define-true-false@yandex.com> + ** Contact: http://www.qt-project.org/legal + ** + ** This file is part of the QtWinExtras module of the Qt Toolkit. + ** + ** $QT_BEGIN_LICENSE:LGPL$ + ** Commercial License Usage + ** Licensees holding valid commercial Qt licenses may use this file in + ** accordance with the commercial license agreement provided with the + ** Software or, alternatively, in accordance with the terms contained in + ** a written agreement between you and Digia. For licensing terms and + ** conditions see http://qt.digia.com/licensing. For further information + ** use the contact form at http://qt.digia.com/contact-us. + ** + ** GNU Lesser General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU Lesser + ** General Public License version 2.1 as published by the Free Software + ** Foundation and appearing in the file LICENSE.LGPL included in the + ** packaging of this file. Please review the following information to + ** ensure the GNU Lesser General Public License version 2.1 requirements + ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. + ** + ** In addition, as a special exception, Digia gives you certain additional + ** rights. These rights are described in the Digia Qt LGPL Exception + ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. + ** + ** GNU General Public License Usage + ** Alternatively, this file may be used under the terms of the GNU + ** General Public License version 3.0 as published by the Free Software + ** Foundation and appearing in the file LICENSE.GPL included in the + ** packaging of this file. Please review the following information to + ** ensure the GNU General Public License version 3.0 requirements will be + ** met: http://www.gnu.org/copyleft/gpl.html. + ** + ** + ** $QT_END_LICENSE$ + ** + ****************************************************************************/ + +import QtQuick 2.0 +import QtQuick.Controls 1.0 +import QtQuick.Window 2.0 +import QtQuick.Layouts 1.0 +import QtWinExtras 1.0 +import QtGraphicalEffects 1.0 + +Window { + title: "DWM Features QtWinExtras manual test" + width: 350 + height: 261 + + DwmFeatures { + id: dwm + leftGlassMargin: sboxLeft.value + rightGlassMargin: sboxRight.value + topGlassMargin: sboxTop.value + bottomGlassMargin: sboxBottom.value + blurBehindEnabled: cbBlurBehind.checked + + excludedFromPeek: cbExcludedFromPeek.checked + peekDisallowed: cbPeekDisallowed.checked + + Component.onCompleted: { + cbCompositionEnabled.checked = compositionEnabled + compositionEnabled = Qt.binding(function () { return cbCompositionEnabled.checked }) + } + } + + Rectangle { + anchors.fill: parent + anchors.leftMargin: dwm.compositionEnabled ? dwm.leftGlassMargin : 0 + anchors.rightMargin: dwm.compositionEnabled ? dwm.rightGlassMargin : 0 + anchors.topMargin: dwm.compositionEnabled ? dwm.topGlassMargin : 0 + anchors.bottomMargin: dwm.compositionEnabled ? dwm.bottomGlassMargin : 0 + + visible: !dwm.compositionEnabled || dwm.topGlassMargin > -1 && dwm.leftGlassMargin > -1 && dwm.rightGlassMargin > -1 && dwm.bottomGlassMargin > -1 && !cbBlurBehind.checked + } + + GridLayout { + anchors.fill: parent + anchors.margins: 2 + columns: 2 + + CheckBox { + id: cbCompositionEnabled + text: "Composition enabled" + Layout.columnSpan: 2 + } + + CheckBox { + id: cbBlurBehind + text: "Blur behind enabled" + Layout.columnSpan: 2 + enabled: cbCompositionEnabled.checked + } + + Label { text: "Top glass frame margin" } + SpinBox { id: sboxTop; minimumValue: -1; maximumValue: 40; value: 0; Layout.alignment: Qt.AlignRight; enabled: cbCompositionEnabled.checked } + Label { text: "Right glass frame margin" } + SpinBox { id: sboxRight; minimumValue: -1; maximumValue: 40; value: 0; Layout.alignment: Qt.AlignRight; enabled: cbCompositionEnabled.checked } + Label { text: "Bottom glass frame margin" } + SpinBox { id: sboxBottom; minimumValue: -1; maximumValue: 40; value: 0; Layout.alignment: Qt.AlignRight; enabled: cbCompositionEnabled.checked } + Label { text: "Left glass frame margin" } + SpinBox { id: sboxLeft; minimumValue: -1; maximumValue: 40; value: 0; Layout.alignment: Qt.AlignRight; enabled: cbCompositionEnabled.checked } + + CheckBox { + id: cbExcludedFromPeek + text: "Excluded from peek" + Layout.columnSpan: 2 + enabled: cbCompositionEnabled.checked + } + + CheckBox { + id: cbPeekDisallowed + text: "Peek disallowed" + Layout.columnSpan: 2 + enabled: cbCompositionEnabled.checked + } + + Rectangle { + id: rcColorization + width: parent.width + height: 32 + color: dwm.realColorizationColor + Layout.fillWidth: true + Layout.columnSpan: 2 + border.width: 4 + border.color: ''+dwm.realColorizationColor + + Label { text: "Real colorization color"; anchors.centerIn: parent} + } + + Rectangle { + width: parent.width + height: 32 + color: dwm.colorizationColor + Layout.fillWidth: true + Layout.columnSpan: 2 + border.width: 4 + border.color: ''+dwm.colorizationColor + + Label { text: "API-given colorization color (blended)"; anchors.centerIn: parent} + } + + Item { Layout.fillHeight: true } + } +} diff --git a/tests/manual/dwmfeatures/dwmfeatures.qmlproject b/tests/manual/dwmfeatures/dwmfeatures.qmlproject new file mode 100644 index 0000000..0f7c6e1 --- /dev/null +++ b/tests/manual/dwmfeatures/dwmfeatures.qmlproject @@ -0,0 +1,16 @@ +import QmlProject 1.1 + +Project { + mainFile: "dwmfeatures.qml" + + /* Include .qml, .js, and image files from current directory and subdirectories */ + QmlFiles { + directory: "." + } + JavaScriptFiles { + directory: "." + } + ImageFiles { + directory: "." + } +} |