Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalUtils: Introduce wait_for_window_actor utility #2178

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
});
lenemter marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
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
Loading