Skip to content

Commit

Permalink
InternalUtils: Introduce wait_for_window_actor utility (#2178)
Browse files Browse the repository at this point in the history
Co-authored-by: Leo <[email protected]>
  • Loading branch information
leolost2605 and lenemter authored Dec 19, 2024
1 parent 5bb3e80 commit 6a90680
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
20 changes: 20 additions & 0 deletions src/InternalUtils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -335,5 +335,25 @@ namespace Gala {

return actor_box;
}

public delegate void WindowActorReadyCallback (Meta.WindowActor window_actor);

public static void wait_for_window_actor (Meta.Window window, owned WindowActorReadyCallback callback) {
unowned var window_actor = (Meta.WindowActor) window.get_compositor_private ();
if (window_actor != null) {
callback (window_actor);
return;
}

Idle.add (() => {
window_actor = (Meta.WindowActor) window.get_compositor_private ();

if (window_actor != null) {
callback (window_actor);
}

return Source.REMOVE;
});
}
}
}
16 changes: 2 additions & 14 deletions src/Widgets/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public class Gala.WindowClone : Clutter.Actor {

reallocate ();

load_clone ();
InternalUtils.wait_for_window_actor (window, load_clone);

window.notify["title"].connect (() => window_title.set_text (window.get_title () ?? ""));
window_title.set_text (window.get_title () ?? "");
Expand Down Expand Up @@ -182,19 +182,7 @@ public class Gala.WindowClone : Clutter.Actor {
* itself at the location of the original window. Also adds the shadow
* effect and makes sure the shadow is updated on size changes.
*/
private void load_clone () {
var actor = (Meta.WindowActor) window.get_compositor_private ();
if (actor == null) {
Idle.add (() => {
if (window.get_compositor_private () != null) {
load_clone ();
}
return Source.REMOVE;
});

return;
}

private void load_clone (Meta.WindowActor actor) {
if (overview_mode) {
actor.hide ();
}
Expand Down

0 comments on commit 6a90680

Please sign in to comment.