Changeset View
Changeset View
Standalone View
Standalone View
effects/frozenapp/package/contents/code/main.js
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | ||||
3 | This file is part of the KDE project. | ||||
4 | | ||||
5 | Copyright (C) 2017 Kai Uwe Broulik <kde@privat.broulik.de> | ||||
6 | | ||||
7 | This program is free software; you can redistribute it and/or modify | ||||
8 | it under the terms of the GNU General Public License as published by | ||||
9 | the Free Software Foundation; either version 2 of the License, or | ||||
10 | (at your option) any later version. | ||||
11 | | ||||
12 | This program is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | GNU General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU General Public License | ||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | *********************************************************************/ | ||||
20 | /*global effect, effects, animate, animationTime, Effect*/ | ||||
21 | var frozenAppEffect = { | ||||
22 | inDuration: animationTime(1500), | ||||
23 | outDuration: animationTime(250), | ||||
24 | loadConfig: function () { | ||||
25 | "use strict"; | ||||
26 | frozenAppEffect.inDuration = animationTime(1500); | ||||
27 | frozenAppEffect.outDuration = animationTime(250); | ||||
28 | }, | ||||
29 | unresponsiveChanged: function (window, unresponsive) { | ||||
30 | "use strict"; | ||||
31 | | ||||
32 | if (unresponsive) { | ||||
33 | frozenAppEffect.appFroze(window); | ||||
34 | } else { | ||||
35 | frozenAppEffect.appUnfroze(window); | ||||
36 | } | ||||
37 | }, | ||||
38 | appFroze: function (window) { | ||||
39 | "use strict"; | ||||
40 | | ||||
41 | if (window.pingAnimation) { | ||||
42 | return; | ||||
43 | } | ||||
44 | | ||||
45 | window.pingAnimation = set({ | ||||
46 | window: window, | ||||
47 | duration: frozenAppEffect.inDuration, | ||||
48 | animations: [{ | ||||
49 | type: Effect.Saturation, | ||||
50 | to: 0.1 | ||||
51 | }, { | ||||
52 | type: Effect.Brightness, | ||||
53 | to: 1.25 | ||||
54 | }] | ||||
55 | }); | ||||
56 | }, | ||||
57 | appUnfroze: function (window) { | ||||
58 | "use strict"; | ||||
59 | | ||||
60 | if (!window.pingAnimation) { | ||||
61 | return; | ||||
62 | } | ||||
63 | | ||||
64 | cancel(window.pingAnimation); | ||||
65 | window.pingAnimation = undefined; | ||||
66 | | ||||
67 | animate({ | ||||
68 | window: window, | ||||
69 | duration: frozenAppEffect.outDuration, | ||||
70 | animations: [{ | ||||
71 | type: Effect.Saturation, | ||||
72 | from: 0.1, | ||||
73 | to: 1.0 | ||||
74 | }, { | ||||
75 | type: Effect.Brightness, | ||||
76 | from: 1.25, | ||||
77 | to: 1.0 | ||||
78 | }] | ||||
79 | }); | ||||
80 | }, | ||||
81 | windowClosed: function (window) { | ||||
82 | "use strict"; | ||||
83 | frozenAppEffect.appUnfroze(window); | ||||
84 | }, | ||||
85 | init: function () { | ||||
86 | "use strict"; | ||||
87 | effect.configChanged.connect(frozenAppEffect.loadConfig); | ||||
88 | effects.windowUnresponsiveChanged.connect(frozenAppEffect.unresponsiveChanged); | ||||
89 | effects.windowClosed.connect(frozenAppEffect.windowClosed); | ||||
90 | } | ||||
91 | }; | ||||
92 | frozenAppEffect.init(); |