From b16ee1a3a6c02facc803be45d2859e53c906decd Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sat, 8 Jun 2013 19:04:36 +0200 Subject: [PATCH] ScreenShield: consolidate code that handles dialog cancellation This way we ensure the same behavior everywhere. https://bugzilla.gnome.org/show_bug.cgi?id=701731 --- js/ui/screenShield.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) 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) {