Skip to content

Commit 7360823

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

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-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: 30 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,25 @@ 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+
if (Meta.Util.is_wayland_compositor ()) {
76+
// We want to wait for the window to be actually shown before revealing and then still a bit
77+
// more since at the beginning it might be doing some relayouting (e.g. the dock only knows
78+
// its size after it got a dbus connection to gala) which disrupts the animation.
79+
panel.window.shown.connect (() => Timeout.add (100, () => {
80+
window_ready = true;
81+
// In the best case we are ready before the manager stops waiting so the on_ready usually
82+
// doesn't do anything. However if the client stalls for some reason or it crashed and has now
83+
// been restarted it will show immediately.
84+
on_ready ();
85+
return Source.REMOVE;
86+
}));
87+
} else {
88+
// On X the window was already shown when it requests being a panel so just mark it ready
89+
window_ready = true;
90+
on_ready ();
91+
}
92+
93+
ShellClientsManager.get_instance ().notify["is-waiting"].connect (on_ready);
8094
}
8195

8296
private void update_visible () {
@@ -142,7 +156,7 @@ public class Gala.PanelClone : Object {
142156
}
143157

144158
private void show () {
145-
if (!panel_hidden) {
159+
if (!panel_hidden || !window_ready || ShellClientsManager.get_instance ().is_waiting) {
146160
return;
147161
}
148162

@@ -160,4 +174,12 @@ public class Gala.PanelClone : Object {
160174
return Source.REMOVE;
161175
});
162176
}
177+
178+
private void on_ready () {
179+
if (hide_mode == NEVER) {
180+
show ();
181+
} else {
182+
hide_tracker.update_overlap ();
183+
}
184+
}
163185
}

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)