Skip to content

Commit

Permalink
Improve debug messages in notifications stack and add more checks (#1805
Browse files Browse the repository at this point in the history
)
  • Loading branch information
lenemter authored Dec 13, 2023
1 parent 51d270e commit 186e9a3
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/NotificationStack.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ public class Gala.NotificationStack : Object {
update_stack_allocation ();
}

public void show_notification (Meta.WindowActor notification, bool animate) requires (!notifications.contains (notification)) {
public void show_notification (Meta.WindowActor notification, bool animate)
requires (notification != null && !notification.is_destroyed () && !notifications.contains (notification)) {

notification.set_pivot_point (0.5f, 0.5f);

unowned Meta.Window window = notification.get_meta_window ();
unowned var window = notification.get_meta_window ();
if (window == null) {
warning ("NotificationStack: Unable to show notification, window is null");
return;
}

var window_rect = window.get_frame_rect ();
window.stick ();

Expand Down Expand Up @@ -110,7 +117,13 @@ public class Gala.NotificationStack : Object {
var iterator = 0;
// Need to iterate like this since we might be removing entries
while (notifications.size > iterator) {
var actor = notifications.get (iterator);
unowned var actor = notifications.get (iterator);
iterator++;
if (actor == null || actor.is_destroyed ()) {
warning ("NotificationStack: Notification actor was null or destroyed");
continue;
}

if (animate) {
actor.save_easing_state ();
actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_BACK);
Expand All @@ -124,11 +137,7 @@ public class Gala.NotificationStack : Object {
actor.restore_easing_state ();
}

// For some reason get_transition doesn't work later when we need to restore it
unowned Clutter.Transition? transition = actor.get_transition ("position");
actor.set_data<Clutter.Transition?> (TRANSITION_MOVE_STACK_ID, transition);

unowned Meta.Window window = actor.get_meta_window ();
unowned var window = actor.get_meta_window ();
if (window == null) {
// Mutter doesn't let us know when a window is closed if a workspace
// transition is in progress. I'm not really sure why, but what this
Expand All @@ -141,7 +150,6 @@ public class Gala.NotificationStack : Object {
}

y += window.get_frame_rect ().height;
iterator++;
}
}

Expand Down Expand Up @@ -174,13 +182,10 @@ public class Gala.NotificationStack : Object {
* in the compositor and then calculate & apply the coordinates for the window
* actor.
*/
private static void move_window (Meta.WindowActor actor, int x, int y) {
if (actor.is_destroyed ()) {
return;
}

unowned Meta.Window window = actor.get_meta_window ();
private static void move_window (Meta.WindowActor actor, int x, int y) requires (actor != null && !actor.is_destroyed ()) {
unowned var window = actor.get_meta_window ();
if (window == null) {
warning ("NotificationStack: Unable to move the window, window is null");
return;
}

Expand Down

0 comments on commit 186e9a3

Please sign in to comment.