[gnome-shell/wip/jimmac/dash-icon-spacing: 35/72] workspacesView: Add primary view to workspaces display




commit 42dd6095533feedbe7028ed334ef1152a614fb42
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Jun 26 18:38:28 2020 +0200

    workspacesView: Add primary view to workspaces display
    
    Boy, does this commit feel good.
    
    While the workspaces view on the primary monitor *appears* as part of
    the overall overview hierarchy, this hasn't actually been the case
    until now. We synchronized its size and (stage) position to match
    the workspaces display, but actually kept in a separate layer for
    the transitions to and from the overview.
    
    But now that the new layout manager slides out completely during the
    overview transitions, the workspaces display starts out covering the
    entire work area, which is exactly what we need for the transition.
    
    So finally stop faking it, and actually make the primary workspaces
    view a child of the workspaces display.

 js/ui/overview.js       |  1 -
 js/ui/workspacesView.js | 79 ++++++++++++++-----------------------------------
 2 files changed, 22 insertions(+), 58 deletions(-)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 2cb5110324..c232d6fb95 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -238,7 +238,6 @@ var Overview = class {
         this._overview = new OverviewActor();
         this._overview._delegate = this;
         Main.layoutManager.overviewGroup.add_child(this._overview);
-        this._overview.connect('notify::allocation', () => this.emit('relayout'));
 
         this._shellInfo = new ShellInfo();
 
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 9ac7e3d08a..fa8decd0a7 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -23,12 +23,11 @@ var WorkspacesViewBase = GObject.registerClass({
     GTypeFlags: GObject.TypeFlags.ABSTRACT,
 }, class WorkspacesViewBase extends St.Widget {
     _init(monitorIndex) {
-        const { x, y, width, height } =
-            Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
-
         super._init({
             style_class: 'workspaces-view',
-            x, y, width, height,
+            clip_to_allocation: true,
+            x_expand: true,
+            y_expand: true,
         });
         this.connect('destroy', this._onDestroy.bind(this));
         global.focus_manager.add_group(this);
@@ -67,6 +66,14 @@ var WorkspacesViewBase = GObject.registerClass({
         for (const child of this)
             child.allocate_available_size(0, 0, box.get_width(), box.get_height());
     }
+
+    vfunc_get_preferred_width() {
+        return [0, 0];
+    }
+
+    vfunc_get_preferred_height() {
+        return [0, 0];
+    }
 });
 
 var WorkspacesView = GObject.registerClass(
@@ -460,8 +467,8 @@ class WorkspacesDisplay extends St.Widget {
             visible: false,
             y_expand: true,
             clip_to_allocation: true,
+            layout_manager: new Clutter.BinLayout(),
         });
-        this.connect('notify::allocation', this._updateWorkspacesActualGeometry.bind(this));
 
         this._snapAdjustment = new St.Adjustment({
             actor: this,
@@ -470,9 +477,6 @@ class WorkspacesDisplay extends St.Widget {
             upper: Clutter.Orientation.VERTICAL,
         });
 
-        Main.overview.connect('relayout',
-            () => this._updateWorkspacesActualGeometry());
-
         let workspaceManager = global.workspace_manager;
         this._scrollAdjustment = scrollAdjustment;
 
@@ -511,9 +515,6 @@ class WorkspacesDisplay extends St.Widget {
         this._windowDragEndId =
             Main.overview.connect('window-drag-end',
                 this._windowDragEnd.bind(this));
-        this._overviewShownId = Main.overview.connect('shown', () => {
-            this._syncWorkspacesActualGeometry();
-        });
 
         this._primaryVisible = true;
         this._primaryIndex = Main.layoutManager.primaryIndex;
@@ -529,9 +530,7 @@ class WorkspacesDisplay extends St.Widget {
         this._scrollEventId = 0;
         this._keyPressEventId = 0;
         this._scrollTimeoutId = 0;
-        this._syncActualGeometryLater = 0;
 
-        this._actualGeometry = null;
         this._inWindowDrag = false;
         this._leavingOverview = false;
 
@@ -554,11 +553,6 @@ class WorkspacesDisplay extends St.Widget {
             this._parentSetLater = 0;
         }
 
-        if (this._syncActualGeometryLater) {
-            Meta.later_remove(this._syncActualGeometryLater);
-            this._syncActualGeometryLater = 0;
-        }
-
         if (this._scrollTimeoutId !== 0) {
             GLib.source_remove(this._scrollTimeoutId);
             this._scrollTimeoutId = 0;
@@ -568,7 +562,6 @@ class WorkspacesDisplay extends St.Widget {
         global.workspace_manager.disconnect(this._reorderWorkspacesdId);
         Main.overview.disconnect(this._windowDragBeginId);
         Main.overview.disconnect(this._windowDragEndId);
-        Main.overview.disconnect(this._overviewShownId);
     }
 
     _windowDragBegin() {
@@ -719,9 +712,6 @@ class WorkspacesDisplay extends St.Widget {
         for (let i = 0; i < this._workspacesViews.length; i++)
             this._workspacesViews[i].animateToOverview();
 
-        if (this._actualGeometry)
-            this._syncWorkspacesActualGeometry();
-
         this._restackedNotifyId =
             Main.overview.connect('windows-restacked',
                                   this._onRestacked.bind(this));
@@ -769,7 +759,6 @@ class WorkspacesDisplay extends St.Widget {
             return;
 
         this._updateWorkspacesViews();
-        this._syncWorkspacesActualGeometry();
     }
 
     _updateWorkspacesViews() {
@@ -787,10 +776,17 @@ class WorkspacesDisplay extends St.Widget {
                 view = new WorkspacesView(i, this._scrollAdjustment, this._snapAdjustment);
 
             this._workspacesViews.push(view);
-            Main.layoutManager.overviewGroup.add_actor(view);
-        }
 
-        this._workspacesViews[this._primaryIndex].visible = this._primaryVisible;
+            if (i === this._primaryIndex) {
+                view.visible = this._primaryVisible;
+                this.add_child(view);
+            } else {
+                const { x, y, width, height } =
+                    Main.layoutManager.getWorkAreaForMonitor(i);
+                view.set({ x, y, width, height });
+                Main.layoutManager.overviewGroup.add_actor(view);
+            }
+        }
     }
 
     _getMonitorIndexForEvent(event) {
@@ -837,37 +833,6 @@ class WorkspacesDisplay extends St.Widget {
         });
     }
 
-    _updateWorkspacesActualGeometry() {
-        const [x, y] = this.get_transformed_position();
-        const width = this.allocation.get_width();
-        const height = this.allocation.get_height();
-
-        this._actualGeometry = { x, y, width, height };
-
-        if (this._syncActualGeometryLater > 0)
-            return;
-
-        this._syncActualGeometryLater =
-            Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
-                this._syncWorkspacesActualGeometry();
-
-                this._syncActualGeometryLater = 0;
-                return GLib.SOURCE_REMOVE;
-            });
-    }
-
-    _syncWorkspacesActualGeometry() {
-        const primaryView = this._getPrimaryView();
-        if (!primaryView)
-            return;
-
-        primaryView.ease({
-            ...this._actualGeometry,
-            duration: Main.overview.animationInProgress ? ANIMATION_TIME : 0,
-            mode: Clutter.AnimationMode.EASE_OUT_QUAD,
-        });
-    }
-
     _onRestacked(overview, stackIndices) {
         for (let i = 0; i < this._workspacesViews.length; i++)
             this._workspacesViews[i].syncStacking(stackIndices);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]