diff --git a/effects/CMakeLists.txt b/effects/CMakeLists.txt index 1d802a66e2..3e88bfa754 100644 --- a/effects/CMakeLists.txt +++ b/effects/CMakeLists.txt @@ -131,6 +131,7 @@ kconfig_add_kcfg_files(kwin4_effect_builtins_sources # scripted effects add_subdirectory( dialogparent ) +add_subdirectory( eyeonscreen ) add_subdirectory( fade ) add_subdirectory( fadedesktop ) add_subdirectory( login ) diff --git a/effects/eyeonscreen/CMakeLists.txt b/effects/eyeonscreen/CMakeLists.txt new file mode 100644 index 0000000000..28f40b3371 --- /dev/null +++ b/effects/eyeonscreen/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory( package ) diff --git a/effects/eyeonscreen/package/CMakeLists.txt b/effects/eyeonscreen/package/CMakeLists.txt new file mode 100644 index 0000000000..37dc0c7d2f --- /dev/null +++ b/effects/eyeonscreen/package/CMakeLists.txt @@ -0,0 +1,6 @@ +install(DIRECTORY contents DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_eyeonscreen) +install(FILES metadata.desktop DESTINATION ${DATA_INSTALL_DIR}/${KWIN_NAME}/effects/kwin4_effect_eyeonscreen) + +install(FILES metadata.desktop + DESTINATION ${SERVICES_INSTALL_DIR}/${KWIN_NAME} + RENAME kwin4_effect_eyeonscreen.desktop) diff --git a/effects/eyeonscreen/package/contents/code/main.js b/effects/eyeonscreen/package/contents/code/main.js new file mode 100644 index 0000000000..aec450eec7 --- /dev/null +++ b/effects/eyeonscreen/package/contents/code/main.js @@ -0,0 +1,161 @@ +/******************************************************************** + KWin - the KDE window manager + This file is part of the KDE project. + + Copyright (C) 2015 Thomas Lübking + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ +/*global effect, effects, animate, animationTime, Effect, QEasingCurve */ + +var eyeOnScreenEffect = { + duration: animationTime(250), + loadConfig: function () { + "use strict"; + eyeOnScreenEffect.duration = animationTime(250); + }, + delevateWindow: function(window) { + "use strict"; + if (window.desktopWindow) { + if (window.eyeOnScreenShowsDesktop) { + window.eyeOnScreenShowsDesktop = false; + var stackingOrder = effects.stackingOrder; + for (var i = 0; i < stackingOrder.length; ++i) { + var w = stackingOrder[i]; + if (w.eyeOnScreenOpacityKeeper === undefined) + continue; + cancel(w.eyeOnScreenOpacityKeeper); + delete w.eyeOnScreenOpacityKeeper; + } + } + } else if (window.elevatedByEyeOnScreen) { + effects.setElevatedWindow(window, false); + window.elevatedByEyeOnScreen = false; + } + }, + slurp: function (showing) { + "use strict"; + var stackingOrder = effects.stackingOrder; + var screenGeo = effects.virtualScreenGeometry; + var center = { value1: screenGeo.x + screenGeo.width/2, + value2: screenGeo.y + screenGeo.height/2 }; + for (var i = 0; i < stackingOrder.length; ++i) { + var w = stackingOrder[i]; + if (!w.visible || !(showing || w.slurpedByEyeOnScreen)) { + continue; + } + w.slurpedByEyeOnScreen = showing; + if (w.desktopWindow) { + // causes "seizures" because of opposing movements + // var zoom = showing ? 0.8 : 1.2; + var zoom = 0.8; + w.eyeOnScreenShowsDesktop = showing; + animate({ + window: w, + duration: 2*eyeOnScreenEffect.duration, // "*2 for "bumper" transition + animations: [{ + type: Effect.Scale, + curve: Effect.GaussianCurve, + to: zoom + }, { + type: Effect.Opacity, + curve: Effect.GaussianCurve, + to: 0.0 + }] + }); + if (showing) // (when not showing, pretty much everything would be above) + break; // ignore windows above the desktop + } else { + effects.setElevatedWindow(w, showing); + if (showing) { + w.elevatedByEyeOnScreen = true; + if (w.dock) { + animate({ + // this is a HACK - we need to trigger an animationEnded to delevate the dock in time, or it'll flicker :-( + // TODO? "var timer = new QTimer;" causes an error in effect scripts + window: w, + animations: [{ + type: Effect.Opacity, + curve: QEasingCurve.Linear, + duration: eyeOnScreenEffect.duration, + to: 0.9 + }] + }); + } else { + animate({ + window: w, + animations: [{ + type: Effect.Scale, + curve: QEasingCurve.InCubic, + duration: eyeOnScreenEffect.duration, + to: 0.0 + }, { + type: Effect.Position, + curve: QEasingCurve.InCubic, + duration: eyeOnScreenEffect.duration, + to: center + }] + }); + } + w.eyeOnScreenOpacityKeeper = set({ + window: w, + animations: [{ + type: Effect.Opacity, + curve: QEasingCurve.InCubic, + duration: eyeOnScreenEffect.duration, + to: 0.0 + }] + }); + } else { + w.elevatedByEyeOnScreen = false; + if (!w.dock) { + animate({ + window: w, + duration: eyeOnScreenEffect.duration, + delay: eyeOnScreenEffect.duration, + animations: [{ + type: Effect.Scale, + curve: QEasingCurve.OutCubic, + from: 0.0 + }, { + type: Effect.Position, + curve: QEasingCurve.OutCubic, + from: center + }] + }); + } + animate({ + window: w, + duration: eyeOnScreenEffect.duration, + delay: eyeOnScreenEffect.duration, + animations: [{ + type: Effect.Opacity, + curve: QEasingCurve.OutCubic, + duration: eyeOnScreenEffect.duration, + from: 0.0 + }] + }); + } + } + } + }, + init: function () { + "use strict"; + eyeOnScreenEffect.loadConfig(); + effects.showingDesktopChanged.connect(eyeOnScreenEffect.slurp); + effect.animationEnded.connect(eyeOnScreenEffect.delevateWindow); + } +}; + +eyeOnScreenEffect.init(); \ No newline at end of file diff --git a/effects/eyeonscreen/package/metadata.desktop b/effects/eyeonscreen/package/metadata.desktop new file mode 100644 index 0000000000..5da317c873 --- /dev/null +++ b/effects/eyeonscreen/package/metadata.desktop @@ -0,0 +1,18 @@ +[Desktop Entry] +Name=eye On Screen +Icon=preferences-system-windows-effect-eyeonscreen +Comment=Suck windows into desktop to show the latter. This might remind you of something. + +Type=Service +X-Plasma-API=javascript +X-Plasma-MainScript=code/main.js +X-KDE-ServiceTypes=KWin/Effect +X-KDE-PluginInfo-Author=Thomas Lübking +X-KDE-PluginInfo-Email=thomas.luebking@gmail.com +X-KDE-PluginInfo-Name=kwin4_effect_eyeonscreen +X-KDE-PluginInfo-Version=0.1.0 +X-KDE-PluginInfo-Category=Appearance +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +X-KDE-Ordering=50