From 82f7431a288f60fd653725f89bf0f2729a13672c Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Fri, 3 Aug 2012 22:56:49 +0200 Subject: [PATCH] ScreenShield: handle Escape on the stage, not on the lock screen This allows to press esc to unlock even if the focus is not on the lock screen (for example after dismissing the auth failure notification). https://bugzilla.gnome.org/show_bug.cgi?id=681143 --- js/ui/screenShield.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 2a1b9ec3a..09e6cdc3c 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -274,8 +274,6 @@ const ScreenShield = new Lang.Class({ can_focus: true, layout_manager: new Clutter.BinLayout() }); - this._lockScreenGroup.connect('key-release-event', - Lang.bind(this, this._onLockScreenKeyRelease)); this._background = Meta.BackgroundActor.new_for_screen(global.screen); this._background.add_effect(new Clutter.BlurEffect()); @@ -330,7 +328,10 @@ const ScreenShield = new Lang.Class({ fadeFactor: 1 }); }, - _onLockScreenKeyRelease: function(actor, event) { + _onStageKeyRelease: function(actor, event) { + if (!this._isLocked) + return false; + if (event.get_key_symbol() == Clutter.KEY_Escape) { this._showUnlockDialog(true); return true; @@ -495,7 +496,9 @@ const ScreenShield = new Lang.Class({ this.emit('lock-screen-shown'); } - this._lockScreenGroup.grab_key_focus(); + if (!this._stageKeyHandler) + this._stageKeyHandler = global.stage.connect('key-release-event', + Lang.bind(this, this._onStageKeyRelease)); }, // Some of the actors in the lock screen are heavy in @@ -544,6 +547,11 @@ const ScreenShield = new Lang.Class({ if (this._hasLockScreen) this._clearLockScreen(); + if (this._stageKeyHandler) { + global.stage.disconnect(this._stageKeyHandler); + this._stageKeyHandler = 0; + } + if (this._keepDialog) { // The dialog must be kept alive, // so immediately go back to it