fix sizing of all-workspace windows in the overview

Window can have more then one clones on different workspaces.
https://bugzilla.gnome.org/show_bug.cgi?id=603078
This commit is contained in:
Maxim Ermilov 2010-02-19 21:27:07 +03:00
parent 5b1d52c5e7
commit 49a9335f68
2 changed files with 25 additions and 26 deletions

View File

@ -764,10 +764,6 @@ Workspace.prototype = {
return visible; return visible;
}, },
_getVisibleWindows: function() {
return this._getVisibleClones().map(function (clone) { return clone.metaWindow; });
},
_resetCloneVisibility: function () { _resetCloneVisibility: function () {
for (let i = 1; i < this._windows.length; i++) { for (let i = 1; i < this._windows.length; i++) {
let clone = this._windows[i]; let clone = this._windows[i];
@ -858,14 +854,14 @@ Workspace.prototype = {
* Iterate over all permutations of the windows, and determine the * Iterate over all permutations of the windows, and determine the
* permutation which has the least total motion. * permutation which has the least total motion.
*/ */
_orderWindowsPermutations: function (windows, slots, slotGeometries) { _orderWindowsPermutations: function (clones, slots, slotGeometries) {
let minimumMotionPermutation = null; let minimumMotionPermutation = null;
let minimumMotion = -1; let minimumMotion = -1;
let permIndex = 0; let permIndex = 0;
this._forEachPermutations(windows, Lang.bind(this, function (permutation) { this._forEachPermutations(clones, Lang.bind(this, function (permutation) {
let motion = 0; let motion = 0;
for (let i = 0; i < permutation.length; i++) { for (let i = 0; i < permutation.length; i++) {
let metaWindow = permutation[i]; let metaWindow = permutation[i].metaWindow;
let slot = slots[i]; let slot = slots[i];
let slotAbsGeometry = slotGeometries[i]; let slotAbsGeometry = slotGeometries[i];
@ -889,26 +885,26 @@ Workspace.prototype = {
* Iterate over available slots in order, placing into each one the window * Iterate over available slots in order, placing into each one the window
* we find with the smallest motion to that slot. * we find with the smallest motion to that slot.
*/ */
_orderWindowsGreedy: function(windows, slots, slotGeometries) { _orderWindowsGreedy: function(clones, slots, slotGeometries) {
let result = []; let result = [];
let slotIndex = 0; let slotIndex = 0;
// Copy since we mutate below // Copy since we mutate below
let windowCopy = windows.concat(); let clonesCopy = clones.concat();
for (let i = 0; i < slots.length; i++) { for (let i = 0; i < slots.length; i++) {
let slot = slots[i]; let slot = slots[i];
let slotGeometry = slotGeometries[i]; let slotGeometry = slotGeometries[i];
let minimumMotionIndex = -1; let minimumMotionIndex = -1;
let minimumMotion = -1; let minimumMotion = -1;
for (let j = 0; j < windowCopy.length; j++) { for (let j = 0; j < clonesCopy.length; j++) {
let metaWindow = windowCopy[j]; let metaWindow = clonesCopy[j].metaWindow;
let delta = this._computeWindowMotion(metaWindow, slot, slotGeometry); let delta = this._computeWindowMotion(metaWindow, slot, slotGeometry);
if (minimumMotionIndex == -1 || delta < minimumMotion) { if (minimumMotionIndex == -1 || delta < minimumMotion) {
minimumMotionIndex = j; minimumMotionIndex = j;
minimumMotion = delta; minimumMotion = delta;
} }
} }
result.push(windowCopy[minimumMotionIndex]); result.push(clonesCopy[minimumMotionIndex]);
windowCopy.splice(minimumMotionIndex, 1); clonesCopy.splice(minimumMotionIndex, 1);
} }
return result; return result;
}, },
@ -922,15 +918,15 @@ Workspace.prototype = {
* to move to the final screen coordinates of @slots. Ties are broken in a stable * to move to the final screen coordinates of @slots. Ties are broken in a stable
* fashion by the order in which the windows were created. * fashion by the order in which the windows were created.
*/ */
_orderWindowsByMotionAndStartup: function(windows, slots) { _orderWindowsByMotionAndStartup: function(clones, slots) {
windows.sort(function(w1, w2) { clones.sort(function(w1, w2) {
return w2.get_stable_sequence() - w1.get_stable_sequence(); return w2.metaWindow.get_stable_sequence() - w1.metaWindow.get_stable_sequence();
}); });
let slotGeometries = slots.map(Lang.bind(this, this._getSlotAbsoluteGeometry)); let slotGeometries = slots.map(Lang.bind(this, this._getSlotAbsoluteGeometry));
if (windows.length <= POSITIONING_PERMUTATIONS_MAX) if (clones.length <= POSITIONING_PERMUTATIONS_MAX)
return this._orderWindowsPermutations(windows, slots, slotGeometries); return this._orderWindowsPermutations(clones, slots, slotGeometries);
else else
return this._orderWindowsGreedy(windows, slots, slotGeometries); return this._orderWindowsGreedy(clones, slots, slotGeometries);
}, },
/** /**
@ -1009,20 +1005,20 @@ Workspace.prototype = {
positionWindows : function(flags) { positionWindows : function(flags) {
let totalVisible = 0; let totalVisible = 0;
let visibleWindows = this._getVisibleWindows(); let visibleClones = this._getVisibleClones();
let workspaceZooming = flags & WindowPositionFlags.ZOOM; let workspaceZooming = flags & WindowPositionFlags.ZOOM;
let animate = flags & WindowPositionFlags.ANIMATE; let animate = flags & WindowPositionFlags.ANIMATE;
// Start the animations // Start the animations
let slots = this._computeAllWindowSlots(visibleWindows.length); let slots = this._computeAllWindowSlots(visibleClones.length);
visibleWindows = this._orderWindowsByMotionAndStartup(visibleWindows, slots); visibleClones = this._orderWindowsByMotionAndStartup(visibleClones, slots);
for (let i = 0; i < visibleWindows.length; i++) { for (let i = 0; i < visibleClones.length; i++) {
let slot = slots[i]; let slot = slots[i];
let metaWindow = visibleWindows[i]; let clone = visibleClones[i];
let metaWindow = clone.metaWindow;
let mainIndex = this._lookupIndex(metaWindow); let mainIndex = this._lookupIndex(metaWindow);
let clone = metaWindow._delegate;
let overlay = this._windowOverlays[mainIndex]; let overlay = this._windowOverlays[mainIndex];
let [x, y, scale] = this._computeWindowRelativeLayout(metaWindow, slot); let [x, y, scale] = this._computeWindowRelativeLayout(metaWindow, slot);

View File

@ -373,8 +373,11 @@ MosaicView.prototype = {
if (newNumWorkspaces > oldNumWorkspaces) { if (newNumWorkspaces > oldNumWorkspaces) {
// Slide new workspaces in from offscreen // Slide new workspaces in from offscreen
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) // New workspaces can contain windows.
for (let w = oldNumWorkspaces; w < newNumWorkspaces; w++) {
this._workspaces[w].positionWindows(0);
this._workspaces[w].slideIn(oldScale); this._workspaces[w].slideIn(oldScale);
}
} else { } else {
// Slide old workspaces out // Slide old workspaces out
for (let w = 0; w < lostWorkspaces.length; w++) { for (let w = 0; w < lostWorkspaces.length; w++) {