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
This commit is contained in:
parent
d12cd12e1b
commit
d91927674d
@ -158,6 +158,8 @@ var WindowClone = GObject.registerClass({
|
|||||||
this.x = this._boundingBox.x;
|
this.x = this._boundingBox.x;
|
||||||
this.y = this._boundingBox.y;
|
this.y = this._boundingBox.y;
|
||||||
|
|
||||||
|
this._computeWindowCenter();
|
||||||
|
|
||||||
let clickAction = new Clutter.ClickAction();
|
let clickAction = new Clutter.ClickAction();
|
||||||
clickAction.connect('clicked', this._onClicked.bind(this));
|
clickAction.connect('clicked', this._onClicked.bind(this));
|
||||||
clickAction.connect('long-press', this._onLongPress.bind(this));
|
clickAction.connect('long-press', this._onLongPress.bind(this));
|
||||||
@ -293,6 +295,18 @@ var WindowClone = GObject.registerClass({
|
|||||||
this.layout_manager.boundingBox = rect;
|
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
|
// Find the actor just below us, respecting reparenting done by DND code
|
||||||
getActualStackAbove() {
|
getActualStackAbove() {
|
||||||
if (this._stackAbove == null)
|
if (this._stackAbove == null)
|
||||||
@ -1017,11 +1031,7 @@ var UnalignedLayoutStrategy = class extends LayoutStrategy {
|
|||||||
_sortRow(row) {
|
_sortRow(row) {
|
||||||
// Sort windows horizontally to minimize travel distance.
|
// Sort windows horizontally to minimize travel distance.
|
||||||
// This affects in what order the windows end up in a row.
|
// This affects in what order the windows end up in a row.
|
||||||
row.windows.sort((a, b) => {
|
row.windows.sort((a, b) => a.windowCenter.x - b.windowCenter.x);
|
||||||
let aCenter = a.realWindow.x + a.realWindow.width / 2;
|
|
||||||
let bCenter = b.realWindow.x + b.realWindow.width / 2;
|
|
||||||
return aCenter - bCenter;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
computeLayout(windows, layout) {
|
computeLayout(windows, layout) {
|
||||||
@ -1040,11 +1050,7 @@ var UnalignedLayoutStrategy = class extends LayoutStrategy {
|
|||||||
// Sort windows vertically to minimize travel distance.
|
// Sort windows vertically to minimize travel distance.
|
||||||
// This affects what rows the windows get placed in.
|
// This affects what rows the windows get placed in.
|
||||||
let sortedWindows = windows.slice();
|
let sortedWindows = windows.slice();
|
||||||
sortedWindows.sort((a, b) => {
|
sortedWindows.sort((a, b) => a.windowCenter.y - b.windowCenter.y);
|
||||||
let aCenter = a.realWindow.y + a.realWindow.height / 2;
|
|
||||||
let bCenter = b.realWindow.y + b.realWindow.height / 2;
|
|
||||||
return aCenter - bCenter;
|
|
||||||
});
|
|
||||||
|
|
||||||
let windowIdx = 0;
|
let windowIdx = 0;
|
||||||
for (let i = 0; i < numRows; i++) {
|
for (let i = 0; i < numRows; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user