From 266607d2b5ce7bb74f5954897460261af21b9ff0 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 18 Aug 2015 12:02:17 -0400 Subject: [PATCH] gdm: honor timed login delay even if animations disabled gnome-shell currently initiates an automatic login attempt if timed login is enabled and the timed login animation completes. Unfortunately, if animations are disabled (as is the case for virtual machines) then the timed login animation will complete instantly, and timed login will proceed immediately after gnome-shell has noticed the user is idle for 5 seconds. This commit addresses that problem by initiating timed login and the animation from a main loop timeout, instead of using the tweener api. --- js/gdm/loginDialog.js | 38 ++++++++++++++++++++++++++++---------- src/gvc | 2 +- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index a51ffd5..4b4d232 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -80,74 +80,90 @@ const UserListItem = new Lang.Class({ scale_x: 0 }); layout.add(this._timedLoginIndicator); this.actor.connect('clicked', Lang.bind(this, this._onClicked)); this._onUserChanged(); }, _onUserChanged: function() { this._updateLoggedIn(); }, _updateLoggedIn: function() { if (this.user.is_logged_in()) this.actor.add_style_pseudo_class('logged-in'); else this.actor.remove_style_pseudo_class('logged-in'); }, _onDestroy: function() { this._user.disconnect(this._userChangedId); }, _onClicked: function() { this.emit('activate'); }, showTimedLoginIndicator: function(time) { let hold = new Batch.Hold(); this.hideTimedLoginIndicator(); - Tweener.addTween(this._timedLoginIndicator, - { scale_x: 1., - time: time, - transition: 'linear', - onComplete: function() { - hold.release(); - }, - onCompleteScope: this - }); + + let startTime = GLib.get_monotonic_time(); + + this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT, + 33, + Lang.bind(this, function() { + let currentTime = GLib.get_monotonic_time(); + let elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC; + this._timedLoginIndicator.scale_x = elapsedTime / time; + log("elasped time: " + elapsedTime + " time: " + time); + if (elapsedTime >= time) { + log("releasing hold"); + this._timedLoginTimeoutId = 0; + hold.release(); + return GLib.SOURCE_REMOVE; + } + + return GLib.SOURCE_CONTINUE; + })); + + GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId'); + return hold; }, hideTimedLoginIndicator: function() { - Tweener.removeTweens(this._timedLoginIndicator); + if (this._timedLoginTimeoutId) { + GLib.source_remove(this._timedLoginTimeoutId); + this._timedLoginTimeoutId = 0; + } this._timedLoginIndicator.scale_x = 0.; } }); Signals.addSignalMethods(UserListItem.prototype); const UserList = new Lang.Class({ Name: 'UserList', _init: function() { this.actor = new St.ScrollView({ style_class: 'login-dialog-user-list-view'}); this.actor.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC); this._box = new St.BoxLayout({ vertical: true, style_class: 'login-dialog-user-list', pseudo_class: 'expanded' }); this.actor.add_actor(this._box); this._items = {}; this.actor.connect('key-focus-in', Lang.bind(this, this._moveFocusToItems)); }, _moveFocusToItems: function() { let hasItems = Object.keys(this._items).length > 0; if (!hasItems) return; if (global.stage.get_key_focus() != this.actor)