From ae33e821c9bff9820d43e98f7312f91eea94dab2 Mon Sep 17 00:00:00 2001 From: Leonhard Date: Sat, 21 Dec 2024 17:54:12 +0100 Subject: [PATCH] Introduce InternalUtils.wait_for_window_actor_visible (#2188) --- src/InternalUtils.vala | 18 +++++++++++++----- src/WindowManager.vala | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/InternalUtils.vala b/src/InternalUtils.vala index 5a2e14239..c8c044369 100644 --- a/src/InternalUtils.vala +++ b/src/InternalUtils.vala @@ -340,7 +340,7 @@ namespace Gala { 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 && window_actor.visible) { + if (window_actor != null) { callback (window_actor); return; } @@ -348,17 +348,25 @@ namespace Gala { Idle.add (() => { window_actor = (Meta.WindowActor) window.get_compositor_private (); - if (window_actor != null && window_actor.visible) { + if (window_actor != null) { callback (window_actor); - } else if (window_actor != null) { + } + + return Source.REMOVE; + }); + } + + public static void wait_for_window_actor_visible (Meta.Window window, owned WindowActorReadyCallback callback) { + wait_for_window_actor (window, (window_actor) => { + if (window_actor.visible) { + callback (window_actor); + } else { ulong show_handler = 0; show_handler = window_actor.show.connect (() => { window_actor.disconnect (show_handler); callback (window_actor); }); } - - return Source.REMOVE; }); } } diff --git a/src/WindowManager.vala b/src/WindowManager.vala index da25e4173..75b488b78 100644 --- a/src/WindowManager.vala +++ b/src/WindowManager.vala @@ -2120,7 +2120,7 @@ namespace Gala { // TODO: currently only notifications are handled here, other windows should be too switch_workspace_window_created_id = window_created.connect ((window) => { if (NotificationStack.is_notification (window)) { - InternalUtils.wait_for_window_actor (window, (actor) => { + InternalUtils.wait_for_window_actor_visible (window, (actor) => { clutter_actor_reparent (actor, notification_group); notification_stack.show_notification (actor); });