diff --git a/panel.js b/panel.js index 7496cff..df63883 100644 --- a/panel.js +++ b/panel.js @@ -991,22 +991,13 @@ var dtpPanel = Utils.defineClass({ }, _toggleWorkspaceWindows: function(hide, workspace) { - let toggleFunc = w => { - Tweener.addTween(w.get_compositor_private(), { - opacity: hide ? 0 : 255, - time: Me.settings.get_int('show-showdesktop-time') * .001, - transition: 'easeOutQuad' - }); + let tweenOpts = { + opacity: hide ? 0 : 255, + time: Me.settings.get_int('show-showdesktop-time') * .001, + transition: 'easeOutQuad' }; - //there currently is a mutter bug with the windows opacity on 3.34, so - //until it is fixed, immediately hide the windows instead of fading them - //https://gitlab.gnome.org/GNOME/mutter/issues/836 - if (Config.PACKAGE_VERSION > '3.33') { - toggleFunc = w => w.get_compositor_private().visible = !hide; - } - - workspace.list_windows().forEach(toggleFunc); + workspace.list_windows().forEach(w => Utils.animateWindowOpacity(w.get_compositor_private(), tweenOpts)); }, _onShowDesktopButtonPress: function() { diff --git a/utils.js b/utils.js index 436f960..2af1172 100644 --- a/utils.js +++ b/utils.js @@ -22,6 +22,7 @@ */ const Clutter = imports.gi.Clutter; +const Config = imports.misc.config; const GdkPixbuf = imports.gi.GdkPixbuf const Gi = imports._gi; const Gio = imports.gi.Gio; @@ -42,7 +43,7 @@ var SCROLL_TIME = Util.SCROLL_TIME / (Util.SCROLL_TIME > 1 ? 1000 : 1); var defineClass = function (classDef) { let parentProto = classDef.Extends ? classDef.Extends.prototype : null; - if (imports.misc.config.PACKAGE_VERSION < '3.31.9') { + if (Config.PACKAGE_VERSION < '3.31.9') { if (parentProto && (classDef.Extends.name || classDef.Extends.toString()).indexOf('DashToPanel.') < 0) { classDef.callParent = function() { let args = Array.prototype.slice.call(arguments); @@ -287,14 +288,6 @@ var getWorkspaceCount = function() { return DisplayWrapper.getWorkspaceManager().n_workspaces; }; -var checkIfWindowHasTransient = function(window) { - let hasTransient; - - window.foreach_transient(t => !(hasTransient = true)); - - return hasTransient; -}; - var findIndex = function(array, predicate) { if (Array.prototype.findIndex) { return array.findIndex(predicate); @@ -401,6 +394,14 @@ var getMouseScrollDirection = function(event) { return direction; }; +var checkIfWindowHasTransient = function(window) { + let hasTransient; + + window.foreach_transient(t => !(hasTransient = true)); + + return hasTransient; +}; + var activateSiblingWindow = function(windows, direction, startWindow) { let windowIndex = windows.indexOf(global.display.focus_window); let nextWindowIndex = windowIndex < 0 ? @@ -418,6 +419,17 @@ var activateSiblingWindow = function(windows, direction, startWindow) { } }; +var animateWindowOpacity = function(window, tweenOpts) { + //there currently is a mutter bug with the windows opacity on 3.34, so + //until it is fixed, immediately hide the windows instead of fading them + //https://gitlab.gnome.org/GNOME/mutter/issues/836 + if (Config.PACKAGE_VERSION > '3.33') { + window.visible = (tweenOpts.opacity == 255); + } else { + Tweener.addTween(window, tweenOpts); + } +}; + var notify = function(text, iconName, action, isTransient) { let source = new MessageTray.SystemNotificationSource(); let notification = new MessageTray.Notification(source, 'Dash to Panel', text); diff --git a/windowPreview.js b/windowPreview.js index 7752923..5e87aa4 100644 --- a/windowPreview.js +++ b/windowPreview.js @@ -652,7 +652,7 @@ var PreviewMenu = Utils.defineClass({ wa.show(); } - Tweener.addTween(wa, getTweenOpts({ opacity: isFocused ? 255 : dimOpacity })); + Utils.animateWindowOpacity(wa, getTweenOpts({ opacity: isFocused ? 255 : dimOpacity })); } }); },