Skip to content

Commit 2765a7c

Browse files
authored
Improve large notification groups performance (#669)
* Moved ExpanableGroup into its own file * Noti Group: Cull non-visible notifications + don't calc transforms every frame Makes sure that only visible notifications are allocated and rendered. Also moves the transforms on size-allocate instead of every frame. Should improve performance. :) * Fixed expandable group not re-allocating on scroll * Fixed floating notifications warning on first map
1 parent f26aeae commit 2765a7c

File tree

6 files changed

+426
-337
lines changed

6 files changed

+426
-337
lines changed

src/animatedList/animatedList.vala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,37 @@ private struct WidgetHeights {
1515
private struct WidgetAlloc {
1616
float y;
1717
int height;
18+
19+
public WidgetAlloc () {
20+
y = 0;
21+
height = 0;
22+
}
23+
}
24+
25+
private class AnimationValueTarget : Object {
26+
private double _progress = 0;
27+
public double progress {
28+
get {
29+
return _progress;
30+
}
31+
set {
32+
_progress = value;
33+
cb (_progress);
34+
}
35+
}
36+
37+
public delegate void callback (double value);
38+
39+
private unowned callback ?cb;
40+
41+
public AnimationValueTarget (float init_value, callback cb) {
42+
this._progress = init_value;
43+
this.cb = cb;
44+
}
45+
46+
public Adw.PropertyAnimationTarget get_animation_target () {
47+
return new Adw.PropertyAnimationTarget (this, "progress");
48+
}
1849
}
1950

2051
public class AnimatedList : Gtk.Widget, Gtk.Scrollable {

src/controlCenter/widgets/notifications/notifications.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace SwayNotificationCenter.Widgets {
182182
noti_groups_name.lookup_extended (param.name_id, null, out group);
183183
}
184184
if (group == null || ConfigModel.instance.notification_grouping == false) {
185-
group = new NotificationGroup (param.name_id, param.display_name);
185+
group = new NotificationGroup (param.name_id, param.display_name, viewport);
186186
// Collapse other groups on expand
187187
group.on_expand_change.connect ((expanded) => {
188188
if (!expanded) {

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ app_sources = [
6868
'dismissableWidget/dismissableWidget.vala',
6969
'notification/notification.vala',
7070
'notificationGroup/notificationGroup.vala',
71+
'notificationGroup/expandableGroup.vala',
7172
'controlCenter/controlCenter.vala',
7273
widget_sources,
7374
'blankWindow/blankWindow.vala',

0 commit comments

Comments
 (0)