@@ -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,38 @@ 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 waiting
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+
92+ ShellClientsManager . get_instance (). notify_client_ready ();
93+
94+ return Source . REMOVE ;
95+ }));
96+ } else {
97+ // On X the window was already shown when it requests being a panel so just mark it ready
98+ window_ready = true ;
99+ on_ready ();
100+ ShellClientsManager . get_instance (). notify_client_ready ();
101+ }
102+
103+ ShellClientsManager . get_instance (). notify[" is-waiting" ]. connect (on_ready);
80104 }
81105
82106 private void update_visible () {
@@ -146,7 +170,7 @@ public class Gala.PanelClone : Object {
146170 }
147171
148172 private void show () {
149- if (! panel_hidden) {
173+ if (! panel_hidden || ! window_ready || ShellClientsManager . get_instance () . is_waiting ) {
150174 return ;
151175 }
152176
@@ -171,4 +195,12 @@ public class Gala.PanelClone : Object {
171195 panel_hidden = false ;
172196 }
173197 }
198+
199+ private void on_ready () {
200+ if (hide_mode == NEVER ) {
201+ show ();
202+ } else {
203+ hide_tracker. update_overlap ();
204+ }
205+ }
174206}
0 commit comments