[gnome-shell/gbsneto/new-lock-screen-part2: 26/34] unlockDialog: Toggle between clock and auth prompt
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/gbsneto/new-lock-screen-part2: 26/34] unlockDialog: Toggle between clock and auth prompt
- Date: Fri, 31 Jan 2020 21:11:06 +0000 (UTC)
commit 2a06a110613cc7974f00bc088e12cbfd1a8e2a14
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Nov 29 14:37:10 2019 -0300
unlockDialog: Toggle between clock and auth prompt
Toggle between them when (1) tapping anythere on the screen, and
(2) pressing any key.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/872
js/ui/unlockDialog.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 76 insertions(+)
---
diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js
index 702aa8fcbf..2a52bf3bda 100644
--- a/js/ui/unlockDialog.js
+++ b/js/ui/unlockDialog.js
@@ -16,6 +16,8 @@ const IDLE_TIMEOUT = 2 * 60;
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
+const CROSSFADE_TIME = 300;
+
const BLUR_BRIGHTNESS = 0.55;
const BLUR_RADIUS = 200;
@@ -400,10 +402,17 @@ var UnlockDialog = GObject.registerClass({
accessible_role: Atk.Role.WINDOW,
style_class: 'login-dialog',
visible: false,
+ reactive: true,
});
parentActor.add_child(this);
+ this._activePage = null;
+
+ let tapAction = new Clutter.TapAction();
+ tapAction.connect('tap', this._showPrompt.bind(this));
+ this.add_action(tapAction);
+
// Background
this._backgroundGroup = new Clutter.Actor();
this.add_child(this._backgroundGroup);
@@ -426,6 +435,7 @@ var UnlockDialog = GObject.registerClass({
this._clock = new Clock();
stack.add_child(this._clock);
+ this._showClock();
this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(),
AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
this._authPrompt.connect('failed', this._fail.bind(this));
@@ -476,6 +486,29 @@ var UnlockDialog = GObject.registerClass({
this.connect('destroy', this._onDestroy.bind(this));
}
+ vfunc_key_press_event(keyEvent) {
+ if (this._activePage === this._promptBox)
+ return Clutter.EVENT_PROPAGATE;
+
+ let symbol = keyEvent.keyval;
+ let unichar = keyEvent.unicode_value;
+
+ let isLiftChar = GLib.unichar_isprint(unichar);
+ let isEnter = symbol === Clutter.KEY_Return ||
+ symbol === Clutter.KEY_KP_Enter ||
+ symbol === Clutter.KEY_ISO_Enter;
+
+ if (!isEnter && !isLiftChar)
+ return Clutter.EVENT_PROPAGATE;
+
+ this._showPrompt();
+
+ if (GLib.unichar_isgraph(unichar))
+ this.addCharacter(unichar);
+
+ return Clutter.EVENT_PROPAGATE;
+ }
+
_createBackground(monitorIndex) {
let monitor = Main.layoutManager.monitors[monitorIndex];
let widget = new St.Widget({
@@ -523,6 +556,48 @@ var UnlockDialog = GObject.registerClass({
}
}
+ _showClock() {
+ if (this._activePage === this._clock)
+ return;
+
+ this._activePage = this._clock;
+ this._clock.show();
+
+ this._promptBox.ease({
+ opacity: 0,
+ duration: CROSSFADE_TIME,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => this._promptBox.hide(),
+ });
+
+ this._clock.ease({
+ opacity: 255,
+ duration: CROSSFADE_TIME,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ });
+ }
+
+ _showPrompt() {
+ if (this._activePage === this._promptBox)
+ return;
+
+ this._activePage = this._promptBox;
+ this._promptBox.show();
+
+ this._clock.ease({
+ opacity: 0,
+ duration: CROSSFADE_TIME,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ onComplete: () => this._clock.hide(),
+ });
+
+ this._promptBox.ease({
+ opacity: 255,
+ duration: CROSSFADE_TIME,
+ mode: Clutter.AnimationMode.EASE_OUT_QUAD,
+ });
+ }
+
_fail() {
this.emit('failed');
}
@@ -569,6 +644,7 @@ var UnlockDialog = GObject.registerClass({
}
addCharacter(unichar) {
+ this._showPrompt();
this._authPrompt.addCharacter(unichar);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]