From 36e0600df57c506de950f569eab2e4b91e5b6030 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Thu, 30 Apr 2020 00:30:52 -0400 Subject: [PATCH] Animate only peeked window workspace --- utils.js | 9 ++++----- windowPreview.js | 23 +++++++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/utils.js b/utils.js index 6372bb0..b07c6be 100644 --- a/utils.js +++ b/utils.js @@ -426,12 +426,11 @@ var activateSiblingWindow = function(windows, direction, startWindow) { }; var animateWindowOpacity = function(window, tweenOpts) { - //there is a mutter bug with the windowactor opacity, starting with 3.34 and ending with 3.36.1 + //there currently is a mutter bug with the windowactor opacity, starting with 3.34 //https://gitlab.gnome.org/GNOME/mutter/issues/836 - let shellVersion = Config.PACKAGE_VERSION; - if (shellVersion > '3.35' && shellVersion < '3.36.1') { - //on <= 3.36, a workaround is to use the windowactor's child for the fade animation + if (Config.PACKAGE_VERSION > '3.35') { + //on 3.36, a workaround is to use the windowactor's child for the fade animation //this leaves a "shadow" on the desktop, so the windowactor needs to be hidden //when the animation is complete let visible = tweenOpts.opacity > 0; @@ -443,7 +442,7 @@ var animateWindowOpacity = function(window, tweenOpts) { window = windowActor.get_first_child() || windowActor; tweenOpts.onComplete = () => windowActor.visible = visible; - } else if (shellVersion > '3.33' && shellVersion < '3.35') { + } else if (Config.PACKAGE_VERSION > '3.33') { //the workaround only works on 3.35+, so on 3.34, let's just hide the //window without animation return window.visible = (tweenOpts.opacity == 255); diff --git a/windowPreview.js b/windowPreview.js index 6a96ae1..86aa044 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -611,9 +611,10 @@ var PreviewMenu = Utils.defineClass({ this._timeoutsHandler.remove(T3); if (this._peekedWindow) { - this._restorePeekedWindowStack(); + let immediate = !stayHere && this.peekInitialWorkspaceIndex != Utils.getCurrentWorkspace().index(); - this._focusMetaWindow(255); + this._restorePeekedWindowStack(); + this._focusMetaWindow(255, this._peekedWindow, immediate); this._peekedWindow = null; if (!stayHere) { @@ -629,7 +630,7 @@ var PreviewMenu = Utils.defineClass({ let shouldAnimate = Main.wm._shouldAnimate; if (!workspace || (!workspace.list_windows().length && - workspaceIndex < Utils.getWorkspaceCount() -1)) { + workspaceIndex < Utils.getWorkspaceCount() - 1)) { workspace = Utils.getCurrentWorkspace(); } @@ -638,16 +639,16 @@ var PreviewMenu = Utils.defineClass({ Main.wm._shouldAnimate = shouldAnimate; }, - _focusMetaWindow: function(dimOpacity, window) { + _focusMetaWindow: function(dimOpacity, window, immediate) { if (Main.overview.visibleTarget) { return; } - global.get_window_actors().forEach(wa => { - let mw = wa.meta_window; + window.get_workspace().list_windows().forEach(mw => { + let wa = mw.get_compositor_private(); let isFocused = mw == window; - if (mw) { + if (wa) { if (isFocused) { mw[PEEK_INDEX_PROP] = wa.get_parent().get_children().indexOf(wa); wa.get_parent().set_child_above_sibling(wa, null); @@ -658,7 +659,13 @@ var PreviewMenu = Utils.defineClass({ } if (!mw.minimized) { - Utils.animateWindowOpacity(wa, getTweenOpts({ opacity: isFocused ? 255 : dimOpacity })); + let tweenOpts = getTweenOpts({ opacity: isFocused ? 255 : dimOpacity }); + + if (immediate && !mw.is_on_all_workspaces()) { + tweenOpts.time = 0; + } + + Utils.animateWindowOpacity(wa, tweenOpts); } } });