authPrompt: Bump the user verifier timeout when wiggling the message

Wiggle may make the error message to be visible for less time so provide
the auth prompt an API to increase the timeout to be used for showing a
message in some cases.

This could be reworked when we'll have a proper asyn wiggle function so
that we could just make the user verifier to "freeze", then await for
the wiggle transition to complete and eventually release the verifier.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1652>
This commit is contained in:
Marco Trevisan (Treviño) 2021-02-08 19:34:09 +01:00 committed by Ray Strode
parent 75a1798e75
commit ed1ace1d99
2 changed files with 17 additions and 3 deletions

View File

@ -432,8 +432,16 @@ var AuthPrompt = GObject.registerClass({
} }
if (type === GdmUtil.MessageType.ERROR && if (type === GdmUtil.MessageType.ERROR &&
this._userVerifier.serviceIsFingerprint(serviceName)) this._userVerifier.serviceIsFingerprint(serviceName)) {
Util.wiggle(this._message); // TODO: Use Await for wiggle to be over before unfreezing the user verifier queue
const wiggleParameters = {
duration: 65,
wiggleCount: 3,
};
this._userVerifier.increaseCurrentMessageTimeout(
wiggleParameters.duration * (wiggleParameters.wiggleCount + 2));
Util.wiggle(this._message, wiggleParameters);
}
} }
updateSensitivity(sensitive) { updateSensitivity(sensitive) {

View File

@ -285,6 +285,11 @@ var ShellUserVerifier = class {
this.emit('no-more-messages'); this.emit('no-more-messages');
} }
increaseCurrentMessageTimeout(interval) {
if (!this._messageQueueTimeoutId && interval > 0)
this._currentMessageExtraInterval = interval;
}
_queueMessageTimeout() { _queueMessageTimeout() {
if (this._messageQueue.length == 0) { if (this._messageQueue.length == 0) {
this.finishMessageQueue(); this.finishMessageQueue();
@ -296,10 +301,11 @@ var ShellUserVerifier = class {
let message = this._messageQueue.shift(); let message = this._messageQueue.shift();
delete this._currentMessageExtraInterval;
this.emit('show-message', message.serviceName, message.text, message.type); this.emit('show-message', message.serviceName, message.text, message.type);
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
message.interval, message.interval + (this._currentMessageExtraInterval | 0),
() => { () => {
this._messageQueueTimeoutId = 0; this._messageQueueTimeoutId = 0;
this._queueMessageTimeout(); this._queueMessageTimeout();