add eye On Screen effect for showing desktop
resembles the homescreen effect on "eye" OS REVIEW: 122679
This commit is contained in:
parent
83a42c55be
commit
fb39fafc71
5 changed files with 187 additions and 0 deletions
|
@ -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 )
|
||||
|
|
1
effects/eyeonscreen/CMakeLists.txt
Normal file
1
effects/eyeonscreen/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
|||
add_subdirectory( package )
|
6
effects/eyeonscreen/package/CMakeLists.txt
Normal file
6
effects/eyeonscreen/package/CMakeLists.txt
Normal file
|
@ -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)
|
161
effects/eyeonscreen/package/contents/code/main.js
Normal file
161
effects/eyeonscreen/package/contents/code/main.js
Normal file
|
@ -0,0 +1,161 @@
|
|||
/********************************************************************
|
||||
KWin - the KDE window manager
|
||||
This file is part of the KDE project.
|
||||
|
||||
Copyright (C) 2015 Thomas Lübking <thomas.luebking@gmail.com>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
*********************************************************************/
|
||||
/*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();
|
18
effects/eyeonscreen/package/metadata.desktop
Normal file
18
effects/eyeonscreen/package/metadata.desktop
Normal file
|
@ -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
|
Loading…
Reference in a new issue