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
107
108
109
110
111
112
113
114
115
116
117
|
import Meta from 'gi://Meta';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
const SURFACE_SIGNALS = [
'notify::allocation',
'notify::position',
'notify::size',
'notify::x',
'notify::y',
'notify::width',
'notify::height',
'notify::clip-rect',
'notify::visible',
'notify::mapped',
'notify::opacity',
'notify::translation-x',
'notify::translation-y',
'notify::scale-x',
'notify::scale-y',
'notify::pseudo-class',
];
export const PopupBlurSurfaceSignals = class PopupBlurSurfaceSignals {
constructor(surface) {
this.surface = surface;
this.signal_ids = [];
this.signal_actors = new WeakSet();
this.destroyed_actors = new WeakSet();
}
connect_actor(actor) {
if (!actor || this.signal_actors.has(actor))
return;
this.signal_actors.add(actor);
this.track_destroy(actor);
const is_heavy_surface = this.surface.is_heavy_surface();
SURFACE_SIGNALS.forEach(signal => {
let id = actor.connect(signal, () => {
this.clear_pending_idles();
const is_visibility_change = signal === 'notify::visible' || signal === 'notify::mapped';
if (is_heavy_surface || is_visibility_change) {
this.surface.queue_update();
return;
}
else {
this.updateId = global.compositor.get_laters().add(Meta.LaterType.IDLE, () => {
this.updateId = 0;
this.surface.queue_update();
return false;
});
}
});
this.signal_ids.push([actor, id, signal]);
});
}
track_destroy(actor) {
const id = actor.connect('destroy', () => this.destroyed_actors.add(actor));
this.signal_ids.push([actor, id]);
}
connect_ancestors(actor) {
actor = actor ? actor.get_parent() : null;
while (actor && actor !== this.surface.parent) {
this.connect_actor(actor);
actor = actor.get_parent();
}
}
connect_layout() {
if (!this.surface.static_blur)
return;
this.signal_ids.push([
Main.layoutManager,
Main.layoutManager.connect('monitors-changed', () => this.surface.queue_update()),
]);
}
connect_settings() {
[
this.surface.corner_radius.key,
'override-background',
'style-popup',
].forEach(key => {
const id = this.surface.settings.popup.settings.connect(
`changed::${key}`,
() => this.surface.update_settings()
);
this.signal_ids.push([this.surface.settings.popup.settings, id]);
});
}
clear_pending_idles() {
if (this.updateId) {
global.compositor.get_laters().remove(this.updateId);
this.updateId = 0;
}
}
disconnect_all() {
this.clear_pending_idles();
this.signal_ids.forEach(([signal_actor, signal_id]) => {
if (this.destroyed_actors.has(signal_actor))
return;
signal_actor.disconnect(signal_id);
});
this.signal_ids = [];
this.signal_actors = new WeakSet();
this.destroyed_actors = new WeakSet();
}
};
|