[gnome-shell] workspace: Use generic _addWindow function to add new clones



commit cc5ed2fbf5a9ff0f6fb6ad951a34e12abb3b0dad
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Sun May 31 23:15:06 2020 +0200

    workspace: Use generic _addWindow function to add new clones
    
    Now that we handle all ClutterClones belonging to the WindowClone pretty
    much the same, we can add a generic _addWindow function to WindowClone
    which creates the ClutterClone and adds it to the layout manager.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1297

 js/ui/workspace.js | 36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index d58114dfce..859e579bbb 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -182,14 +182,6 @@ var WindowClone = GObject.registerClass({
         this.metaWindow._delegate = this;
         this._workspace = workspace;
 
-        this._windowClone = new Clutter.Clone({ source: realWindow });
-        // We expect this to be used for all interaction rather than
-        // this._windowClone; as the former is reactive and the latter
-        // is not, this just works for most cases. However, for DND all
-        // actors are picked, so DND operations would operate on the clone.
-        // To avoid this, we hide it from pick.
-        Shell.util_set_hidden_from_pick(this._windowClone, true);
-
         // The MetaShapedTexture that we clone has a size that includes
         // the invisible border; this is inconvenient; rather than trying
         // to compensate all over the place we insert a ClutterActor into
@@ -203,7 +195,7 @@ var WindowClone = GObject.registerClass({
 
         this.set_offscreen_redirect(Clutter.OffscreenRedirect.AUTOMATIC_FOR_OPACITY);
 
-        this.layout_manager.addWindow(this._windowClone, this.metaWindow);
+        this._addWindow(realWindow.meta_window);
 
         this._delegate = this;
 
@@ -242,6 +234,20 @@ var WindowClone = GObject.registerClass({
         this._closeRequested = false;
     }
 
+    _addWindow(metaWindow) {
+        const windowActor = metaWindow.get_compositor_private();
+        const clone = new Clutter.Clone({ source: windowActor });
+
+        // We expect this to be used for all interaction rather than
+        // the ClutterClone; as the former is reactive and the latter
+        // is not, this just works for most cases. However, for DND all
+        // actors are picked, so DND operations would operate on the clone.
+        // To avoid this, we hide it from pick.
+        Shell.util_set_hidden_from_pick(clone, true);
+
+        this.layout_manager.addWindow(clone, metaWindow);
+    }
+
     vfunc_has_overlaps() {
         return this.hasAttachedDialogs();
     }
@@ -278,7 +284,7 @@ var WindowClone = GObject.registerClass({
 
         // Display dialog if it is attached to our metaWindow
         if (win.is_attached_dialog() && parent == this.metaWindow)
-            this._doAddAttachedDialog(win, win.get_compositor_private());
+            this._addWindow(win);
 
         // The dialog popped up after the user tried to close the window,
         // assume it's a close confirmation and leave the overview
@@ -290,14 +296,6 @@ var WindowClone = GObject.registerClass({
         return this.get_n_children() > 1;
     }
 
-    _doAddAttachedDialog(metaWin, realWin) {
-        let clone = new Clutter.Clone({ source: realWin });
-
-        Shell.util_set_hidden_from_pick(clone, true);
-
-        this.layout_manager.addWindow(clone, metaWin);
-    }
-
     _updateAttachedDialogs() {
         let iter = win => {
             let actor = win.get_compositor_private();
@@ -307,7 +305,7 @@ var WindowClone = GObject.registerClass({
             if (!win.is_attached_dialog())
                 return false;
 
-            this._doAddAttachedDialog(win, actor);
+            this._addWindow(win);
             win.foreach_transient(iter);
             return true;
         };


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