[gnome-shell/wip/exalm/gestures2: 12/13] workspaceAnimation: Group sticky windows and moving window



commit 21b4b0f8a60ddd9109ea7c8a6b40fb254c2ca519
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sat Jun 20 23:44:24 2020 +0500

    workspaceAnimation: Group sticky windows and moving window
    
    Since the transitions consists of window clones now, all the clones appear
    above sticky windows. Clone sticky windows as well, and treat them same as
    moving window instead.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1326

 js/ui/workspaceAnimation.js | 102 +++++++++++++++++++++++++++++++-------------
 1 file changed, 73 insertions(+), 29 deletions(-)
---
diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js
index f51eafe846..b81251b011 100644
--- a/js/ui/workspaceAnimation.js
+++ b/js/ui/workspaceAnimation.js
@@ -90,6 +90,75 @@ class WorkspaceGroup extends Clutter.Actor {
     }
 });
 
+const StickyGroup = GObject.registerClass(
+class StickyGroup extends Clutter.Actor {
+    _init(controller) {
+        super._init();
+
+        this._controller = controller;
+        this._windows = [];
+
+        this._refreshWindows();
+
+        this.connect('destroy', this._onDestroy.bind(this));
+        this._restackedId = global.display.connect('restacked',
+            this._refreshWindows.bind(this));
+    }
+
+    _shouldShowWindow(window) {
+        if (!window.showing_on_its_workspace())
+            return false;
+
+        return window.is_on_all_workspaces() || window === this._controller.movingWindow;
+    }
+
+    _refreshWindows() {
+        if (this._windows.length > 0)
+            this._removeWindows();
+
+        let windows = global.get_window_actors();
+        windows = windows.filter(w => this._shouldShowWindow(w.meta_window));
+
+        for (let window of windows) {
+            let clone = new Clutter.Clone({
+                source: window,
+                x: window.x,
+                y: window.y,
+            });
+
+            this.add_actor(clone);
+            window.hide();
+
+            let record = { window, clone };
+
+            record.windowDestroyId = window.connect('destroy', () => {
+                clone.destroy();
+                this._windows.splice(this._windows.indexOf(record), 1);
+            });
+
+            this._windows.push(record);
+        }
+    }
+
+    _removeWindows() {
+        for (let i = 0; i < this._windows.length; i++) {
+            let w = this._windows[i];
+
+            w.window.disconnect(w.windowDestroyId);
+            w.clone.destroy();
+
+            w.window.show();
+        }
+
+        this._windows = [];
+    }
+
+    _onDestroy() {
+        global.display.disconnect(this._restackedId);
+        this._removeWindows();
+    }
+});
+
 var WorkspaceAnimationController = class {
     constructor() {
         this._movingWindow = null;
@@ -127,15 +196,14 @@ var WorkspaceAnimationController = class {
         let switchData = {};
 
         this._switchData = switchData;
-        switchData.movingWindowBin = new Clutter.Actor();
-        switchData.movingWindow = null;
+        switchData.stickyGroup = new StickyGroup(this);
         switchData.workspaces = [];
         switchData.gestureActivated = false;
         switchData.inProgress = false;
 
         switchData.container = new Clutter.Actor();
 
-        wgroup.add_actor(switchData.movingWindowBin);
+        wgroup.add_actor(switchData.stickyGroup);
         wgroup.add_actor(switchData.container);
 
         let x = 0;
@@ -194,38 +262,14 @@ var WorkspaceAnimationController = class {
         else
             switchData.container.x = -switchData.workspaces[activeWorkspaceIndex].x * global.screen_width;
 
-        wgroup.set_child_above_sibling(switchData.movingWindowBin, null);
-
-        if (this.movingWindow) {
-            let actor = this.movingWindow.get_compositor_private();
-
-            switchData.movingWindow = {
-                window: actor,
-                parent: actor.get_parent(),
-            };
-
-            switchData.movingWindow.parent.remove_child(actor);
-            switchData.movingWindowBin.add_child(actor);
-            switchData.movingWindow.windowDestroyId = actor.connect('destroy', () => {
-                switchData.movingWindow = null;
-            });
-        }
+        wgroup.set_child_above_sibling(switchData.stickyGroup, null);
     }
 
     _finishWorkspaceSwitch(switchData) {
         this._switchData = null;
 
-        if (switchData.movingWindow) {
-            let record = switchData.movingWindow;
-            record.window.disconnect(record.windowDestroyId);
-            record.window.get_parent().remove_child(record.window);
-            record.parent.add_child(record.window);
-
-            switchData.movingWindow = null;
-        }
-
         switchData.container.destroy();
-        switchData.movingWindowBin.destroy();
+        switchData.stickyGroup.destroy();
 
         this.movingWindow = null;
     }


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