effects/overview: Allow blurring desktop background

This puts more emphasis on windows and less on desktop background.
This commit is contained in:
Vlad Zahorodnii 2021-10-20 09:43:10 +03:00
parent baf05ec4a5
commit c7c63ba269
5 changed files with 47 additions and 6 deletions

View file

@ -37,26 +37,33 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="1" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="KShortcutsEditor" name="shortcutsEditor" native="true"> <widget class="KShortcutsEditor" name="shortcutsEditor">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="actionTypes"> </widget>
<enum>KShortcutsEditor::GlobalAction</enum> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_BlurBackground">
<property name="text">
<string>Blur background:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QCheckBox" name="kcfg_BlurBackground"/>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>
<class>KShortcutsEditor</class> <class>KShortcutsEditor</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header location="global">KShortcutsEditor</header> <header>kshortcutseditor.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>

View file

@ -14,6 +14,10 @@
<default>1</default> <default>1</default>
</entry> </entry>
<entry name="BlurBackground" type="Bool">
<default>true</default>
</entry>
<entry name="BorderActivate" type="IntList" /> <entry name="BorderActivate" type="IntList" />
<entry name="TouchBorderActivate" type="IntList" /> <entry name="TouchBorderActivate" type="IntList" />
</group> </group>

View file

@ -106,6 +106,7 @@ void OverviewEffect::reconfigure(ReconfigureFlags)
OverviewConfig::self()->read(); OverviewConfig::self()->read();
setLayout(ExpoLayout::LayoutMode(OverviewConfig::layoutMode())); setLayout(ExpoLayout::LayoutMode(OverviewConfig::layoutMode()));
setAnimationDuration(animationTime(200)); setAnimationDuration(animationTime(200));
setBlurBackground(OverviewConfig::blurBackground());
for (const ElectricBorder &border : qAsConst(m_borderActivate)) { for (const ElectricBorder &border : qAsConst(m_borderActivate)) {
effects->unreserveElectricBorder(border, this); effects->unreserveElectricBorder(border, this);
@ -157,6 +158,19 @@ void OverviewEffect::setLayout(ExpoLayout::LayoutMode layout)
} }
} }
bool OverviewEffect::blurBackground() const
{
return m_blurBackground;
}
void OverviewEffect::setBlurBackground(bool blur)
{
if (m_blurBackground != blur) {
m_blurBackground = blur;
Q_EMIT blurBackgroundChanged();
}
}
void OverviewEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &data) void OverviewEffect::paintScreen(int mask, const QRegion &region, ScreenPaintData &data)
{ {
Q_UNUSED(mask) Q_UNUSED(mask)

View file

@ -40,6 +40,7 @@ class OverviewEffect : public Effect
Q_OBJECT Q_OBJECT
Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged) Q_PROPERTY(int animationDuration READ animationDuration NOTIFY animationDurationChanged)
Q_PROPERTY(ExpoLayout::LayoutMode layout READ layout NOTIFY layoutChanged) Q_PROPERTY(ExpoLayout::LayoutMode layout READ layout NOTIFY layoutChanged)
Q_PROPERTY(bool blurBackground READ blurBackground NOTIFY blurBackgroundChanged)
public: public:
OverviewEffect(); OverviewEffect();
@ -51,6 +52,9 @@ public:
int animationDuration() const; int animationDuration() const;
void setAnimationDuration(int duration); void setAnimationDuration(int duration);
bool blurBackground() const;
void setBlurBackground(bool blur);
void paintScreen(int mask, const QRegion &region, ScreenPaintData &data) override; void paintScreen(int mask, const QRegion &region, ScreenPaintData &data) override;
void postPaintScreen() override; void postPaintScreen() override;
bool isActive() const override; bool isActive() const override;
@ -66,6 +70,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
void animationDurationChanged(); void animationDurationChanged();
void layoutChanged(); void layoutChanged();
void blurBackgroundChanged();
public Q_SLOTS: public Q_SLOTS:
void activate(); void activate();
@ -88,6 +93,7 @@ private:
QList<QKeySequence> m_toggleShortcut; QList<QKeySequence> m_toggleShortcut;
QList<ElectricBorder> m_borderActivate; QList<ElectricBorder> m_borderActivate;
QList<ElectricBorder> m_touchBorderActivate; QList<ElectricBorder> m_touchBorderActivate;
bool m_blurBackground = false;
bool m_activated = false; bool m_activated = false;
int m_animationDuration = 200; int m_animationDuration = 200;
ExpoLayout::LayoutMode m_layout = ExpoLayout::LayoutNatural; ExpoLayout::LayoutMode m_layout = ExpoLayout::LayoutNatural;

View file

@ -5,6 +5,7 @@
*/ */
import QtQuick 2.12 import QtQuick 2.12
import QtGraphicalEffects 1.12
import org.kde.kwin 3.0 as KWinComponents import org.kde.kwin 3.0 as KWinComponents
import org.kde.kwin.private.overview 1.0 import org.kde.kwin.private.overview 1.0
import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.components 3.0 as PC3
@ -42,6 +43,15 @@ FocusScope {
y: model.client.y - targetScreen.geometry.y y: model.client.y - targetScreen.geometry.y
width: model.client.width width: model.client.width
height: model.client.height height: model.client.height
layer.enabled: effect.blurBackground
layer.effect: FastBlur {
radius: container.organized ? 64 : 0
Behavior on radius {
NumberAnimation { duration: effect.animationDuration; easing.type: Easing.OutCubic }
}
}
} }
} }