diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index b5e274347..b99645e23 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -591,6 +591,21 @@ const ScreenShield = new Lang.Class({ } }, + _maybeCancelDialog: function() { + if (!this._dialog) + return; + + this._dialog.cancel(); + if (this._isGreeter) { + // LoginDialog.cancel() will grab the key focus + // on its own, so ensure it stays on lock screen + // instead + this._lockScreenGroup.grab_key_focus(); + } else { + this._dialog = null; + } + }, + _becomeModal: function() { if (this._isModal) return true; @@ -746,13 +761,7 @@ const ScreenShield = new Lang.Class({ onCompleteScope: this, }); - // If we have a unlock dialog, cancel it - if (this._dialog) { - this._dialog.cancel(); - if (!this._isGreeter) { - this._dialog = null; - } - } + this._maybeCancelDialog(); } }, @@ -760,12 +769,7 @@ const ScreenShield = new Lang.Class({ if (status != GnomeSession.PresenceStatus.IDLE) return; - if (this._dialog) { - this._dialog.cancel(); - if (!this._isGreeter) { - this._dialog = null; - } - } + this._maybeCancelDialog(); if (this._lightbox.actor.visible || this._isActive) {