From 92d8d65543c7f3577ea2618a8db46952817106e2 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Tue, 4 Sep 2012 19:28:19 +0200 Subject: [PATCH] ScreenShield: use session mode to handle the GDM login dialog Have main.js call .showDialog() when going back from the lock-screen, instead of using the return value of createUnlockDialog to know if the dialog was persistent. _keepDialog is still used as LoginDialog cannot really be destroyed, and cancelling it does not destroy it. https://bugzilla.gnome.org/show_bug.cgi?id=683156 --- js/ui/main.js | 17 ++--------------- js/ui/screenShield.js | 15 +++++++-------- js/ui/sessionMode.js | 29 +++++++++++++++-------------- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/js/ui/main.js b/js/ui/main.js index 9410c2352..63c4be62f 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -69,22 +69,9 @@ let _overridesSettings = null; let background = null; -function createGDMLoginDialog(parentActor) { - // We do this this here instead of at the top to prevent GDM - // related code from getting loaded in normal user sessions - const LoginDialog = imports.gdm.loginDialog; - - let loginDialog = new LoginDialog.LoginDialog(parentActor); - return [loginDialog, true]; -} - -function createSessionUnlockDialog(parentActor) { - let dialog = new UnlockDialog.UnlockDialog(parentActor); - return [dialog, false]; -} - function _sessionUpdated() { - Meta.keybindings_set_custom_handler('panel-run-dialog', sessionMode.hasRunDialog ? openRunDialog : null); + if (sessionMode.isGreeter) + screenShield.showDialog(); } function start() { diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js index 9c4f0b8e4..9642ed94a 100644 --- a/js/ui/screenShield.js +++ b/js/ui/screenShield.js @@ -606,7 +606,9 @@ const ScreenShield = new Lang.Class({ _ensureUnlockDialog: function() { if (!this._dialog) { - [this._dialog, this._keepDialog] = Main.sessionMode.createUnlockDialog(this._lockDialogGroup); + let constructor = Main.sessionMode.unlockDialog; + this._dialog = new constructor(this._lockDialogGroup); + this._keepDialog = Main.sessionMode.isGreeter; if (!this._dialog) { // This session mode has no locking capabilities this.unlock(); @@ -624,7 +626,7 @@ const ScreenShield = new Lang.Class({ this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded)); } - if (this._keepDialog) { + if (Main.sessionMode.isGreeter) { // Notify the other components that even though we are showing the // screenshield, we're not in a locked state // (this happens for the gdm greeter) @@ -764,12 +766,9 @@ const ScreenShield = new Lang.Class({ if (this._hasLockScreen) this._clearLockScreen(); - if (this._keepDialog) { - // The dialog must be kept alive, - // so immediately go back to it - // This will also reset _isLocked - this._ensureUnlockDialog(); - return; + if (this._dialog && !this._keepDialog) { + this._dialog.destroy(); + this._dialog = null; } this._lightbox.hide(); diff --git a/js/ui/sessionMode.js b/js/ui/sessionMode.js index c5ec0aa2c..3ca08db78 100644 --- a/js/ui/sessionMode.js +++ b/js/ui/sessionMode.js @@ -19,7 +19,8 @@ const _modes = { hasWorkspaces: false, hasWindows: false, isLocked: false, - createUnlockDialog: null, + isGreeter: false, + unlockDialog: null, components: [], panel: { left: [], @@ -30,7 +31,8 @@ const _modes = { 'gdm': { allowKeybindingsWhenModal: true, - createUnlockDialog: Main.createGDMLoginDialog, + isGreeter: true, + unlockDialog: imports.gdm.loginDialog.LoginDialog, panel: { left: [], center: ['dateMenu'], @@ -41,8 +43,9 @@ const _modes = { 'lock-screen': { isLocked: true, + isGreeter: undefined, + unlockDialog: undefined, components: ['networkAgent', 'polkitAgent', 'telepathyClient'], - createUnlockDialog: Main.createSessionUnlockDialog, panel: { left: ['userMenu'], center: [], @@ -67,6 +70,8 @@ const _modes = { hasRunDialog: true, hasWorkspaces: true, hasWindows: true, + unlockDialog: imports.ui.unlockDialog.UnlockDialog, + isLocked: false, components: ['networkAgent', 'polkitAgent', 'telepathyClient', 'keyring', 'recorder', 'autorunManager', 'automountManager'], panel: { @@ -113,18 +118,14 @@ const SessionMode = new Lang.Class({ let params = _modes[this.currentMode]; params = Params.parse(params, _modes[DEFAULT_MODE]); - this._createUnlockDialog = params.createUnlockDialog; - delete params.createUnlockDialog; + // A simplified version of Lang.copyProperties, handles + // undefined as a special case for "no change / inherit from previous mode" + for (let prop in params) { + if (params[prop] !== undefined) + this[prop] = params[prop]; + } - Lang.copyProperties(params, this); this.emit('updated'); - }, - - createUnlockDialog: function() { - if (this._createUnlockDialog) - return this._createUnlockDialog.apply(this, arguments); - else - return null; - }, + } }); Signals.addSignalMethods(SessionMode.prototype);