diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js index 432044f7592b84099c7fb1c44ca33489b048f20c..9c29d2d0b94b23304ce8e0ba9b6ce4cf46876a80 100644 --- a/js/ui/workspaceAnimation.js +++ b/js/ui/workspaceAnimation.js @@ -461,8 +461,26 @@ var WorkspaceAnimationController = class { }; if (monitorGroup.index === Main.layoutManager.primaryIndex) { + const workspaceManager = global.workspace_manager; + + let wsIndex = newWs.index(); + let wsDefunct = false; + workspaceManager.connectObject( + 'workspace-removed', (_, index) => { + if (index === wsIndex) + wsDefunct = true; + else + wsIndex = newWs.index(); + }, + 'workspaces-reordered', () => { + wsIndex = newWs.index(); + }, this); + + params.onStopped = () => { + workspaceManager.disconnectObject(this); + }; params.onComplete = () => { - if (!newWs.active) + if (!wsDefunct && !newWs.active) newWs.activate(endTime); this._finishWorkspaceSwitch(switchData); };