@@ -140,21 +140,47 @@ export function setupOverrides() {
140140 // WorkspaceAnimation.WorkspaceAnimationController.animateSwitch
141141 // Disable the workspace switching animation in Gnome 40+
142142 function ( _from , _to , _direction , onComplete ) {
143+ // ensure swipeTrackers are disabled after this
144+ const reset = ( ) => {
145+ // gnome windows switch animation time = 250, do that plus a little more
146+ pillSwipeTimer = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 300 , ( ) => {
147+ swipeTrackers . forEach ( t => {
148+ t . enabled = false ;
149+ } ) ;
150+ pillSwipeTimer = null ;
151+ return false ; // on return false destroys timeout
152+ } ) ;
153+ } ;
154+
155+ if ( Tiling . inPreview ) {
156+ onComplete ( ) ;
157+ reset ( ) ;
158+ return ;
159+ }
160+
143161 // if using PaperWM workspace switch animation, just do complete here
144- if ( Tiling . inPreview || ! Tiling . spaces . space_defaultAnimation ) {
162+ if ( ! Tiling . spaces . space_defaultAnimation ) {
145163 onComplete ( ) ;
164+ reset ( ) ;
165+ return ;
146166 }
147- else {
148- const saved = getSavedPrototype ( WorkspaceAnimation . WorkspaceAnimationController , 'animateSwitch' ) ;
149- saved . call ( this , _from , _to , _direction , onComplete ) ;
167+
168+ // if switching to a paperwm space that is already shown on a monitor
169+ // from / to are workspace indices
170+ const toSpace = Tiling . spaces . spaceOfIndex ( _to ) ;
171+
172+ const spaces = Array . from ( Tiling . spaces . monitors . values ( ) ) ;
173+ const toOnMonitor = spaces . some ( space => space === toSpace ) ;
174+ if ( toOnMonitor ) {
175+ onComplete ( ) ;
176+ reset ( ) ;
177+ return ;
150178 }
151179
152- // ensure swipeTrackers are disabled after this
153- pillSwipeTimer = GLib . timeout_add ( GLib . PRIORITY_DEFAULT , 500 , ( ) => {
154- swipeTrackers . forEach ( t => t . enabled = false ) ;
155- pillSwipeTimer = null ;
156- return false ; // on return false destroys timeout
157- } ) ;
180+ // standard gnome switch animation
181+ const saved = getSavedPrototype ( WorkspaceAnimation . WorkspaceAnimationController , 'animateSwitch' ) ;
182+ saved . call ( this , _from , _to , _direction , onComplete ) ;
183+ reset ( ) ;
158184 } ) ;
159185
160186 registerOverridePrototype ( WorkspaceAnimation . WorkspaceAnimationController , '_prepareWorkspaceSwitch' ,
0 commit comments