From 732e710f1e4885a60c172781788ebe4dc4f7c052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 24 Nov 2022 22:45:29 +0100 Subject: [PATCH] workspaceAnimation: Don't activate workspace if it was removed With dynamic workspaces enabled, if the second last workspace had a single window, which closed during the swipe workspace switch fling animation was animating a workspace switch to the last (empty) workspace, we'd end up calling `newWs.activate()` on the removed workspace. This wasn't handled gracefully by mutter, who assumed valid input was passed, resulting an an abort() being hit. Fix this by keeping track of whether the workspace was removed while the animation is ongoing. Fixes a crash in mutter originating from #0 ui/workspaceAnimation.js:466 #1 ui/environment.js:153 #2 ui/environment.js:317 With the logged warning Bug in window manager: Failed to find destination workspace in layout --- js/ui/workspaceAnimation.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/js/ui/workspaceAnimation.js b/js/ui/workspaceAnimation.js index 432044f759..9c29d2d0b9 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); }; -- GitLab