Skip to content

Commit

Permalink
Overview: Windows added while in the overview do zoom-in animation
Browse files Browse the repository at this point in the history
They previously did a weird animation from the top left corner.
  • Loading branch information
germanfr authored and clefebvre committed Oct 17, 2018
1 parent d0b1c3b commit 3c828d5
Showing 1 changed file with 12 additions and 34 deletions.
46 changes: 12 additions & 34 deletions js/ui/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ WindowClone.prototype = {
this.metaWindow._delegate = this;
this.overlay = null;
this.closedFromOverview = false;
this._is_new_window = false; // Window opened while in the overview

// Original position of the full-sized window
this.origX = 0;
Expand Down Expand Up @@ -726,7 +727,7 @@ WorkspaceMonitor.prototype = {
if (overlay)
overlay.hide();
if (animate && isOnCurrentWorkspace) {
if (!metaWindow.showing_on_its_workspace()) {
if (!metaWindow.showing_on_its_workspace() || clone._is_new_window) {
/* Hidden windows should fade in and grow
* therefore we need to resize them now so they
* can be scaled up later */
Expand All @@ -736,8 +737,15 @@ WorkspaceMonitor.prototype = {
clone.actor.scale_y = 0;
clone.actor.x = this._width / 2;
clone.actor.y = this._height / 2;
} else if (clone._is_new_window) {
clone.actor.opacity = 0;
clone.actor.scale_x = 0;
clone.actor.scale_y = 0;
clone.actor.x = x + clone.actor.width * scale / 2;
clone.actor.y = y + clone.actor.height * scale / 2;
}


// Make the window slightly transparent to indicate it's hidden
Tweener.addTween(clone.actor,
{ opacity: 255,
Expand All @@ -763,6 +771,8 @@ WorkspaceMonitor.prototype = {
clone.actor.set_scale(scale, scale);
this._showWindowOverlay(clone, isOnCurrentWorkspace);
}

clone._is_new_window = false;
}
},

Expand Down Expand Up @@ -863,22 +873,6 @@ WorkspaceMonitor.prototype = {

this._windows.splice(index, 1);

// If metaWin.get_compositor_private() returned non-NULL, that
// means the window still exists (and is just being moved to
// another workspace or something), so set its overviewHint
// accordingly. (If it returned NULL, then the window is being
// destroyed; we'd like to animate this, but it's too late at
// this point.)
if (win) {
let [stageX, stageY] = clone.actor.get_transformed_position();
let [stageWidth, stageHeight] = clone.actor.get_transformed_size();
win._overviewHint = {
x: stageX,
y: stageY,
scale: stageWidth / clone.actor.width
};
}

if (this._kbWindowIndex >= this._windows.length) {
this._kbWindowIndex = this._windows.length - 1;
}
Expand Down Expand Up @@ -926,26 +920,10 @@ WorkspaceMonitor.prototype = {
}
let clone = this._addWindowClone(win);

if (win._overviewHint) {
let x = win._overviewHint.x - this.actor.x;
let y = win._overviewHint.y - this.actor.y;
let scale = win._overviewHint.scale;
delete win._overviewHint;

clone.actor.set_position (x, y);
clone.actor.set_scale (scale, scale);
} else {
// Position new windows at the top corner of the workspace rather
// than where they were placed for real to avoid the window
// being clipped to the workspaceView. Its not really more
// natural for the window to suddenly appear in the overview
// on some seemingly random location anyway.
clone.actor.set_position (this._x, this._y);
}

this._updateEmptyPlaceholder();

if (this.actor.get_stage()) {
clone._is_new_window = true;
let animate = global.settings.get_boolean("desktop-effects");
this.positionWindows(animate ? WindowPositionFlags.ANIMATE : 0);
}
Expand Down

0 comments on commit 3c828d5

Please sign in to comment.