-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
106 lines (89 loc) · 3.27 KB
/
extension.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/* extension.js
*
* 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/>.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* exported init */
const Background = imports.ui.background.Background;
const BackgroundManager = imports.ui.background.BackgroundManager;
var _Background_destroy = Background.prototype._destroy;
var _BackgroundManager_swapBackgroundActor = BackgroundManager.prototype._swapBackgroundActor;
const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const Tweener = imports.ui.tweener;
var FADE_ANIMATION_TIME = 1.0;
var debug = true;
function log(msg) {
if (debug)
print("bionichotpatch extension " + msg); // disable to keep the noise down in journal
}
class Extension {
constructor() {
}
enable() {
if (Convenience.currentVersionSmaller('3.33.3')) {
log('enabled');
Background.prototype._destroy = patched_background_destroy;
BackgroundManager.prototype._swapBackgroundActor = patched_backgroundmanager_swapBackgroundActor;
}
}
disable() {
if (Convenience.currentVersionSmaller('3.33.3')) {
log('disabled');
Background.prototype._destroy = _Background_destroy;
BackgroundManager.prototype._swapBackgroundActor = _BackgroundManager_swapBackgroundActor;
}
}
}
function init() {
return new Extension();
}
// there are the patched versions of the two functions
function patched_background_destroy() {
this.background = null;
this._cancellable.cancel();
this._removeAnimationTimeout();
let i;
let keys = Object.keys(this._fileWatches);
for (i = 0; i < keys.length; i++) {
this._cache.disconnect(this._fileWatches[keys[i]]);
}
this._fileWatches = null;
if (this._timezoneChangedId != 0)
this._clock.disconnect(this._timezoneChangedId);
this._timezoneChangedId = 0;
this._clock = null;
if (this._prepareForSleepId != 0)
LoginManager.getLoginManager().disconnect(this._prepareForSleepId);
this._prepareForSleepId = 0;
if (this._settingsChangedSignalId != 0)
this._settings.disconnect(this._settingsChangedSignalId);
this._settingsChangedSignalId = 0;
}
function patched_backgroundmanager_swapBackgroundActor() {
let oldBackgroundActor = this.backgroundActor;
this.backgroundActor = this._newBackgroundActor;
this._newBackgroundActor = null;
this.emit('changed');
Tweener.addTween(oldBackgroundActor,
{ opacity: 0,
time: FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
oldBackgroundActor.destroy();
}
});
}