summarylogtreecommitdiffstats
path: root/mr1884.patch
blob: 1ebe2111a435e902c0055eb9819022faaf7688ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
Source: https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1884
Editor: Sung Mingi <FiestaLake@protonmail.com>
Commit: cac94861037a793a16e6ba2b174ff74837625406
Last Updated: 06/07/22 (gnome-shell 42.3.1-1)

diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index dd75a09ed..e02971024 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -202,6 +202,16 @@ var BaseAppView = GObject.registerClass({
         this._scrollView.connect('leave-event', this._onLeave.bind(this));
         this._scrollView.connect('button-press-event', this._onButtonPress.bind(this));
 
+        // Disable the the fade effect shader. IconGrid does its own fading
+        // that's much faster.
+        this._scrollView.update_fade_effect(
+            new Clutter.Margin({
+                left: 0.0,
+                right: 0.0,
+                top: 0.0,
+                bottom: 0.0,
+            }));
+
         this._scrollView.add_actor(this._grid);
 
         const scroll = this._scrollView.hscroll;
@@ -380,10 +390,12 @@ var BaseAppView = GObject.registerClass({
                 -(this._availWidth - this._grid.layout_manager.pageWidth) / 2);
         }
 
-        this._scrollView.update_fade_effect(fadeMargin);
-        const effect = this._scrollView.get_effect('fade');
-        if (effect)
-            effect.extend_fade_area = true;
+        this._updateFadeMargin(fadeMargin);
+    }
+
+    _updateFadeMargin(margin) {
+        const pagePos = this._adjustment.value / this._adjustment.page_size;
+        this._grid.updateFade(pagePos, margin);
     }
 
     _updateFade() {
@@ -411,7 +423,7 @@ var BaseAppView = GObject.registerClass({
                 return;
         }
 
-        this._scrollView.update_fade_effect(
+        this._updateFadeMargin(
             new Clutter.Margin({
                 left: hOffset,
                 right: hOffset,
@@ -2106,6 +2118,10 @@ class AppViewItem extends St.Button {
         this.fake_release();
     }
 
+    get dragging() {
+        return this._draggable && this._dragging;
+    }
+
     get id() {
         return this._id;
     }
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 599374fa3..826fb1246 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -1409,4 +1409,33 @@ var IconGrid = GObject.registerClass({
         const layoutManager = this.layout_manager;
         return layoutManager.rows_per_page * layoutManager.columns_per_page;
     }
+
+    updateFade(pagePosition, fadeMargin) {
+        const pageWidth = this.layout_manager.pageWidth;
+        const fadeOutLeftX = pagePosition * pageWidth + fadeMargin.left;
+        const fadeOutRightX = (pagePosition + 1) * pageWidth - fadeMargin.right;
+
+        let children = [];
+        for (let p = 0; p < this.nPages; p++) {
+            children = children.concat(
+                this.getItemsAtPage(p).filter(c => c.visible && !c.dragging)
+            );
+        }
+
+        children.forEach(child => {
+            const childWidth = child.width;
+            const childLeft = child.x;
+            const childRight = childLeft + childWidth;
+
+            let progress = 0.0;
+
+            if (childLeft < fadeOutLeftX && fadeMargin.left > 0)
+                progress = (fadeOutLeftX - childLeft) / childWidth;
+            else if (childRight > fadeOutRightX && fadeMargin.right > 0)
+                progress = (childRight - fadeOutRightX) / childWidth;
+
+            progress = Math.clamp(progress, 0.0, 1.0);
+            child.set_opacity((1.0 - progress) * 255.0);
+        });
+    }
 });