(wm, fromIndex, toIndex, animate = false)
| 2700 | } |
| 2701 | |
| 2702 | switchWorkspace(wm, fromIndex, toIndex, animate = false) { |
| 2703 | /** |
| 2704 | * disable swipetrackers on workspace switch to avoid gesture confusion |
| 2705 | * see https://github.com/paperwm/PaperWM/issues/682 |
| 2706 | */ |
| 2707 | if (Gestures.gestureEnabled()) { |
| 2708 | // if in overview exit -> overview will disable swipetrackers when done |
| 2709 | if (!Main.overview.visible) { |
| 2710 | Gestures.swipeTrackersEnable(false); |
| 2711 | } |
| 2712 | } |
| 2713 | |
| 2714 | let to = workspaceManager.get_workspace_by_index(toIndex); |
| 2715 | let from = workspaceManager.get_workspace_by_index(fromIndex); |
| 2716 | let toSpace = this.spaceOf(to); |
| 2717 | let fromSpace = this.spaceOf(from); |
| 2718 | |
| 2719 | if (inGrab && inGrab.window) { |
| 2720 | inGrab.window.change_workspace(toSpace.workspace); |
| 2721 | } |
| 2722 | |
| 2723 | for (let metaWindow of toSpace.getWindows()) { |
| 2724 | // Make sure all windows belong to the correct workspace. |
| 2725 | // Note: The 'switch-workspace' signal (this method) runs before mutter decides on focus window. |
| 2726 | // This simplifies other code moving windows between workspaces. |
| 2727 | // Eg.: The DnD-window defer changing its workspace until the workspace actually is activated. |
| 2728 | // This ensures the DnD window keep focus the whole time. |
| 2729 | metaWindow.change_workspace(toSpace.workspace); |
| 2730 | } |
| 2731 | |
| 2732 | if (inPreview === PreviewMode.NONE && |
| 2733 | toSpace.monitor === fromSpace.monitor) { |
| 2734 | // Only start an animation if we're moving between workspaces on the |
| 2735 | // same monitor |
| 2736 | this.initWorkspaceSequence(); |
| 2737 | } else { |
| 2738 | this.selectedSpace.setMonitor(this.selectedSpace.monitor); |
| 2739 | } |
| 2740 | |
| 2741 | this.stack = this.stack.filter(s => s !== toSpace); |
| 2742 | this.stack = [toSpace, ...this.stack]; |
| 2743 | |
| 2744 | let monitor = toSpace.monitor; |
| 2745 | this.setMonitors(monitor, toSpace, true); |
| 2746 | |
| 2747 | this.forEach(s => s.setSpaceTopbarElementsVisible()); |
| 2748 | let doAnimate = animate || this.space_paperwmAnimation; |
| 2749 | this.animateToSpace( |
| 2750 | toSpace, |
| 2751 | fromSpace, |
| 2752 | doAnimate); |
| 2753 | |
| 2754 | // Update panel to handle target workspace |
| 2755 | signals.disconnect(Main.panel, this.touchSignal); |
| 2756 | this.touchSignal = signals.connect(Main.panel, "touch-event", Gestures.horizontalTouchScroll.bind(toSpace)); |
| 2757 | |
| 2758 | inPreview = PreviewMode.NONE; |
| 2759 | } |
no test coverage detected