Block cancellation of the unlock dialog when dragging

Pressing esc while the mouse is down should not make the curtain fall,
otherwise a gray screen results.

https://bugzilla.gnome.org/show_bug.cgi?id=686800
This commit is contained in:
Giovanni Campagna 2012-10-24 17:53:19 +02:00
parent b59529e579
commit 4535a70f08
2 changed files with 13 additions and 7 deletions

View File

@ -502,7 +502,7 @@ const ScreenShield = new Lang.Class({
if (symbol == Clutter.KEY_Escape || if (symbol == Clutter.KEY_Escape ||
symbol == Clutter.KEY_Return || symbol == Clutter.KEY_Return ||
symbol == Clutter.KEY_KP_Enter) { symbol == Clutter.KEY_KP_Enter) {
this._ensureUnlockDialog(true); this._ensureUnlockDialog(true, true);
this._hideLockScreen(true, 0); this._hideLockScreen(true, 0);
return true; return true;
} }
@ -525,7 +525,7 @@ const ScreenShield = new Lang.Class({
// 7 standard scrolls to lift up // 7 standard scrolls to lift up
if (this._lockScreenScrollCounter > 35) { if (this._lockScreenScrollCounter > 35) {
this._ensureUnlockDialog(false); this._ensureUnlockDialog(false, true);
this._hideLockScreen(true, 0); this._hideLockScreen(true, 0);
} }
@ -557,7 +557,7 @@ const ScreenShield = new Lang.Class({
_onDragBegin: function() { _onDragBegin: function() {
Tweener.removeTweens(this._lockScreenGroup); Tweener.removeTweens(this._lockScreenGroup);
this._lockScreenState = MessageTray.State.HIDING; this._lockScreenState = MessageTray.State.HIDING;
this._ensureUnlockDialog(false); this._ensureUnlockDialog(false, false);
return true; return true;
}, },
@ -579,6 +579,7 @@ const ScreenShield = new Lang.Class({
// Complete motion automatically // Complete motion automatically
let [velocity, velocityX, velocityY] = this._dragAction.get_velocity(0); let [velocity, velocityX, velocityY] = this._dragAction.get_velocity(0);
this._hideLockScreen(true, -velocityY); this._hideLockScreen(true, -velocityY);
this._ensureUnlockDialog(false, true);
} else { } else {
// restore the lock screen to its original place // restore the lock screen to its original place
// try to use the same speed as the normal animation // try to use the same speed as the normal animation
@ -661,7 +662,7 @@ const ScreenShield = new Lang.Class({
this.actor.show(); this.actor.show();
this._isGreeter = Main.sessionMode.isGreeter; this._isGreeter = Main.sessionMode.isGreeter;
this._ensureUnlockDialog(true); this._ensureUnlockDialog(true, true);
this._hideLockScreen(false, 0); this._hideLockScreen(false, 0);
}, },
@ -717,7 +718,7 @@ const ScreenShield = new Lang.Class({
Main.sessionMode.popMode('lock-screen'); Main.sessionMode.popMode('lock-screen');
}, },
_ensureUnlockDialog: function(onPrimary) { _ensureUnlockDialog: function(onPrimary, allowCancel) {
if (!this._dialog) { if (!this._dialog) {
let constructor = Main.sessionMode.unlockDialog; let constructor = Main.sessionMode.unlockDialog;
if (!constructor) { if (!constructor) {
@ -740,6 +741,8 @@ const ScreenShield = new Lang.Class({
this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed)); this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed));
this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded)); this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded));
} }
this._dialog.allowCancel = allowCancel;
}, },
_onUnlockFailed: function() { _onUnlockFailed: function() {

View File

@ -174,6 +174,7 @@ const UnlockDialog = new Lang.Class({
this._workSpinner.actor.opacity = 0; this._workSpinner.actor.opacity = 0;
this._workSpinner.actor.show(); this._workSpinner.actor.show();
this.allowCancel = false;
this.buttonLayout.visible = true; this.buttonLayout.visible = true;
this.addButton({ label: _("Cancel"), this.addButton({ label: _("Cancel"),
action: Lang.bind(this, this._escape), action: Lang.bind(this, this._escape),
@ -349,8 +350,10 @@ const UnlockDialog = new Lang.Class({
}, },
_escape: function() { _escape: function() {
if (this.allowCancel) {
this._userVerifier.cancel(); this._userVerifier.cancel();
this.emit('failed'); this.emit('failed');
}
}, },
_otherUserClicked: function(button, event) { _otherUserClicked: function(button, event) {