From df149524d444ef415858d04ff96f4c7edf4f7861 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Mon, 8 Jun 2020 14:47:43 +0200 Subject: [PATCH] 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 --- js/ui/workspace.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index fccb5c560..c815ebec8 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -159,6 +159,36 @@ var WindowCloneLayout = GObject.registerClass({ 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 get bounding_box() { return this._boundingBox;