on xenial help sign in
Re-introduce interactive drawer blur (#421)

* src: interactiveBlur property Allow to set a new 'interactiveBlur' based on a new Android property, called 'ubuntu.unity8.interactive_blur'. This should be used to indicate the ability to draw interactive blur in the drawer quickly without causing too many dropped frames. * qml: Re-introduce interactive Drawer blur on capable devices On device ports which set the necessary getprop property, allow the use of interactive blur in the drawer. Use static blur otherwise. * src: Fix FTBFS in ApplicationArguments The object member is called differently, so fix it.

commit441abf2b529762a07df9b99e7c80f5784fe163bf authorAlfred E. Neumayer <dev.beidl@gmail.com> dateWed 19 Jan 2022, 20:59 (5 years ago) parentd1fffd2
7 files changed+121−2
qml/Launcher/BackgroundBlur.qml+81 qml/Launcher/Drawer.qml+8−2 qml/Launcher/Launcher.qml+17 qml/OrientedShell.qml+1 qml/Shell.qml+3 src/ApplicationArguments.h+5 src/ShellApplication.cpp+6
qml/Launcher/BackgroundBlur.qmlnew file+81
@@ -0,0 +1,81 @@
1+/*
2+ * Copyright (C) 2016 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+import QtQuick 2.4
18+import Ubuntu.Components 1.3
19+import QtGraphicalEffects 1.0
20+
21+Item {
22+ id: root
23+
24+ property int blurAmount: 32
25+ property Item sourceItem
26+ property rect blurRect: Qt.rect(0,0,0,0)
27+ property alias cached: fastBlur.cached
28+
29+ Rectangle {
30+ id: blurMask
31+ color: "yellow"
32+ x: blurRect.x
33+ y: blurRect.y
34+ width: blurRect.width
35+ height: blurRect.height
36+ }
37+
38+ ShaderEffect {
39+ id: maskedBlurEffect
40+ x: blurRect.x
41+ y: blurRect.y
42+ width: blurRect.width
43+ height: blurRect.height
44+
45+ property variant source: ShaderEffectSource {
46+ id: shaderEffectSource
47+ sourceItem: root.sourceItem
48+ hideSource: false
49+ sourceRect: root.blurRect
50+ }
51+
52+ property var mask: ShaderEffectSource {
53+ sourceItem: blurMask
54+ hideSource: true
55+ }
56+
57+ fragmentShader: "
58+ varying highp vec2 qt_TexCoord0;
59+ uniform sampler2D source;
60+ uniform sampler2D mask;
61+ void main(void)
62+ {
63+ highp vec4 sourceColor = texture2D(source, qt_TexCoord0);
64+ highp vec4 maskColor = texture2D(mask, qt_TexCoord0);
65+
66+ sourceColor *= maskColor.a;
67+
68+ gl_FragColor = sourceColor;
69+ }"
70+ }
71+
72+ FastBlur {
73+ id: fastBlur
74+ x: blurRect.x
75+ y: blurRect.y
76+ width: blurRect.width
77+ height: blurRect.height
78+ source: maskedBlurEffect
79+ radius: Math.min(blurAmount, 128)
80+ }
81+ }
qml/Launcher/Drawer.qml+8−2
@@ -34,6 +34,7 @@ FocusScope {
3434 readonly property real delegateWidth: units.gu(10)
3535 property url background
3636 property alias backgroundSourceSize: background.sourceSize
37+ property bool staticBlurEnabled : true
3738 visible: x > -width
3839 property var fullyOpen: x === 0
3940 property var fullyClosed: x === -width
@@ -155,18 +156,21 @@ FocusScope {
155156
156157 Rectangle {
157158 anchors.fill: parent
158− color: "#111111"
159− opacity: 0.99
159+ color: "#BF000000"
160160
161161 Wallpaper {
162162 id: background
163163 objectName: "drawerBackground"
164+ visible: staticBlurEnabled
165+ enabled: staticBlurEnabled
164166 anchors.fill: parent
165167 source: root.background
166168 }
167169
168170 FastBlur {
169171 anchors.fill: background
172+ visible: staticBlurEnabled
173+ enabled: staticBlurEnabled
170174 source: background
171175 radius: 64
172176 cached: true
@@ -175,6 +179,8 @@ FocusScope {
175179 // Images with fastblur can't use opacity, so we'll put this on top
176180 Rectangle {
177181 anchors.fill: background
182+ visible: staticBlurEnabled
183+ enabled: staticBlurEnabled
178184 color: parent.color
179185 opacity: 0.67
180186 }
qml/Launcher/Launcher.qml+17
@@ -31,6 +31,8 @@ FocusScope {
3131 property bool lockedVisible: false
3232 property bool available: true // can be used to disable all interactions
3333 property alias inverted: panel.inverted
34+ property Item blurSource: null
35+ property bool interactiveBlur: false
3436 property int topPanelHeight: 0
3537 property bool drawerEnabled: true
3638 property alias privateMode: panel.privateMode
@@ -364,6 +366,20 @@ FocusScope {
364366 }
365367 }
366368
369+ BackgroundBlur {
370+ id: backgroundBlur
371+ anchors.fill: parent
372+ anchors.topMargin: root.inverted ? 0 : -root.topPanelHeight
373+ visible: root.interactiveBlur && root.blurSource && drawer.x > -drawer.width
374+ blurAmount: units.gu(6)
375+ sourceItem: root.blurSource
376+ blurRect: Qt.rect(panel.width,
377+ root.topPanelHeight,
378+ drawer.width + drawer.x - panel.width,
379+ height - root.topPanelHeight)
380+ cached: drawer.moving
381+ }
382+
367383 Drawer {
368384 id: drawer
369385 objectName: "drawer"
@@ -377,6 +393,7 @@ FocusScope {
377393 width: Math.min(root.width, units.gu(81))
378394 panelWidth: panel.width
379395 allowSlidingAnimation: !dragArea.dragging && !launcherDragArea.drag.active && panel.animate
396+ staticBlurEnabled: !root.interactiveBlur
380397
381398 onApplicationSelected: {
382399 root.launcherApplicationSelected(appId)
qml/OrientedShell.qml+1
@@ -273,6 +273,7 @@ Item {
273273 nativeWidth: root.width
274274 nativeHeight: root.height
275275 mode: applicationArguments.mode
276+ interactiveBlur: applicationArguments.interactiveBlur
276277 hasMouse: pointerInputDevices > 0
277278 hasKeyboard: keyboardsModel.count > 0
278279 hasTouchscreen: touchScreensModel.count > 0
qml/Shell.qml+3
@@ -59,6 +59,7 @@ StyledItem {
5959 property alias panelAreaShowProgress: panel.panelAreaShowProgress
6060 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
6161 property string mode: "full-greeter"
62+ property bool interactiveBlur: false
6263 property alias oskEnabled: inputMethod.enabled
6364 function updateFocusedAppOrientation() {
6465 stage.updateFocusedAppOrientation();
@@ -604,6 +605,8 @@ StyledItem {
604605 superTabPressed: physicalKeysMapper.superTabPressed
605606 panelWidth: units.gu(settings.launcherWidth)
606607 lockedVisible: (lockedByUser || shell.atDesktop) && lockAllowed
608+ blurSource: greeter.shown ? greeter : stages
609+ interactiveBlur: shell.interactiveBlur
607610 topPanelHeight: panel.panelHeight
608611 drawerEnabled: !greeter.active && tutorial.launcherLongSwipeEnabled
609612 privateMode: greeter.active
src/ApplicationArguments.h+5
@@ -28,6 +28,7 @@ class ApplicationArguments : public QObject
2828 Q_OBJECT
2929 Q_PROPERTY(QString deviceName READ deviceName NOTIFY deviceNameChanged)
3030 Q_PROPERTY(QString mode READ mode CONSTANT)
31+ Q_PROPERTY(bool interactiveBlur READ interactiveBlur CONSTANT)
3132public:
3233 ApplicationArguments(QObject *parent = nullptr);
3334
@@ -42,12 +43,16 @@ public:
4243 void setMode(const QString &mode) { m_mode = mode; }
4344 QString mode() const { return m_mode; }
4445
46+ void setInteractiveBlur(const bool &value) { m_interactiveBlur = value; }
47+ bool interactiveBlur() { return m_interactiveBlur; }
48+
4549Q_SIGNALS:
4650 void deviceNameChanged(const QString&);
4751
4852private:
4953 QString m_deviceName;
5054 QString m_mode;
55+ bool m_interactiveBlur;
5156};
5257
5358#endif // APPLICATION_ARGUMENTS_H
src/ShellApplication.cpp+6
@@ -58,6 +58,12 @@ ShellApplication::ShellApplication(int & argc, char ** argv, bool isMirServer)
5858
5959 m_qmlArgs.setMode(parser.mode());
6060
61+ {
62+ char buffer[200];
63+ property_get("ubuntu.unity8.interactive_blur", buffer, "false");
64+ m_qmlArgs.setInteractiveBlur(QString(buffer) == QStringLiteral("true"));
65+ }
66+
6167 // The testability driver is only loaded by QApplication but not by QGuiApplication.
6268 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
6369 if (parser.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {