workspace: Initialize WindowPreview using a MetaWindow

MetaWindow is Mutters representation of a window and provides all the
APIs about it, MetaWindowActor is just the ClutterActor that's drawing
that window. So use a MetaWindow to create a WindowPreview instead of
the window actor.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1307
This commit is contained in:
Jonas Dreßler 2020-06-08 09:58:22 +02:00
parent 8c49f45ac8
commit 6bef9334b7

View File

@ -214,10 +214,10 @@ var WindowPreview = GObject.registerClass({
'size-changed': {},
},
}, class WindowPreview extends St.Widget {
_init(realWindow, workspace) {
this.realWindow = realWindow;
this.metaWindow = realWindow.meta_window;
_init(metaWindow, workspace) {
this.metaWindow = metaWindow;
this.metaWindow._delegate = this;
this.realWindow = metaWindow.get_compositor_private();
this._workspace = workspace;
super._init({
@ -1167,7 +1167,7 @@ class Workspace extends St.Widget {
this._windows = [];
for (let i = 0; i < windows.length; i++) {
if (this._isOverviewWindow(windows[i]))
this._addWindowClone(windows[i].get_compositor_private(), true);
this._addWindowClone(windows[i], true);
}
// Track window changes
@ -1534,7 +1534,7 @@ class Workspace extends St.Widget {
return;
}
let clone = this._addWindowClone(win, false);
let clone = this._addWindowClone(metaWin, false);
if (metaWin._overviewHint) {
let x = metaWin._overviewHint.x - this.x;
@ -1812,20 +1812,20 @@ class Workspace extends St.Widget {
}
// Create a clone of a (non-desktop) window and add it to the window list
_addWindowClone(win, positioned) {
let clone = new WindowPreview(win, this);
_addWindowClone(metaWindow, positioned) {
let clone = new WindowPreview(metaWindow, this);
clone.positioned = positioned;
clone.connect('selected',
this._onCloneSelected.bind(this));
clone.connect('drag-begin', () => {
Main.overview.beginWindowDrag(clone.metaWindow);
Main.overview.beginWindowDrag(metaWindow);
});
clone.connect('drag-cancelled', () => {
Main.overview.cancelledWindowDrag(clone.metaWindow);
Main.overview.cancelledWindowDrag(metaWindow);
});
clone.connect('drag-end', () => {
Main.overview.endWindowDrag(clone.metaWindow);
Main.overview.endWindowDrag(metaWindow);
});
clone.connect('size-changed', () => {
this._recalculateWindowPositions(WindowPositionFlags.NONE);
@ -1841,7 +1841,7 @@ class Workspace extends St.Widget {
});
});
clone.connect('destroy', () => {
this._removeWindowClone(clone.metaWindow);
this._removeWindowClone(metaWindow);
});
this.add_child(clone);