workspace: Split out window repositioning logic and rename

Split out the part that moves the window clones around from
the part that calculates the window clone positions, and rename
both methods so that the overall meaning is more clear.

https://bugzilla.gnome.org/show_bug.cgi?id=694469
This commit is contained in:
Jasper St. Pierre 2013-02-25 22:43:36 -05:00
parent 59ba5504d0
commit bde8cc3285

View File

@ -974,7 +974,7 @@ const Workspace = new Lang.Class({
return false; return false;
})); }));
this._positionWindows(WindowPositionFlags.NONE); this._recalculateWindowPositions(WindowPositionFlags.NONE);
}, },
_lookupIndex: function (metaWindow) { _lookupIndex: function (metaWindow) {
@ -1002,24 +1002,24 @@ const Workspace = new Lang.Class({
clone = null; clone = null;
this._reservedSlot = clone; this._reservedSlot = clone;
this._positionWindows(WindowPositionFlags.ANIMATE); this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
}, },
_positionWindows: function(flags) { _recalculateWindowPositions: function(flags) {
this._positionWindowsFlags |= flags; this._positionWindowsFlags |= flags;
if (this._positionWindowsId > 0) if (this._positionWindowsId > 0)
return; return;
this._positionWindowsId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() { this._positionWindowsId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
this._realPositionWindows(this._positionWindowsFlags); this._realRecalculateWindowPositions(this._positionWindowsFlags);
this._positionWindowsFlags = 0; this._positionWindowsFlags = 0;
this._positionWindowsId = 0; this._positionWindowsId = 0;
return false; return false;
})); }));
}, },
_realPositionWindows : function(flags) { _realRecalculateWindowPositions: function(flags) {
if (this._repositionWindowsId > 0) { if (this._repositionWindowsId > 0) {
Mainloop.source_remove(this._repositionWindowsId); Mainloop.source_remove(this._repositionWindowsId);
this._repositionWindowsId = 0; this._repositionWindowsId = 0;
@ -1036,10 +1036,15 @@ const Workspace = new Lang.Class({
if (this._reservedSlot) if (this._reservedSlot)
clones.push(this._reservedSlot); clones.push(this._reservedSlot);
this._currentLayout = this._computeLayout(clones);
this._updateWindowPositions(flags);
},
_updateWindowPositions: function(flags) {
let initialPositioning = flags & WindowPositionFlags.INITIAL; let initialPositioning = flags & WindowPositionFlags.INITIAL;
let animate = flags & WindowPositionFlags.ANIMATE; let animate = flags & WindowPositionFlags.ANIMATE;
let layout = this._computeLayout(clones); let layout = this._currentLayout;
let strategy = layout.strategy; let strategy = layout.strategy;
let [, , padding] = this._getSpacingAndPadding(); let [, , padding] = this._getSpacingAndPadding();
@ -1174,7 +1179,7 @@ const Workspace = new Lang.Class({
return true; return true;
} }
this._positionWindows(WindowPositionFlags.ANIMATE); this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
return false; return false;
}, },
@ -1277,7 +1282,7 @@ const Workspace = new Lang.Class({
clone.overlay.relayout(false); clone.overlay.relayout(false);
} }
this._positionWindows(WindowPositionFlags.ANIMATE); this._recalculateWindowPositions(WindowPositionFlags.ANIMATE);
}, },
_windowAdded : function(metaWorkspace, metaWin) { _windowAdded : function(metaWorkspace, metaWin) {
@ -1315,7 +1320,7 @@ const Workspace = new Lang.Class({
// Animate the full-screen to Overview transition. // Animate the full-screen to Overview transition.
zoomToOverview : function() { zoomToOverview : function() {
// Position and scale the windows. // Position and scale the windows.
this._positionWindows(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL); this._recalculateWindowPositions(WindowPositionFlags.ANIMATE | WindowPositionFlags.INITIAL);
}, },
// Animates the return from Overview mode // Animates the return from Overview mode
@ -1439,7 +1444,7 @@ const Workspace = new Lang.Class({
})); }));
clone.connect('size-changed', clone.connect('size-changed',
Lang.bind(this, function() { Lang.bind(this, function() {
this._positionWindows(WindowPositionFlags.NONE); this._recalculateWindowPositions(WindowPositionFlags.NONE);
})); }));
this.actor.add_actor(clone.actor); this.actor.add_actor(clone.actor);