1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-25 19:21:41 +03:00

blur dock settings window properly

--the new approach is always using the background
mask of the window from the FrameSvgItem background
applied.

BUG:416177
FIXED-IN:0.9.8
This commit is contained in:
Michail Vourlakos 2020-01-12 21:56:46 +02:00
parent 9e78fab4ce
commit 16a04684df
6 changed files with 91 additions and 5 deletions

View File

@ -45,6 +45,7 @@
#include <KDeclarative/KDeclarative>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/surface.h>
#include <KWindowEffects>
#include <KWindowSystem>
// Plasma
@ -86,6 +87,12 @@ PrimaryConfigView::PrimaryConfigView(Plasma::Containment *containment, Latte::Vi
connect(this, &PrimaryConfigView::complexityChanged, this, &PrimaryConfigView::updateShowInlineProperties);
connect(this, &PrimaryConfigView::complexityChanged, this, &PrimaryConfigView::syncGeometry);
connect(this, &QQuickView::statusChanged, [&](QQuickView::Status status) {
if (status == QQuickView::Ready) {
updateEffects();
}
});
connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() {
setScreen(m_latteView->screen());
setFlags(wFlags());
@ -364,8 +371,6 @@ void PrimaryConfigView::showEvent(QShowEvent *ev)
setFlags(wFlags());
m_corona->wm()->setViewExtraFlags(this, false, Latte::Types::NormalWindow);
m_corona->wm()->enableBlurBehind(*this);
syncGeometry();
syncSlideEffect();
@ -692,6 +697,34 @@ void PrimaryConfigView::updateEnabledBorders()
}
//!END borders
void PrimaryConfigView::updateEffects()
{
//! Don't apply any effect before the wayland surface is created under wayland
//! https://bugs.kde.org/show_bug.cgi?id=392890
if (KWindowSystem::isPlatformWayland() && !m_shellSurface) {
return;
}
QRegion mask;
QQuickItem *rootObject = this->rootObject();
if (rootObject) {
const QVariant maskProperty = rootObject->property("backgroundMask");
if (static_cast<QMetaType::Type>(maskProperty.type()) == QMetaType::QRegion) {
qDebug() << "found 2...";
mask = maskProperty.value<QRegion>();
}
}
if (!mask.isEmpty()) {
setMask(mask);
KWindowEffects::enableBlurBehind(winId(), true, mask);
} else {
setMask(QRect());
KWindowEffects::enableBlurBehind(winId(), false);
}
}
//!BEGIN configuration
void PrimaryConfigView::loadConfig()
{

View File

@ -108,6 +108,7 @@ public slots:
Q_INVOKABLE void setSticker(bool blockFocusLost);
Q_INVOKABLE void syncGeometry();
Q_INVOKABLE void updateLaunchersForGroup(int groupInt);
Q_INVOKABLE void updateEffects();
signals:
void availableScreenGeometryChanged();

View File

@ -38,6 +38,7 @@
#include <KDeclarative/KDeclarative>
#include <KWayland/Client/plasmashell.h>
#include <KWayland/Client/surface.h>
#include <KWindowEffects>
#include <KWindowSystem>
// Plasma
@ -76,6 +77,12 @@ SecondaryConfigView::SecondaryConfigView(Latte::View *view, QWindow *parent)
m_screenSyncTimer.setSingleShot(true);
m_screenSyncTimer.setInterval(100);
connect(this, &QQuickView::statusChanged, [&](QQuickView::Status status) {
if (status == QQuickView::Ready) {
updateEffects();
}
});
connections << connect(m_parent, &PrimaryConfigView::availableScreenGeometryChanged, this, &SecondaryConfigView::syncGeometry);
connections << connect(&m_screenSyncTimer, &QTimer::timeout, this, [this]() {
@ -294,8 +301,6 @@ void SecondaryConfigView::showEvent(QShowEvent *ev)
setFlags(wFlags());
m_corona->wm()->setViewExtraFlags(this, false, Latte::Types::NormalWindow);
m_corona->wm()->enableBlurBehind(*this);
syncGeometry();
syncSlideEffect();
@ -393,6 +398,34 @@ void SecondaryConfigView::hideConfigWindow()
}
}
void SecondaryConfigView::updateEffects()
{
//! Don't apply any effect before the wayland surface is created under wayland
//! https://bugs.kde.org/show_bug.cgi?id=392890
if (KWindowSystem::isPlatformWayland() && !m_shellSurface) {
return;
}
QRegion mask;
QQuickItem *rootObject = this->rootObject();
if (rootObject) {
const QVariant maskProperty = rootObject->property("backgroundMask");
if (static_cast<QMetaType::Type>(maskProperty.type()) == QMetaType::QRegion) {
qDebug() << "found 2...";
mask = maskProperty.value<QRegion>();
}
}
if (!mask.isEmpty()) {
setMask(mask);
KWindowEffects::enableBlurBehind(winId(), true, mask);
} else {
setMask(QRect());
KWindowEffects::enableBlurBehind(winId(), false);
}
}
//!BEGIN borders
Plasma::FrameSvg::EnabledBorders SecondaryConfigView::enabledBorders() const
{

View File

@ -82,6 +82,7 @@ public:
public slots:
Q_INVOKABLE void hideConfigWindow();
Q_INVOKABLE void syncGeometry();
Q_INVOKABLE void updateEffects();
signals:
void enabledBordersChanged();

View File

@ -43,6 +43,8 @@ import "../controls" as LatteExtraControls
FocusScope {
id: dialog
property alias backgroundMask: backgroundFrameSvgItem.mask
readonly property bool basicLevel: viewConfig.complexity === Latte.Types.BasicSettings
readonly property bool advancedLevel: viewConfig.complexity === Latte.Types.AdvancedSettings
readonly property bool expertLevel: viewConfig.complexity === Latte.Types.ExpertSettings
@ -124,9 +126,16 @@ FocusScope {
}
PlasmaCore.FrameSvgItem{
id: backgroundFrameSvgItem
anchors.fill: parent
imagePath: "dialogs/background"
enabledBorders: viewConfig.enabledBorders
onEnabledBordersChanged: viewConfig.updateEffects()
onWidthChanged: viewConfig.updateEffects()
onHeightChanged: viewConfig.updateEffects()
Component.onCompleted: viewConfig.updateEffects()
}
MouseArea{

View File

@ -40,6 +40,8 @@ import "../controls" as LatteExtraControls
FocusScope {
id: dialog
property alias backgroundMask: backgroundFrameSvgItem.mask
width: typeSettings.width + units.smallSpacing * 4
height: typeSettings.height + units.smallSpacing * 4
Layout.minimumWidth: width
@ -50,9 +52,16 @@ FocusScope {
property bool panelIsVertical: plasmoid.formFactor === PlasmaCore.Types.Vertical
PlasmaCore.FrameSvgItem{
id: backgroundFrameSvgItem
anchors.fill: parent
imagePath: "dialogs/background"
enabledBorders: viewConfig.enabledBorders
onEnabledBordersChanged: viewConfig.updateEffects()
onWidthChanged: viewConfig.updateEffects()
onHeightChanged: viewConfig.updateEffects()
Component.onCompleted: viewConfig.updateEffects()
}