Skip to content

Commit 6a90680

Browse files
InternalUtils: Introduce wait_for_window_actor utility (#2178)
Co-authored-by: Leo <[email protected]>
1 parent 5bb3e80 commit 6a90680

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/InternalUtils.vala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,25 @@ namespace Gala {
335335

336336
return actor_box;
337337
}
338+
339+
public delegate void WindowActorReadyCallback (Meta.WindowActor window_actor);
340+
341+
public static void wait_for_window_actor (Meta.Window window, owned WindowActorReadyCallback callback) {
342+
unowned var window_actor = (Meta.WindowActor) window.get_compositor_private ();
343+
if (window_actor != null) {
344+
callback (window_actor);
345+
return;
346+
}
347+
348+
Idle.add (() => {
349+
window_actor = (Meta.WindowActor) window.get_compositor_private ();
350+
351+
if (window_actor != null) {
352+
callback (window_actor);
353+
}
354+
355+
return Source.REMOVE;
356+
});
357+
}
338358
}
339359
}

src/Widgets/WindowClone.vala

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public class Gala.WindowClone : Clutter.Actor {
143143

144144
reallocate ();
145145

146-
load_clone ();
146+
InternalUtils.wait_for_window_actor (window, load_clone);
147147

148148
window.notify["title"].connect (() => window_title.set_text (window.get_title () ?? ""));
149149
window_title.set_text (window.get_title () ?? "");
@@ -182,19 +182,7 @@ public class Gala.WindowClone : Clutter.Actor {
182182
* itself at the location of the original window. Also adds the shadow
183183
* effect and makes sure the shadow is updated on size changes.
184184
*/
185-
private void load_clone () {
186-
var actor = (Meta.WindowActor) window.get_compositor_private ();
187-
if (actor == null) {
188-
Idle.add (() => {
189-
if (window.get_compositor_private () != null) {
190-
load_clone ();
191-
}
192-
return Source.REMOVE;
193-
});
194-
195-
return;
196-
}
197-
185+
private void load_clone (Meta.WindowActor actor) {
198186
if (overview_mode) {
199187
actor.hide ();
200188
}

0 commit comments

Comments
 (0)