Skip to content

Commit d5d338d

Browse files
committed
Simplified the height computation logic
1 parent 62a2791 commit d5d338d

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/animatedList/animatedList.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ public class AnimatedList : Gtk.Widget, Gtk.Scrollable {
214214
fade_distance = 0;
215215

216216
int num_vexpand_children = 0;
217-
WidgetHeights measured_height = WidgetHeights ();
218217
WidgetHeights[] heights = new WidgetHeights[n_children];
219218
int total_min = 0;
220219
int total_nat = 0;
@@ -259,11 +258,12 @@ public class AnimatedList : Gtk.Widget, Gtk.Scrollable {
259258

260259
bool allocate_nat = false;
261260
int extra_height = 0;
262-
if (height >= measured_height.nat_height) {
261+
if (height == total_min) {
263262
allocate_nat = true;
264-
extra_height = height - measured_height.nat_height;
265-
} else {
266-
warn_if_reached ();
263+
extra_height = height - total_min;
264+
} else if (height >= total_nat) {
265+
allocate_nat = true;
266+
extra_height = height - total_nat;
267267
}
268268

269269
int y = 0;

src/notificationGroup/expandableGroup.vala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ namespace SwayNotificationCenter {
108108
int height,
109109
compute_height_iter_cb iter_callback) {
110110
int num_vexpand_children = 0;
111-
WidgetHeights measured_height = WidgetHeights ();
112111
WidgetHeights[] heights = new WidgetHeights[n_children];
113112
int total_min = 0;
114113
int total_nat = 0;
@@ -149,11 +148,12 @@ namespace SwayNotificationCenter {
149148

150149
bool allocate_nat = false;
151150
int extra_height = 0;
152-
if (height >= measured_height.nat_height) {
151+
if (height == total_min) {
153152
allocate_nat = true;
154-
extra_height = height - measured_height.nat_height;
155-
} else {
156-
warn_if_reached ();
153+
extra_height = height - total_min;
154+
} else if (height >= total_nat) {
155+
allocate_nat = true;
156+
extra_height = height - total_nat;
157157
}
158158

159159
WidgetAlloc first_allocation = WidgetAlloc ();
@@ -190,8 +190,6 @@ namespace SwayNotificationCenter {
190190
}
191191

192192
protected override void size_allocate (int width, int height, int baseline) {
193-
base.size_allocate (width, height, baseline);
194-
195193
// Recalculate which children are visible, so clear the old list
196194
while (!visible_widgets.is_empty ()) {
197195
visible_widgets.delete_link (visible_widgets.nth (0));

0 commit comments

Comments
 (0)