[gnome-shell] workspace: Stop using WindowPreview.realWindow in the overview



commit 46600740fedd6da7344d4693fb8b0721ef063d0c
Author: Jonas Dreßler <verdre v0yd nl>
Date:   Mon Jun 8 09:50:41 2020 +0200

    workspace: Stop using WindowPreview.realWindow in the overview
    
    We can simply get the MetaWindowActor by calling
    MetaWindow.get_compositor_private(), so stop accessing the realWindow
    property of WindowPreview. For this we also have to make _isMyWindow()
    and _isOverviewWindow() take a MetaWindow as an argument instead of a
    MetaWindowActor.
    
    Since the WorkspacesThumbnails are also drop targets for WindowPreviews
    and their WindowClones also have the public metaWindow property, switch
    to using the metaWindow property there, too.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1307

 js/ui/workspace.js          | 43 +++++++++++++++++++++----------------------
 js/ui/workspaceThumbnail.js | 15 ++++++++-------
 2 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index e1096f16f1..2bf98da5d1 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -1159,14 +1159,15 @@ class Workspace extends St.Widget {
 
         this.connect('destroy', this._onDestroy.bind(this));
 
-        let windows = global.get_window_actors().filter(this._isMyWindow, this);
+        const windows = global.get_window_actors().map(a => a.meta_window)
+            .filter(this._isMyWindow, this);
 
         // Create clones for windows that should be
         // visible in the Overview
         this._windows = [];
         for (let i = 0; i < windows.length; i++) {
             if (this._isOverviewWindow(windows[i]))
-                this._addWindowClone(windows[i], true);
+                this._addWindowClone(windows[i].get_compositor_private(), true);
         }
 
         // Track window changes
@@ -1514,10 +1515,10 @@ class Workspace extends St.Widget {
         if (this._lookupIndex(metaWin) != -1)
             return;
 
-        if (!this._isMyWindow(win))
+        if (!this._isMyWindow(metaWin))
             return;
 
-        if (!this._isOverviewWindow(win)) {
+        if (!this._isOverviewWindow(metaWin)) {
             if (metaWin.get_transient_for() == null)
                 return;
 
@@ -1798,16 +1799,16 @@ class Workspace extends St.Widget {
         this._recalculateWindowPositions(WindowPositionFlags.INITIAL);
     }
 
-    // Tests if @actor belongs to this workspaces and monitor
-    _isMyWindow(actor) {
-        let win = actor.meta_window;
-        return (this.metaWorkspace == null || win.located_on_workspace(this.metaWorkspace)) &&
-            (win.get_monitor() == this.monitorIndex);
+    _isMyWindow(window) {
+        const isOnWorkspace = this.metaWorkspace === null ||
+            window.located_on_workspace(this.metaWorkspace);
+        const isOnMonitor = window.get_monitor() === this.monitorIndex;
+
+        return isOnWorkspace && isOnMonitor;
     }
 
-    // Tests if @win should be shown in the Overview
-    _isOverviewWindow(win) {
-        return !win.get_meta_window().skip_taskbar;
+    _isOverviewWindow(window) {
+        return !window.skip_taskbar;
     }
 
     // Create a clone of a (non-desktop) window and add it to the window list
@@ -1961,7 +1962,7 @@ class Workspace extends St.Widget {
 
     // Draggable target interface
     handleDragOver(source, _actor, _x, _y, _time) {
-        if (source.realWindow && !this._isMyWindow(source.realWindow))
+        if (source.metaWindow && !this._isMyWindow(source.metaWindow))
             return DND.DragMotionResult.MOVE_DROP;
         if (source.app && source.app.can_open_new_window())
             return DND.DragMotionResult.COPY_DROP;
@@ -1977,29 +1978,27 @@ class Workspace extends St.Widget {
             ? this.metaWorkspace.index()
             : workspaceManager.get_active_workspace_index();
 
-        if (source.realWindow) {
-            let win = source.realWindow;
-            if (this._isMyWindow(win))
+        if (source.metaWindow) {
+            const window = source.metaWindow;
+            if (this._isMyWindow(window))
                 return false;
 
             // Set a hint on the Mutter.Window so its initial position
             // in the new workspace will be correct
-            win._overviewHint = {
+            window.get_compositor_private()._overviewHint = {
                 x: actor.x,
                 y: actor.y,
                 width: actor.width,
                 heigth: actor.height,
             };
 
-            let metaWindow = win.get_meta_window();
-
             // We need to move the window before changing the workspace, because
             // the move itself could cause a workspace change if the window enters
             // the primary monitor
-            if (metaWindow.get_monitor() != this.monitorIndex)
-                metaWindow.move_to_monitor(this.monitorIndex);
+            if (window.get_monitor() != this.monitorIndex)
+                window.move_to_monitor(this.monitorIndex);
 
-            metaWindow.change_workspace_by_index(workspaceIndex, false);
+            window.change_workspace_by_index(workspaceIndex, false);
             return true;
         } else if (source.app && source.app.can_open_new_window()) {
             if (source.animateLaunchAtPos)
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 5066678098..73f8b7ec95 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -567,7 +567,8 @@ var WorkspaceThumbnail = GObject.registerClass({
         if (this.state > ThumbnailState.NORMAL)
             return DND.DragMotionResult.CONTINUE;
 
-        if (source.realWindow && !this._isMyWindow(source.realWindow))
+        if (source.metaWindow &&
+            !this._isMyWindow(source.metaWindow.get_compositor_private()))
             return DND.DragMotionResult.MOVE_DROP;
         if (source.app && source.app.can_open_new_window())
             return DND.DragMotionResult.COPY_DROP;
@@ -581,8 +582,8 @@ var WorkspaceThumbnail = GObject.registerClass({
         if (this.state > ThumbnailState.NORMAL)
             return false;
 
-        if (source.realWindow) {
-            let win = source.realWindow;
+        if (source.metaWindow) {
+            let win = source.metaWindow.get_compositor_private();
             if (this._isMyWindow(win))
                 return false;
 
@@ -795,7 +796,7 @@ var ThumbnailsBox = GObject.registerClass({
 
     // Draggable target interface
     handleDragOver(source, actor, x, y, time) {
-        if (!source.realWindow &&
+        if (!source.metaWindow &&
             (!source.app || !source.app.can_open_new_window()) &&
             (source.app || !source.shellWorkspaceLaunch) &&
             source != Main.xdndHandler)
@@ -846,7 +847,7 @@ var ThumbnailsBox = GObject.registerClass({
         if (this._dropWorkspace != -1)
             return this._thumbnails[this._dropWorkspace].handleDragOverInternal(source, actor, time);
         else if (this._dropPlaceholderPos != -1)
-            return source.realWindow ? DND.DragMotionResult.MOVE_DROP : DND.DragMotionResult.COPY_DROP;
+            return source.metaWindow ? DND.DragMotionResult.MOVE_DROP : DND.DragMotionResult.COPY_DROP;
         else
             return DND.DragMotionResult.CONTINUE;
     }
@@ -855,12 +856,12 @@ var ThumbnailsBox = GObject.registerClass({
         if (this._dropWorkspace != -1) {
             return this._thumbnails[this._dropWorkspace].acceptDropInternal(source, actor, time);
         } else if (this._dropPlaceholderPos != -1) {
-            if (!source.realWindow &&
+            if (!source.metaWindow &&
                 (!source.app || !source.app.can_open_new_window()) &&
                 (source.app || !source.shellWorkspaceLaunch))
                 return false;
 
-            let isWindow = !!source.realWindow;
+            let isWindow = !!source.metaWindow;
 
             let newWorkspaceIndex;
             [newWorkspaceIndex, this._dropPlaceholderPos] = [this._dropPlaceholderPos, -1];


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