Delay login animation until after wallpaper has loaded

Currently, the login animation can occur before the user's wallpaper has
been loaded. When this happens, we wind up displaying a solid blue
background for half a second or so before the proper background is
displayed. This looks jarring and bad. It's great that we can start
GNOME quickly, but starting up before the wallpaper is ready is *too*
quickly.

I've been meaning to fix this since 2014. Better late than never! We can
just have BackgroundManager emit a loaded signal the first time it loads
its first background, and have the startup animation code wait for that
before proceeding.

Some of this code is by Florian, who helped with promisifying. Thanks!

https://bugzilla.gnome.org/show_bug.cgi?id=734996
This commit is contained in:
Michael Catanzaro 2020-07-20 19:00:32 -05:00 committed by Florian Müllner
parent 1e87315554
commit 7097796c3f
2 changed files with 24 additions and 4 deletions

View File

@ -758,10 +758,19 @@ var BackgroundManager = class BackgroundManager {
this._updateBackgroundActor(); this._updateBackgroundActor();
}); });
let loadedSignalId = background.connect('loaded', () => {
background.disconnect(loadedSignalId);
loadedSignalId = null;
this.emit('loaded');
});
backgroundActor.connect('destroy', () => { backgroundActor.connect('destroy', () => {
if (changeSignalId) if (changeSignalId)
background.disconnect(changeSignalId); background.disconnect(changeSignalId);
if (loadedSignalId)
background.disconnect(loadedSignalId);
if (backgroundActor.loadedSignalId) if (backgroundActor.loadedSignalId)
background.disconnect(backgroundActor.loadedSignalId); background.disconnect(backgroundActor.loadedSignalId);
}); });

View File

@ -470,6 +470,15 @@ var LayoutManager = GObject.registerClass({
} }
} }
_waitLoaded(bgManager) {
return new Promise(resolve => {
const id = bgManager.connect('loaded', () => {
bgManager.disconnect(id);
resolve();
});
});
}
_updateBackgrounds() { _updateBackgrounds() {
for (let i = 0; i < this._bgManagers.length; i++) for (let i = 0; i < this._bgManagers.length; i++)
this._bgManagers[i].destroy(); this._bgManagers[i].destroy();
@ -477,7 +486,7 @@ var LayoutManager = GObject.registerClass({
this._bgManagers = []; this._bgManagers = [];
if (Main.sessionMode.isGreeter) if (Main.sessionMode.isGreeter)
return; return Promise.resolve();
for (let i = 0; i < this.monitors.length; i++) { for (let i = 0; i < this.monitors.length; i++) {
let bgManager = this._createBackgroundManager(i); let bgManager = this._createBackgroundManager(i);
@ -486,6 +495,8 @@ var LayoutManager = GObject.registerClass({
if (i != this.primaryIndex && this._startingUp) if (i != this.primaryIndex && this._startingUp)
bgManager.backgroundActor.hide(); bgManager.backgroundActor.hide();
} }
return Promise.all(this._bgManagers.map(this._waitLoaded));
} }
_updateKeyboardBox() { _updateKeyboardBox() {
@ -644,7 +655,7 @@ var LayoutManager = GObject.registerClass({
// When starting a normal user session, we want to grow it out of the middle // When starting a normal user session, we want to grow it out of the middle
// of the screen. // of the screen.
_prepareStartupAnimation() { async _prepareStartupAnimation() {
// During the initial transition, add a simple actor to block all events, // During the initial transition, add a simple actor to block all events,
// so they don't get delivered to X11 windows that have been transformed. // so they don't get delivered to X11 windows that have been transformed.
this._coverPane = new Clutter.Actor({ opacity: 0, this._coverPane = new Clutter.Actor({ opacity: 0,
@ -661,8 +672,6 @@ var LayoutManager = GObject.registerClass({
} else if (Main.sessionMode.isGreeter) { } else if (Main.sessionMode.isGreeter) {
this.panelBox.translation_y = -this.panelBox.height; this.panelBox.translation_y = -this.panelBox.height;
} else { } else {
this._updateBackgrounds();
// We need to force an update of the regions now before we scale // We need to force an update of the regions now before we scale
// the UI group to get the correct allocation for the struts. // the UI group to get the correct allocation for the struts.
this._updateRegions(); this._updateRegions();
@ -678,6 +687,8 @@ var LayoutManager = GObject.registerClass({
this.uiGroup.scale_x = this.uiGroup.scale_y = 0.75; this.uiGroup.scale_x = this.uiGroup.scale_y = 0.75;
this.uiGroup.opacity = 0; this.uiGroup.opacity = 0;
global.window_group.set_clip(monitor.x, monitor.y, monitor.width, monitor.height); global.window_group.set_clip(monitor.x, monitor.y, monitor.width, monitor.height);
await this._updateBackgrounds();
} }
this.emit('startup-prepared'); this.emit('startup-prepared');