From 48fb16b5706f2a705d15e666fc142b02f613a5cd Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sun, 14 Oct 2012 18:34:22 +0200 Subject: [PATCH] ScreenShield: show the unlock dialog on the primary monitor when using the keyboard Make ModalDialog.open() accept an optional onPrimary argument, and pass it when the dialog is activated using ESC or Return. https://bugzilla.gnome.org/show_bug.cgi?id=685855 --- js/ui/layout.js | 3 +++ js/ui/modalDialog.js | 11 +++++++---- js/ui/screenShield.js | 13 +++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/js/ui/layout.js b/js/ui/layout.js index c399d421e..ad260ec32 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -43,6 +43,8 @@ const MonitorConstraint = new Lang.Class({ }, set primary(v) { + if (v) + this._index = -1; this._primary = v; if (this.actor) this.actor.queue_relayout(); @@ -54,6 +56,7 @@ const MonitorConstraint = new Lang.Class({ }, set index(v) { + this._primary = false; this._index = v; if (this.actor) this.actor.queue_relayout(); diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js index 3f7233f9a..71fbfc781 100644 --- a/js/ui/modalDialog.js +++ b/js/ui/modalDialog.js @@ -202,8 +202,11 @@ const ModalDialog = new Lang.Class({ this.emit('destroy'); }, - _fadeOpen: function() { - this._monitorConstraint.index = global.screen.get_current_monitor(); + _fadeOpen: function(onPrimary) { + if (onPrimary) + this._monitorConstraint.primary = true; + else + this._monitorConstraint.index = global.screen.get_current_monitor(); this.state = State.OPENING; @@ -236,14 +239,14 @@ const ModalDialog = new Lang.Class({ })); }, - open: function(timestamp) { + open: function(timestamp, onPrimary) { if (this.state == State.OPENED || this.state == State.OPENING) return true; if (!this.pushModal(timestamp)) return false; - this._fadeOpen(); + this._fadeOpen(onPrimary); return true; }, diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 4674e6578..d5ca644fd 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -453,7 +453,7 @@ const ScreenShield = new Lang.Class({ if (symbol == Clutter.KEY_Escape || symbol == Clutter.KEY_Return || symbol == Clutter.KEY_KP_Enter) { - this._ensureUnlockDialog(); + this._ensureUnlockDialog(true); this._hideLockScreen(true); return true; } @@ -476,7 +476,7 @@ const ScreenShield = new Lang.Class({ // 7 standard scrolls to lift up if (this._lockScreenScrollCounter > 35) { - this._ensureUnlockDialog(); + this._ensureUnlockDialog(false); this._hideLockScreen(true); } @@ -508,7 +508,7 @@ const ScreenShield = new Lang.Class({ _onDragBegin: function() { Tweener.removeTweens(this._lockScreenGroup); this._lockScreenState = MessageTray.State.HIDING; - this._ensureUnlockDialog(); + this._ensureUnlockDialog(false); }, _onDragEnd: function(action, actor, eventX, eventY, modifiers) { @@ -585,7 +585,7 @@ const ScreenShield = new Lang.Class({ this.actor.show(); this._isGreeter = Main.sessionMode.isGreeter; - this._ensureUnlockDialog(); + this._ensureUnlockDialog(true); this._hideLockScreen(false); }, @@ -632,7 +632,7 @@ const ScreenShield = new Lang.Class({ Main.sessionMode.popMode('lock-screen'); }, - _ensureUnlockDialog: function() { + _ensureUnlockDialog: function(onPrimary) { if (!this._dialog) { let constructor = Main.sessionMode.unlockDialog; this._dialog = new constructor(this._lockDialogGroup); @@ -642,8 +642,9 @@ const ScreenShield = new Lang.Class({ return; } + let time = global.get_current_time(); this._dialog.connect('loaded', Lang.bind(this, function() { - if (!this._dialog.open()) { + if (!this._dialog.open(time, onPrimary)) { log('Could not open login dialog: failed to acquire grab'); this.unlock(); }