File indexing completed on 2024-06-23 05:25:47
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2015 Thomas Lübking <thomas.luebking@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 /*global effect, effects, animate, animationTime, Effect, QEasingCurve */ 0010 0011 "use strict"; 0012 0013 var eyeOnScreenEffect = { 0014 duration: animationTime(250), 0015 loadConfig: function () { 0016 eyeOnScreenEffect.duration = animationTime(250); 0017 }, 0018 slurp: function (showing) { 0019 var stackingOrder = effects.stackingOrder; 0020 for (var i = 0; i < stackingOrder.length; ++i) { 0021 var w = stackingOrder[i]; 0022 if (!w.visible || !(showing || w.slurpedByEyeOnScreen)) { 0023 continue; 0024 } 0025 const screenGeo = w.screen.geometry; 0026 const center = { value1: screenGeo.x + screenGeo.width / 2, 0027 value2: screenGeo.y + screenGeo.height / 2 }; 0028 w.slurpedByEyeOnScreen = showing; 0029 if (w.desktopWindow) { 0030 // causes "seizures" because of opposing movements 0031 // var zoom = showing ? 0.8 : 1.2; 0032 var zoom = 0.8; 0033 w.eyeOnScreenShowsDesktop = showing; 0034 animate({ 0035 window: w, 0036 duration: 2*eyeOnScreenEffect.duration, // "*2 for "bumper" transition 0037 animations: [{ 0038 type: Effect.Scale, 0039 curve: Effect.GaussianCurve, 0040 to: zoom 0041 }, { 0042 type: Effect.Opacity, 0043 curve: Effect.GaussianCurve, 0044 to: 0.0 0045 }] 0046 }); 0047 } else { 0048 if (showing) { 0049 animate({ 0050 window: w, 0051 animations: [{ 0052 type: Effect.Scale, 0053 curve: QEasingCurve.InCubic, 0054 duration: eyeOnScreenEffect.duration, 0055 to: 0.0 0056 }, { 0057 type: Effect.Position, 0058 curve: QEasingCurve.InCubic, 0059 duration: eyeOnScreenEffect.duration, 0060 to: center 0061 }, { 0062 type: Effect.Opacity, 0063 curve: QEasingCurve.InCubic, 0064 duration: eyeOnScreenEffect.duration, 0065 to: 0.0 0066 }] 0067 }); 0068 } else { 0069 animate({ 0070 window: w, 0071 duration: eyeOnScreenEffect.duration, 0072 delay: eyeOnScreenEffect.duration, 0073 animations: [{ 0074 type: Effect.Scale, 0075 curve: QEasingCurve.OutCubic, 0076 from: 0.0 0077 }, { 0078 type: Effect.Position, 0079 curve: QEasingCurve.OutCubic, 0080 from: center 0081 }, { 0082 type: Effect.Opacity, 0083 curve: QEasingCurve.OutCubic, 0084 from: 0.0 0085 }] 0086 }); 0087 } 0088 } 0089 } 0090 }, 0091 init: function () { 0092 eyeOnScreenEffect.loadConfig(); 0093 effects.showingDesktopChanged.connect(eyeOnScreenEffect.slurp); 0094 } 0095 }; 0096 0097 eyeOnScreenEffect.init();