[gnome-shell/gnome-3-34] workspace: Sort windows in overview grid using cached center
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gnome-3-34] workspace: Sort windows in overview grid using cached center
- Date: Thu, 17 Oct 2019 08:07:40 +0000 (UTC)
commit 072a9a4842673355535098edd4748d689b913bf1
Author: Andrew Watson <andrew l watson btinternet com>
Date: Tue Oct 15 11:35:18 2019 +0000
workspace: Sort windows in overview grid using cached center
When accessing properties on ClutterActor for size and position there is
a notable access time overhead. This overhead adds considerable user lag
when opening the overview if many windows are open.
This is primarily due to these properties being accessed while sorting
WindowClone instances by their window's center for placement in the
overview. By pre-computing this center value only once when
initializing WindowClone, the induced lag can be significantly reduced.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/763
(cherry picked from commit d91927674d4ea5ae7c7e77ace28f5939553147d5)
js/ui/workspace.js | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index a93b19add9..cf0c479020 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -157,6 +157,8 @@ var WindowClone = GObject.registerClass({
this.x = this._boundingBox.x;
this.y = this._boundingBox.y;
+ this._computeWindowCenter();
+
let clickAction = new Clutter.ClickAction();
clickAction.connect('clicked', this._onClicked.bind(this));
clickAction.connect('long-press', this._onLongPress.bind(this));
@@ -299,6 +301,18 @@ var WindowClone = GObject.registerClass({
this.layout_manager.boundingBox = rect;
}
+ get windowCenter() {
+ return this._windowCenter;
+ }
+
+ _computeWindowCenter() {
+ let box = this.realWindow.get_allocation_box();
+ this._windowCenter = new Clutter.Point({
+ x: box.get_x() + box.get_width() / 2,
+ y: box.get_y() + box.get_height() / 2,
+ });
+ }
+
// Find the actor just below us, respecting reparenting done by DND code
getActualStackAbove() {
if (this._stackAbove == null)
@@ -1003,11 +1017,7 @@ var UnalignedLayoutStrategy = class extends LayoutStrategy {
_sortRow(row) {
// Sort windows horizontally to minimize travel distance.
// This affects in what order the windows end up in a row.
- row.windows.sort((a, b) => {
- let aCenter = a.realWindow.x + a.realWindow.width / 2;
- let bCenter = b.realWindow.x + b.realWindow.width / 2;
- return aCenter - bCenter;
- });
+ row.windows.sort((a, b) => a.windowCenter.x - b.windowCenter.x);
}
computeLayout(windows, layout) {
@@ -1026,11 +1036,7 @@ var UnalignedLayoutStrategy = class extends LayoutStrategy {
// Sort windows vertically to minimize travel distance.
// This affects what rows the windows get placed in.
let sortedWindows = windows.slice();
- sortedWindows.sort((a, b) => {
- let aCenter = a.realWindow.y + a.realWindow.height / 2;
- let bCenter = b.realWindow.y + b.realWindow.height / 2;
- return aCenter - bCenter;
- });
+ sortedWindows.sort((a, b) => a.windowCenter.y - b.windowCenter.y);
let windowIdx = 0;
for (let i = 0; i < numRows; i++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]