@@ -9,7 +9,7 @@ public class Gala.PanelClone : Object {
99 private const int ANIMATION_DURATION = 250 ;
1010
1111 public WindowManager wm { get ; construct; }
12- public unowned PanelWindow panel { get ; construct; }
12+ public unowned PanelWindow ? panel { get ; construct; }
1313
1414 public Pantheon . Desktop . HideMode hide_mode {
1515 get {
@@ -35,6 +35,8 @@ public class Gala.PanelClone : Object {
3535 private SafeWindowClone clone;
3636 private Meta . WindowActor actor;
3737
38+ private bool window_ready = false ;
39+
3840 private HideTracker ? hide_tracker;
3941
4042 public PanelClone (WindowManager wm , PanelWindow panel ) {
@@ -67,16 +69,34 @@ public class Gala.PanelClone : Object {
6769 // https://github.com/elementary/gala/issues/2080
6870 panel. window. focused. connect (update_visible);
6971
72+ panel. window. unmanaging. connect (() = > panel = null );
73+
7074 update_visible ();
7175 update_clone_position ();
7276
73- Idle . add_once (() = > {
74- if (hide_mode == NEVER ) {
75- show ();
76- } else {
77- hide_tracker. schedule_update ();
78- }
79- });
77+ if (Meta . Util . is_wayland_compositor ()) {
78+ // We want to wait for the window to be actually shown before revealing and then still a bit
79+ // more since at the beginning it might be doing some relayouting (e.g. the dock only knows
80+ // its size after it got a dbus connection to gala) which disrupts the animation.
81+ panel. window. shown. connect (() = > Timeout . add (100 , () = > {
82+ if (panel == null ) {
83+ return Source . REMOVE ; // The window was unmanaged while we were animating
84+ }
85+
86+ window_ready = true ;
87+ // In the best case we are ready before the manager stops waiting so the on_ready usually
88+ // doesn't do anything. However if the client stalls for some reason or it crashed and has now
89+ // been restarted it will show immediately.
90+ on_ready ();
91+ return Source . REMOVE ;
92+ }));
93+ } else {
94+ // On X the window was already shown when it requests being a panel so just mark it ready
95+ window_ready = true ;
96+ on_ready ();
97+ }
98+
99+ ShellClientsManager . get_instance (). notify[" is-waiting" ]. connect (on_ready);
80100 }
81101
82102 private void update_visible () {
@@ -142,7 +162,7 @@ public class Gala.PanelClone : Object {
142162 }
143163
144164 private void show () {
145- if (! panel_hidden) {
165+ if (! panel_hidden || ! window_ready || ShellClientsManager . get_instance () . is_waiting ) {
146166 return ;
147167 }
148168
@@ -163,4 +183,12 @@ public class Gala.PanelClone : Object {
163183 panel_hidden = false ;
164184 }
165185 }
186+
187+ private void on_ready () {
188+ if (hide_mode == NEVER ) {
189+ show ();
190+ } else {
191+ hide_tracker. update_overlap ();
192+ }
193+ }
166194}
0 commit comments