Skip to content

Commit

Permalink
Move clutter_actor_reparent to InternalUtils (#2223)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter authored Jan 12, 2025
1 parent ff7c2cb commit d5cb0b4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
11 changes: 11 additions & 0 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -369,5 +369,16 @@ namespace Gala {
}
});
}

public static void clutter_actor_reparent (Clutter.Actor actor, Clutter.Actor new_parent) {
if (actor == new_parent) {
return;
}

actor.ref ();
actor.get_parent ().remove_child (actor);
new_parent.add_child (actor);
actor.unref ();
}
}
}
24 changes: 7 additions & 17 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ namespace Gala {
// Notifications are a special case and have to be always be handled
// (also regardless of the animation setting)
if (NotificationStack.is_notification (window)) {
clutter_actor_reparent (actor, notification_group);
InternalUtils.clutter_actor_reparent (actor, notification_group);
notification_stack.show_notification (actor);

map_completed (actor);
Expand Down Expand Up @@ -1945,7 +1945,7 @@ namespace Gala {
windows.append (actor);
parents.append (actor.get_parent ());

clutter_actor_reparent (actor, static_windows);
InternalUtils.clutter_actor_reparent (actor, static_windows);
actor.set_translation (-clone_offset_x, -clone_offset_y, 0);

// Don't fade docks and moving/grabbed windows they just stay where they are
Expand All @@ -1966,7 +1966,7 @@ namespace Gala {
windows.append (actor);
parents.append (actor.get_parent ());
actor.set_translation (-clone_offset_x, -clone_offset_y, 0);
clutter_actor_reparent (actor, out_group);
InternalUtils.clutter_actor_reparent (actor, out_group);

if (window.fullscreen)
from_has_fullscreened = true;
Expand All @@ -1975,7 +1975,7 @@ namespace Gala {
windows.append (actor);
parents.append (actor.get_parent ());
actor.set_translation (-clone_offset_x, -clone_offset_y, 0);
clutter_actor_reparent (actor, in_group);
InternalUtils.clutter_actor_reparent (actor, in_group);

if (window.fullscreen)
to_has_fullscreened = true;
Expand Down Expand Up @@ -2050,7 +2050,7 @@ namespace Gala {
switch_workspace_window_created_id = window_created.connect ((window) => {
if (NotificationStack.is_notification (window)) {
InternalUtils.wait_for_window_actor_visible (window, (actor) => {
clutter_actor_reparent (actor, notification_group);
InternalUtils.clutter_actor_reparent (actor, notification_group);
notification_stack.show_notification (actor);
});
}
Expand Down Expand Up @@ -2180,13 +2180,13 @@ namespace Gala {

unowned Meta.WindowActor? window = actor as Meta.WindowActor;
if (window == null) {
clutter_actor_reparent (actor, parents.nth_data (i));
InternalUtils.clutter_actor_reparent (actor, parents.nth_data (i));
continue;
}

unowned Meta.Window? meta_window = window.get_meta_window ();
if (!window.is_destroyed ()) {
clutter_actor_reparent (actor, parents.nth_data (i));
InternalUtils.clutter_actor_reparent (actor, parents.nth_data (i));
}

kill_window_effects (window);
Expand Down Expand Up @@ -2350,15 +2350,5 @@ namespace Gala {
// Ignore this error
}
}

private static void clutter_actor_reparent (Clutter.Actor actor, Clutter.Actor new_parent) {
if (actor == new_parent)
return;

actor.ref ();
actor.get_parent ().remove_child (actor);
new_parent.add_child (actor);
actor.unref ();
}
}
}

0 comments on commit d5cb0b4

Please sign in to comment.