Skip to content

Commit 8ada0ac

Browse files
committed
ShellClients: Wait and reveal in sync on session start
1 parent 986a833 commit 8ada0ac

File tree

4 files changed

+40
-12
lines changed

4 files changed

+40
-12
lines changed

src/ShellClients/HideTracker.vala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,13 @@ public class Gala.HideTracker : Object {
147147
});
148148
}
149149

150-
private void update_overlap () {
150+
/**
151+
* Immediately updates the overlap. Usually {@link schedule_update} should be used instead which
152+
* internally calls this but throttles it since it's a somewhat expensive operation.
153+
* On very rare use cases however it is required to update immediately. In that case you can call
154+
* this directly.
155+
*/
156+
public void update_overlap () {
151157
overlap = false;
152158
focus_overlap = false;
153159
focus_maximized_overlap = false;

src/ShellClients/PanelClone.vala

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {
@@ -70,13 +72,19 @@ public class Gala.PanelClone : Object {
7072
update_visible ();
7173
update_clone_position ();
7274

73-
Idle.add_once (() => {
74-
if (hide_mode == NEVER) {
75-
show ();
76-
} else {
77-
hide_tracker.schedule_update ();
78-
}
79-
});
75+
// We want to wait for the window to be actually shown before revealing and then still a bit
76+
// more since at the beginning it might be doing some relayouting (e.g. the dock only knows
77+
// its size after it got a dbus connection to gala) which disrupts the animation.
78+
panel.window.shown.connect (() => Timeout.add (100, () => {
79+
window_ready = true;
80+
// In the best case we are ready before the manager stops waiting so the on_ready usually
81+
// doesn't do anything. However if the client stalls for some reason or it crashed and has now
82+
// been restarted it will show immediately.
83+
on_ready ();
84+
return Source.REMOVE;
85+
}));
86+
87+
ShellClientsManager.get_instance ().notify["is-waiting"].connect (on_ready);
8088
}
8189

8290
private void update_visible () {
@@ -142,7 +150,7 @@ public class Gala.PanelClone : Object {
142150
}
143151

144152
private void show () {
145-
if (!panel_hidden) {
153+
if (!panel_hidden || !window_ready || ShellClientsManager.get_instance ().is_waiting) {
146154
return;
147155
}
148156

@@ -160,4 +168,12 @@ public class Gala.PanelClone : Object {
160168
return Source.REMOVE;
161169
});
162170
}
171+
172+
private void on_ready () {
173+
if (hide_mode == NEVER) {
174+
show ();
175+
} else {
176+
hide_tracker.update_overlap ();
177+
}
178+
}
163179
}

src/ShellClients/ShellClientsManager.vala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class Gala.ShellClientsManager : Object {
2020
return instance;
2121
}
2222

23+
public bool is_waiting { get; private set; default = true; } // On session start wait a bit for a synchronized and smooth reveal
24+
2325
public WindowManager wm { get; construct; }
2426

2527
private NotificationsClient notifications_client;
@@ -105,6 +107,10 @@ public class Gala.ShellClientsManager : Object {
105107
}
106108
}
107109

110+
public void notify_ready () {
111+
Timeout.add_once (1500, () => is_waiting = false);
112+
}
113+
108114
public void make_dock (Meta.Window window) {
109115
if (Meta.Util.is_wayland_compositor ()) {
110116
make_dock_wayland (window);

src/WindowManager.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,13 @@ namespace Gala {
367367

368368
stage.show ();
369369

370-
Idle.add (() => {
370+
Idle.add_once (() => {
371371
// let the session manager move to the next phase
372372
#if WITH_SYSTEMD
373373
Systemd.Daemon.notify (true, "READY=1");
374374
#endif
375-
display.get_context ().notify_ready ();
376-
return GLib.Source.REMOVE;
375+
get_display ().get_context ().notify_ready ();
376+
ShellClientsManager.get_instance ().notify_ready ();
377377
});
378378
}
379379

0 commit comments

Comments
 (0)