[gnome-shell] workspace: Sort windows when we calculate slots
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] workspace: Sort windows when we calculate slots
- Date: Wed, 24 Apr 2013 18:23:49 +0000 (UTC)
commit e0252f35be2b4df565c649ca67780d8949a80159
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Wed Apr 24 13:53:11 2013 -0400
workspace: Sort windows when we calculate slots
This ensures that windows don't change positions when we lay
them out again when expanding the workspace switcher.
https://bugzilla.gnome.org/show_bug.cgi?id=698776
js/ui/workspace.js | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/workspace.js b/js/ui/workspace.js
index ae6ad18..ee6dcfc 100644
--- a/js/ui/workspace.js
+++ b/js/ui/workspace.js
@@ -753,13 +753,6 @@ const LayoutStrategy = new Lang.Class({
layout.space = space;
},
- _getDistance: function (row, actor) {
- let dist_x = actor.x - row.x;
- let dist_y = actor.y - row.y;
-
- return Math.sqrt(Math.pow(dist_x, 2) + Math.pow(dist_y, 2));
- },
-
computeWindowSlots: function(layout, area) {
this._computeRowSizes(layout);
@@ -788,10 +781,6 @@ const LayoutStrategy = new Lang.Class({
row.x = area.x + (Math.max(area.width - row.width, 0) / 2) * row.additionalScale;
row.y = area.y + (y + Math.max(area.height - height, 0) / 2) * row.additionalScale;
y += row.height + this._rowSpacing;
-
- row.windows.sort(Lang.bind(this, function(a, b) {
- return this._getDistance(row, a.realWindow) - this._getDistance(row, b.realWindow);
- }));
}
for (let i = 0; i < rows.length; i++) {
@@ -844,6 +833,13 @@ const UnalignedLayoutStrategy = new Lang.Class({
return false;
},
+ _sortRow: function(row) {
+ // Sort windows horizontally to minimize travel distance
+ row.windows.sort(function(a, b) {
+ return a.realWindow.x - b.realWindow.x;
+ });
+ },
+
computeLayout: function(windows, layout) {
let numRows = layout.numRows;
@@ -874,6 +870,7 @@ const UnalignedLayoutStrategy = new Lang.Class({
row.windows.push(window);
row.fullWidth += width;
} else {
+ this._sortRow(row);
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]