Commit f182f2b4 authored by Erik Reider's avatar Erik Reider

Fixed removed floating notifications sometimes being rendered for a few ticks

Caused when the notification windows input region is set right after a notification has been removed, before the AnimatedLists size-allocation has been re-computed. Can be reproduced by running this command in sway: `notify-send "test 1" -u critical; notify-send "test 2" -t 2000; sleep 1; swaymsg "output * power off"; notify-send "test 3" -t 500; sleep 3; swaymsg "output * power on"`
parent 32587275
...@@ -674,17 +674,29 @@ public class AnimatedList : Gtk.Widget, Gtk.Scrollable { ...@@ -674,17 +674,29 @@ public class AnimatedList : Gtk.Widget, Gtk.Scrollable {
AnimatedListItem ?item = try_get_ancestor (widget); AnimatedListItem ?item = try_get_ancestor (widget);
if (item == null) { if (item == null) {
warn_if_reached ();
return false; return false;
} }
// Will unparent itself when done animating // Will unparent itself when done animating
bool result = yield item.removed (transition_children && transition); if (!yield item.removed (transition_children && transition)) {
debug ("Skipping extra removal of AnimatedListItem");
return false;
}
item.unparent (); item.unparent ();
children.remove (item); children.remove (item);
n_children--; n_children--;
// Make sure that we don't render/compute the bounds of this destroyed widget.
// queue_resize might not finish in-time before iterating the visible children
unowned List<unowned AnimatedListItem> visible_item = visible_children.find (item);
if (visible_item != null) {
visible_children.delete_link (visible_item);
}
queue_resize (); queue_resize ();
return result; return true;
} }
public bool move_to_beginning (Gtk.Widget widget, bool scroll_to) { public bool move_to_beginning (Gtk.Widget widget, bool scroll_to) {
......
...@@ -178,19 +178,26 @@ namespace SwayNotificationCenter { ...@@ -178,19 +178,26 @@ namespace SwayNotificationCenter {
} }
Cairo.Region region = new Cairo.Region (); Cairo.Region region = new Cairo.Region ();
foreach (AnimatedListItem item in list.visible_children) { foreach (unowned AnimatedListItem item in list.visible_children) {
if (item == null || !(item is Object)) {
critical (
"Could not iter over AnimatedListItem (%p) while setting input region\n",
item);
continue;
}
if (item.destroying) { if (item.destroying) {
continue; continue;
} }
Graphene.Rect out_bounds; Graphene.Rect out_bounds;
item.compute_bounds (this, out out_bounds); if (item.compute_bounds (this, out out_bounds)) {
Cairo.RectangleInt item_rect = Cairo.RectangleInt () { Cairo.RectangleInt item_rect = Cairo.RectangleInt () {
x = (int) out_bounds.get_x (), x = (int) out_bounds.get_x (),
y = (int) out_bounds.get_y (), y = (int) out_bounds.get_y (),
width = (int) out_bounds.get_width (), width = (int) out_bounds.get_width (),
height = (int) out_bounds.get_height (), height = (int) out_bounds.get_height (),
}; };
region.union_rectangle (item_rect); region.union_rectangle (item_rect);
}
} }
// The input region should only cover each preview widget // The input region should only cover each preview widget
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment