workspace: Add API to get windows and metaWindow to WindowCloneLayout

This will allow us to remove the remaining parts of the WindowClone
looping through children in favour of simply getting an array with the
windows or metaWindows and looping through that.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1298
This commit is contained in:
Jonas Dreßler 2020-06-08 14:47:43 +02:00
parent f0ee9cdcf8
commit df149524d4

View File

@ -159,6 +159,36 @@ var WindowCloneLayout = GObject.registerClass({
this._layoutChanged(); this._layoutChanged();
} }
/**
* getWindows:
*
* Gets an array of all ClutterActors that were added to the layout
* using addWindow(), ordered by the insertion order.
*
* @returns {Array} An array including all windows
*/
getWindows() {
return [...this._windows.keys()];
}
/**
* getMetaWindow:
* @param {Clutter.Actor} window: the window to get the MetaWindow for
*
* Gets the MetaWindow associated to the ClutterActor @window that was
* added to the layout using addWindow(). If @window is not found,
* null is returned.
*
* @returns {Meta.Window} The metaWindow of the window
*/
getMetaWindow(window) {
const windowInfo = this._windows.get(window);
if (!windowInfo)
return null;
return windowInfo.metaWindow;
}
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
get bounding_box() { get bounding_box() {
return this._boundingBox; return this._boundingBox;