# Changeset View

Changeset View

# Standalone View

Standalone View

# effects/frozenapp/package/contents/code/main.js

Show All 11 Lines | |||||

12 | This program is distributed in the hope that it will be useful, | 12 | This program is distributed in the hope that it will be useful, | ||

13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||

14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||

15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||

16 | 16 | | |||

17 | You should have received a copy of the GNU General Public License | 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/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||

19 | *********************************************************************/ | 19 | *********************************************************************/ | ||

20 | /*global effect, effects, animate, animationTime, Effect*/ | 20 | | ||

21 | "use strict"; | ||||

22 | | ||||

21 | var frozenAppEffect = { | 23 | var frozenAppEffect = { | ||

22 | inDuration: animationTime(1500), | 24 | inDuration: animationTime(1500), | ||

23 | outDuration: animationTime(250), | 25 | outDuration: animationTime(250), | ||

24 | loadConfig: function () { | 26 | loadConfig: function () { | ||

25 | "use strict"; | | |||

26 | frozenAppEffect.inDuration = animationTime(1500); | 27 | frozenAppEffect.inDuration = animationTime(1500); | ||

27 | frozenAppEffect.outDuration = animationTime(250); | 28 | frozenAppEffect.outDuration = animationTime(250); | ||

28 | }, | 29 | }, | ||

29 | windowAdded: function (window) { | 30 | windowAdded: function (window) { | ||

30 | "use strict"; | | |||

31 | if (!window || !window.unresponsive) { | 31 | if (!window || !window.unresponsive) { | ||

32 | return; | 32 | return; | ||

33 | } | 33 | } | ||

34 | frozenAppEffect.windowBecameUnresponsive(window); | 34 | frozenAppEffect.windowBecameUnresponsive(window); | ||

35 | }, | 35 | }, | ||

36 | windowBecameUnresponsive: function (window) { | 36 | windowBecameUnresponsive: function (window) { | ||

37 | "use strict"; | | |||

38 | if (window.unresponsiveAnimation) { | 37 | if (window.unresponsiveAnimation) { | ||

39 | return; | 38 | return; | ||

40 | } | 39 | } | ||

41 | frozenAppEffect.startAnimation(window, frozenAppEffect.inDuration); | 40 | frozenAppEffect.startAnimation(window, frozenAppEffect.inDuration); | ||

42 | }, | 41 | }, | ||

43 | startAnimation: function (window, duration) { | 42 | startAnimation: function (window, duration) { | ||

44 | "use strict"; | | |||

45 | if (!window.visible) { | 43 | if (!window.visible) { | ||

46 | return; | 44 | return; | ||

47 | } | 45 | } | ||

48 | window.unresponsiveAnimation = set({ | 46 | window.unresponsiveAnimation = set({ | ||

49 | window: window, | 47 | window: window, | ||

50 | duration: duration, | 48 | duration: duration, | ||

51 | animations: [{ | 49 | animations: [{ | ||

52 | type: Effect.Saturation, | 50 | type: Effect.Saturation, | ||

53 | to: 0.1 | 51 | to: 0.1 | ||

54 | }, { | 52 | }, { | ||

55 | type: Effect.Brightness, | 53 | type: Effect.Brightness, | ||

56 | to: 1.5 | 54 | to: 1.5 | ||

57 | }] | 55 | }] | ||

58 | }); | 56 | }); | ||

59 | }, | 57 | }, | ||

60 | windowClosed: function (window) { | 58 | windowClosed: function (window) { | ||

61 | "use strict"; | | |||

62 | frozenAppEffect.cancelAnimation(window); | 59 | frozenAppEffect.cancelAnimation(window); | ||

63 | if (!window.unresponsive) { | 60 | if (!window.unresponsive) { | ||

64 | return; | 61 | return; | ||

65 | } | 62 | } | ||

66 | frozenAppEffect.windowBecameResponsive(window); | 63 | frozenAppEffect.windowBecameResponsive(window); | ||

67 | }, | 64 | }, | ||

68 | windowBecameResponsive: function (window) { | 65 | windowBecameResponsive: function (window) { | ||

69 | "use strict"; | | |||

70 | if (!window.unresponsiveAnimation) { | 66 | if (!window.unresponsiveAnimation) { | ||

71 | return; | 67 | return; | ||

72 | } | 68 | } | ||

73 | cancel(window.unresponsiveAnimation); | 69 | cancel(window.unresponsiveAnimation); | ||

74 | window.unresponsiveAnimation = undefined; | 70 | window.unresponsiveAnimation = undefined; | ||

75 | 71 | | |||

76 | animate({ | 72 | animate({ | ||

77 | window: window, | 73 | window: window, | ||

78 | duration: frozenAppEffect.outDuration, | 74 | duration: frozenAppEffect.outDuration, | ||

79 | animations: [{ | 75 | animations: [{ | ||

80 | type: Effect.Saturation, | 76 | type: Effect.Saturation, | ||

81 | from: 0.1, | 77 | from: 0.1, | ||

82 | to: 1.0 | 78 | to: 1.0 | ||

83 | }, { | 79 | }, { | ||

84 | type: Effect.Brightness, | 80 | type: Effect.Brightness, | ||

85 | from: 1.5, | 81 | from: 1.5, | ||

86 | to: 1.0 | 82 | to: 1.0 | ||

87 | }] | 83 | }] | ||

88 | }); | 84 | }); | ||

89 | }, | 85 | }, | ||

90 | cancelAnimation: function (window) { | 86 | cancelAnimation: function (window) { | ||

91 | "use strict"; | | |||

92 | if (window.unresponsiveAnimation) { | 87 | if (window.unresponsiveAnimation) { | ||

93 | cancel(window.unresponsiveAnimation); | 88 | cancel(window.unresponsiveAnimation); | ||

94 | window.unresponsiveAnimation = undefined; | 89 | window.unresponsiveAnimation = undefined; | ||

95 | } | 90 | } | ||

96 | }, | 91 | }, | ||

97 | desktopChanged: function () { | 92 | desktopChanged: function () { | ||

98 | "use strict"; | | |||

99 | | ||||

100 | var windows = effects.stackingOrder; | 93 | var windows = effects.stackingOrder; | ||

101 | for (var i = 0, length = windows.length; i < length; ++i) { | 94 | for (var i = 0, length = windows.length; i < length; ++i) { | ||

102 | var window = windows[i]; | 95 | var window = windows[i]; | ||

103 | frozenAppEffect.cancelAnimation(window); | 96 | frozenAppEffect.cancelAnimation(window); | ||

104 | frozenAppEffect.restartAnimation(window); | 97 | frozenAppEffect.restartAnimation(window); | ||

105 | } | 98 | } | ||

106 | }, | 99 | }, | ||

107 | unresponsiveChanged: function (window) { | 100 | unresponsiveChanged: function (window) { | ||

108 | "use strict"; | | |||

109 | if (window.unresponsive) { | 101 | if (window.unresponsive) { | ||

110 | frozenAppEffect.windowBecameUnresponsive(window); | 102 | frozenAppEffect.windowBecameUnresponsive(window); | ||

111 | } else { | 103 | } else { | ||

112 | frozenAppEffect.windowBecameResponsive(window); | 104 | frozenAppEffect.windowBecameResponsive(window); | ||

113 | } | 105 | } | ||

114 | }, | 106 | }, | ||

115 | restartAnimation: function (window) { | 107 | restartAnimation: function (window) { | ||

116 | "use strict"; | | |||

117 | if (!window || !window.unresponsive) { | 108 | if (!window || !window.unresponsive) { | ||

118 | return; | 109 | return; | ||

119 | } | 110 | } | ||

120 | frozenAppEffect.startAnimation(window, 1); | 111 | frozenAppEffect.startAnimation(window, 1); | ||

121 | }, | 112 | }, | ||

122 | init: function () { | 113 | init: function () { | ||

123 | "use strict"; | | |||

124 | | ||||

125 | effects.windowAdded.connect(frozenAppEffect.windowAdded); | 114 | effects.windowAdded.connect(frozenAppEffect.windowAdded); | ||

126 | effects.windowClosed.connect(frozenAppEffect.windowClosed); | 115 | effects.windowClosed.connect(frozenAppEffect.windowClosed); | ||

127 | effects.windowMinimized.connect(frozenAppEffect.cancelAnimation); | 116 | effects.windowMinimized.connect(frozenAppEffect.cancelAnimation); | ||

128 | effects.windowUnminimized.connect(frozenAppEffect.restartAnimation); | 117 | effects.windowUnminimized.connect(frozenAppEffect.restartAnimation); | ||

129 | effects.windowUnresponsiveChanged.connect(frozenAppEffect.unresponsiveChanged); | 118 | effects.windowUnresponsiveChanged.connect(frozenAppEffect.unresponsiveChanged); | ||

130 | effects['desktopChanged(int,int)'].connect(frozenAppEffect.desktopChanged); | 119 | effects['desktopChanged(int,int)'].connect(frozenAppEffect.desktopChanged); | ||

131 | effects.desktopPresenceChanged.connect(frozenAppEffect.cancelAnimation); | 120 | effects.desktopPresenceChanged.connect(frozenAppEffect.cancelAnimation); | ||

132 | effects.desktopPresenceChanged.connect(frozenAppEffect.restartAnimation); | 121 | effects.desktopPresenceChanged.connect(frozenAppEffect.restartAnimation); | ||

133 | 122 | | |||

134 | var windows = effects.stackingOrder; | 123 | var windows = effects.stackingOrder; | ||

135 | for (var i = 0, length = windows.length; i < length; ++i) { | 124 | for (var i = 0, length = windows.length; i < length; ++i) { | ||

136 | frozenAppEffect.restartAnimation(windows[i]); | 125 | frozenAppEffect.restartAnimation(windows[i]); | ||

137 | } | 126 | } | ||

138 | } | 127 | } | ||

139 | }; | 128 | }; | ||

140 | frozenAppEffect.init(); | 129 | frozenAppEffect.init(); |