Skip to content

Commit

Permalink
FIX: for case where switchWorkspace by clicking link (which opens window
Browse files Browse the repository at this point in the history
in another space on another monitor) - if space is shown on that monitor
don't do gnome workspace switch animation.
  • Loading branch information
jtaala committed Jan 26, 2024
1 parent 6d97ef6 commit b7a926a
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,21 +140,47 @@ export function setupOverrides() {
// WorkspaceAnimation.WorkspaceAnimationController.animateSwitch
// Disable the workspace switching animation in Gnome 40+
function (_from, _to, _direction, onComplete) {
// ensure swipeTrackers are disabled after this
const reset = () => {
// gnome windows switch animation time = 250, do that plus a little more
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 300, () => {
swipeTrackers.forEach(t => {
t.enabled = false;
});
pillSwipeTimer = null;
return false; // on return false destroys timeout
});
};

if (Tiling.inPreview) {
onComplete();
reset();
return;
}

// if using PaperWM workspace switch animation, just do complete here
if (Tiling.inPreview || !Tiling.spaces.space_defaultAnimation) {
if (!Tiling.spaces.space_defaultAnimation) {
onComplete();
reset();
return;
}
else {
const saved = getSavedPrototype(WorkspaceAnimation.WorkspaceAnimationController, 'animateSwitch');
saved.call(this, _from, _to, _direction, onComplete);

// if switching to a paperwm space that is already shown on a monitor
// from / to are workspace indices
const toSpace = Tiling.spaces.spaceOfIndex(_to);

const spaces = Array.from(Tiling.spaces.monitors.values());
const toOnMonitor = spaces.some(space => space === toSpace);
if (toOnMonitor) {
onComplete();
reset();
return;
}

// ensure swipeTrackers are disabled after this
pillSwipeTimer = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, () => {
swipeTrackers.forEach(t => t.enabled = false);
pillSwipeTimer = null;
return false; // on return false destroys timeout
});
// standard gnome switch animation
const saved = getSavedPrototype(WorkspaceAnimation.WorkspaceAnimationController, 'animateSwitch');
saved.call(this, _from, _to, _direction, onComplete);
reset();
});

registerOverridePrototype(WorkspaceAnimation.WorkspaceAnimationController, '_prepareWorkspaceSwitch',
Expand Down

0 comments on commit b7a926a

Please sign in to comment.