Changeset View
Changeset View
Standalone View
Standalone View
effects/scalein/package/contents/code/main.js
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2013 Kai Uwe Broulik <kde@privat.broulik.de> | 5 | Copyright (C) 2013 Kai Uwe Broulik <kde@privat.broulik.de> | ||
6 | Copyright (C) 2018 Vlad Zagorodniy <vladzzag@gmail.com> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | 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 | 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 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 16 | GNU General Public License for more details. | ||
16 | 17 | | |||
17 | You should have received a copy of the GNU General Public License | 18 | 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 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 20 | *********************************************************************/ | ||
20 | /*global effect, effects, animate, animationTime, Effect, QEasingCurve */ | 21 | | ||
22 | var blacklist = [ | ||||
23 | "ksmserver ksmserver", | ||||
24 | "ksplashx ksplashx", | ||||
25 | "ksplashsimple ksplashsimple", | ||||
26 | "ksplashqml ksplashqml" | ||||
27 | ]; | ||||
28 | | ||||
21 | var scaleInEffect = { | 29 | var scaleInEffect = { | ||
22 | duration: animationTime(150), | 30 | duration: animationTime(160), | ||
23 | loadConfig: function () { | 31 | loadConfig: function () { | ||
24 | "use strict"; | 32 | "use strict"; | ||
25 | scaleInEffect.duration = animationTime(150); | 33 | scaleInEffect.duration = animationTime(160); | ||
26 | }, | 34 | }, | ||
27 | isScaleWindow: function (window) { | 35 | isScaleWindow: function (window) { | ||
28 | "use strict"; | 36 | "use strict"; | ||
29 | if (window.popupMenu || window.specialWindow || window.utility || window.minimized || | 37 | if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) { | ||
30 | effect.isGrabbed(window, Effect.WindowAddedGrabRole)) { | 38 | return false; | ||
39 | } | ||||
40 | if (blacklist.indexOf(window.windowClass) != -1) { | ||||
31 | return false; | 41 | return false; | ||
32 | } | 42 | } | ||
33 | return true; | 43 | return !window.minimized | ||
44 | && !window.popupMenu | ||||
45 | && !window.specialWindow | ||||
46 | && !window.utility; | ||||
34 | }, | 47 | }, | ||
35 | scaleIn: function (window) { | 48 | startAnimation: function (window) { | ||
36 | "use strict"; | 49 | "use strict"; | ||
50 | if (!scaleInEffect.isScaleWindow(window)) { | ||||
51 | return; | ||||
52 | } | ||||
53 | effect.grab(window, Effect.WindowAddedGrabRole); | ||||
37 | window.scaleInWindowTypeAnimation = animate({ | 54 | window.scaleInWindowTypeAnimation = animate({ | ||
38 | window: window, | 55 | window: window, | ||
39 | duration: scaleInEffect.duration, | 56 | duration: scaleInEffect.duration, | ||
40 | curve: QEasingCurve.InOutQuad, | 57 | curve: QEasingCurve.InOutQuad, | ||
41 | animations: [{ | 58 | animations: [{ | ||
42 | type: Effect.Opacity, | 59 | type: Effect.Opacity, | ||
43 | from: 0.0, | 60 | from: 0.3, | ||
44 | to: 1.0 | 61 | to: 1.0 | ||
45 | }, { | 62 | }, { | ||
46 | type: Effect.Scale, | 63 | type: Effect.Scale, | ||
47 | from: 0.75, | 64 | from: 0.96, | ||
48 | to: 1.0 | 65 | to: 1.0 | ||
49 | }] | 66 | }] | ||
50 | }); | 67 | }); | ||
51 | }, | 68 | }, | ||
52 | added: function (window) { | 69 | cancelAnimation: function (window) { | ||
53 | "use strict"; | 70 | "use strict"; | ||
54 | if (!scaleInEffect.isScaleWindow(window)) { | | |||
55 | return; | | |||
56 | } | | |||
57 | scaleInEffect.scaleIn(window); | | |||
58 | }, | | |||
59 | dataChanged: function (window, role) { | | |||
60 | "use strict"; | | |||
61 | if (role == Effect.WindowAddedGrabRole) { | | |||
62 | if (effect.isGrabbed(window, Effect.WindowAddedGrabRole)) { | | |||
63 | if (window.scaleInWindowTypeAnimation !== undefined) { | 71 | if (window.scaleInWindowTypeAnimation !== undefined) { | ||
64 | cancel(window.scaleInWindowTypeAnimation); | 72 | cancel(window.scaleInWindowTypeAnimation); | ||
65 | window.scaleInWindowTypeAnimation = undefined; | 73 | window.scaleInWindowTypeAnimation = undefined; | ||
66 | } | 74 | } | ||
75 | }, | ||||
76 | windowDataChanged: function (window, role) { | ||||
77 | "use strict"; | ||||
78 | if (role != Effect.WindowAddedGrabRole) { | ||||
79 | return; | ||||
67 | } | 80 | } | ||
81 | if (!effect.isGrabbed(window, Effect.WindowAddedGrabRole)) { | ||||
82 | return; | ||||
68 | } | 83 | } | ||
84 | scaleInEffect.cancelAnimation(window); | ||||
69 | }, | 85 | }, | ||
70 | init: function () { | 86 | init: function () { | ||
71 | "use strict"; | 87 | "use strict"; | ||
72 | effect.configChanged.connect(scaleInEffect.loadConfig); | 88 | effect.configChanged.connect(scaleInEffect.loadConfig); | ||
73 | effects.windowAdded.connect(scaleInEffect.added); | 89 | effects.windowAdded.connect(scaleInEffect.startAnimation); | ||
74 | effects.windowDataChanged.connect(scaleInEffect.dataChanged); | 90 | effects.windowClosed.connect(scaleInEffect.cancelAnimation); | ||
91 | effects.windowDataChanged.connect(scaleInEffect.windowDataChanged); | ||||
75 | } | 92 | } | ||
76 | }; | 93 | }; | ||
94 | | ||||
77 | scaleInEffect.init(); | 95 | scaleInEffect.init(); |