2012-05-20 12:30:14 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 09:07:06 -05:00
|
|
|
/* exported UnlockDialog */
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2020-02-01 10:23:59 -05:00
|
|
|
const { AccountsService, Atk, Clutter, Gdm,
|
2019-11-28 16:16:53 -05:00
|
|
|
GnomeDesktop, GLib, GObject, Meta, Shell, St } = imports.gi;
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2019-11-28 17:16:55 -05:00
|
|
|
const Background = imports.ui.background;
|
2013-07-16 07:31:22 -04:00
|
|
|
const Layout = imports.ui.layout;
|
2012-05-20 12:30:14 -04:00
|
|
|
const Main = imports.ui.main;
|
2019-11-28 16:35:13 -05:00
|
|
|
const MessageTray = imports.ui.messageTray;
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2013-07-23 20:37:42 -04:00
|
|
|
const AuthPrompt = imports.gdm.authPrompt;
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2012-08-16 15:24:53 -04:00
|
|
|
// The timeout before going back automatically to the lock screen (in seconds)
|
|
|
|
const IDLE_TIMEOUT = 2 * 60;
|
|
|
|
|
2019-11-28 17:16:55 -05:00
|
|
|
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
|
|
|
|
|
2019-11-29 12:37:10 -05:00
|
|
|
const CROSSFADE_TIME = 300;
|
|
|
|
|
2020-01-07 14:43:35 -05:00
|
|
|
const BLUR_BRIGHTNESS = 0.55;
|
2020-02-10 09:34:57 -05:00
|
|
|
const BLUR_SIGMA = 60;
|
2020-01-07 14:43:35 -05:00
|
|
|
|
2019-11-29 14:08:20 -05:00
|
|
|
const SUMMARY_ICON_SIZE = 32;
|
2019-11-28 16:35:13 -05:00
|
|
|
|
|
|
|
var NotificationsBox = GObject.registerClass({
|
|
|
|
Signals: { 'wake-up-screen': {} },
|
|
|
|
}, class NotificationsBox extends St.BoxLayout {
|
|
|
|
_init() {
|
|
|
|
super._init({
|
|
|
|
vertical: true,
|
|
|
|
name: 'unlockDialogNotifications',
|
|
|
|
style_class: 'unlock-dialog-notifications-container',
|
|
|
|
});
|
|
|
|
|
|
|
|
this._scrollView = new St.ScrollView({ hscrollbar_policy: St.PolicyType.NEVER });
|
|
|
|
this._notificationBox = new St.BoxLayout({
|
|
|
|
vertical: true,
|
|
|
|
style_class: 'unlock-dialog-notifications-container',
|
|
|
|
});
|
|
|
|
this._scrollView.add_actor(this._notificationBox);
|
|
|
|
|
|
|
|
this.add_child(this._scrollView);
|
|
|
|
|
|
|
|
this._sources = new Map();
|
|
|
|
Main.messageTray.getSources().forEach(source => {
|
|
|
|
this._sourceAdded(Main.messageTray, source, true);
|
|
|
|
});
|
|
|
|
this._updateVisibility();
|
|
|
|
|
|
|
|
this._sourceAddedId = Main.messageTray.connect('source-added', this._sourceAdded.bind(this));
|
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
if (this._sourceAddedId) {
|
|
|
|
Main.messageTray.disconnect(this._sourceAddedId);
|
|
|
|
this._sourceAddedId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
let items = this._sources.entries();
|
|
|
|
for (let [source, obj] of items)
|
|
|
|
this._removeSource(source, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateVisibility() {
|
|
|
|
this._notificationBox.visible =
|
|
|
|
this._notificationBox.get_children().some(a => a.visible);
|
|
|
|
|
|
|
|
this.visible = this._notificationBox.visible;
|
|
|
|
}
|
|
|
|
|
|
|
|
_makeNotificationSource(source, box) {
|
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
|
|
|
box.add_child(sourceActor);
|
|
|
|
|
2019-11-29 14:05:45 -05:00
|
|
|
let textBox = new St.BoxLayout({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
2019-11-28 16:35:13 -05:00
|
|
|
box.add_child(textBox);
|
|
|
|
|
|
|
|
let title = new St.Label({
|
|
|
|
text: source.title,
|
|
|
|
style_class: 'unlock-dialog-notification-label',
|
2019-11-29 14:05:45 -05:00
|
|
|
x_expand: true,
|
|
|
|
x_align: Clutter.ActorAlign.START,
|
2019-11-28 16:35:13 -05:00
|
|
|
});
|
|
|
|
textBox.add(title);
|
|
|
|
|
|
|
|
let count = source.unseenCount;
|
|
|
|
let countLabel = new St.Label({
|
2019-11-29 14:05:12 -05:00
|
|
|
text: `${count}`,
|
2019-11-28 16:35:13 -05:00
|
|
|
style_class: 'unlock-dialog-notification-count-text',
|
|
|
|
});
|
|
|
|
textBox.add(countLabel);
|
|
|
|
|
|
|
|
box.visible = count !== 0;
|
|
|
|
return [title, countLabel];
|
|
|
|
}
|
|
|
|
|
|
|
|
_makeNotificationDetailedSource(source, box) {
|
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
|
|
|
let sourceBin = new St.Bin({ child: sourceActor });
|
|
|
|
box.add(sourceBin);
|
|
|
|
|
|
|
|
let textBox = new St.BoxLayout({ vertical: true });
|
|
|
|
box.add_child(textBox);
|
|
|
|
|
|
|
|
let title = new St.Label({
|
|
|
|
text: source.title,
|
|
|
|
style_class: 'unlock-dialog-notification-label',
|
|
|
|
});
|
|
|
|
textBox.add(title);
|
|
|
|
|
|
|
|
let visible = false;
|
|
|
|
for (let i = 0; i < source.notifications.length; i++) {
|
|
|
|
let n = source.notifications[i];
|
|
|
|
|
|
|
|
if (n.acknowledged)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let body = '';
|
|
|
|
if (n.bannerBodyText) {
|
|
|
|
body = n.bannerBodyMarkup
|
|
|
|
? n.bannerBodyText
|
|
|
|
: GLib.markup_escape_text(n.bannerBodyText, -1);
|
|
|
|
}
|
|
|
|
|
|
|
|
let label = new St.Label({ style_class: 'unlock-dialog-notification-count-text' });
|
|
|
|
label.clutter_text.set_markup(`<b>${n.title}</b> ${body}`);
|
|
|
|
textBox.add(label);
|
|
|
|
|
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
box.visible = visible;
|
|
|
|
return [title, null];
|
|
|
|
}
|
|
|
|
|
|
|
|
_shouldShowDetails(source) {
|
|
|
|
return source.policy.detailsInLockScreen ||
|
|
|
|
source.narrowestPrivacyScope === MessageTray.PrivacyScope.SYSTEM;
|
|
|
|
}
|
|
|
|
|
2020-02-05 09:58:57 -05:00
|
|
|
_updateSourceBoxStyle(source, obj, box) {
|
|
|
|
let hasCriticalNotification =
|
|
|
|
source.notifications.some(n => n.urgency === MessageTray.Urgency.CRITICAL);
|
|
|
|
|
|
|
|
if (hasCriticalNotification !== obj.hasCriticalNotification) {
|
|
|
|
obj.hasCriticalNotification = hasCriticalNotification;
|
|
|
|
|
|
|
|
if (hasCriticalNotification)
|
|
|
|
box.add_style_class_name('critical');
|
|
|
|
else
|
|
|
|
box.remove_style_class_name('critical');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-28 16:35:13 -05:00
|
|
|
_showSource(source, obj, box) {
|
|
|
|
if (obj.detailed)
|
|
|
|
[obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box);
|
|
|
|
else
|
|
|
|
[obj.titleLabel, obj.countLabel] = this._makeNotificationSource(source, box);
|
|
|
|
|
|
|
|
box.visible = obj.visible && (source.unseenCount > 0);
|
2020-02-05 09:58:57 -05:00
|
|
|
|
|
|
|
this._updateSourceBoxStyle(source, obj, box);
|
2019-11-28 16:35:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_sourceAdded(tray, source, initial) {
|
|
|
|
let obj = {
|
|
|
|
visible: source.policy.showInLockScreen,
|
|
|
|
detailed: this._shouldShowDetails(source),
|
|
|
|
sourceDestroyId: 0,
|
|
|
|
sourceCountChangedId: 0,
|
|
|
|
sourceTitleChangedId: 0,
|
|
|
|
sourceUpdatedId: 0,
|
|
|
|
sourceBox: null,
|
|
|
|
titleLabel: null,
|
|
|
|
countLabel: null,
|
2020-02-05 09:58:57 -05:00
|
|
|
hasCriticalNotification: false,
|
2019-11-28 16:35:13 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
obj.sourceBox = new St.BoxLayout({
|
|
|
|
style_class: 'unlock-dialog-notification-source',
|
|
|
|
x_expand: true,
|
|
|
|
});
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
this._notificationBox.add_child(obj.sourceBox);
|
|
|
|
|
|
|
|
obj.sourceCountChangedId = source.connect('notify::count', () => {
|
|
|
|
this._countChanged(source, obj);
|
|
|
|
});
|
|
|
|
obj.sourceTitleChangedId = source.connect('notify::title', () => {
|
|
|
|
this._titleChanged(source, obj);
|
|
|
|
});
|
|
|
|
obj.policyChangedId = source.policy.connect('notify', (policy, pspec) => {
|
|
|
|
if (pspec.name === 'show-in-lock-screen')
|
|
|
|
this._visibleChanged(source, obj);
|
|
|
|
else
|
|
|
|
this._detailedChanged(source, obj);
|
|
|
|
});
|
|
|
|
obj.sourceDestroyId = source.connect('destroy', () => {
|
|
|
|
this._onSourceDestroy(source, obj);
|
|
|
|
});
|
|
|
|
|
|
|
|
this._sources.set(source, obj);
|
|
|
|
|
|
|
|
if (!initial) {
|
|
|
|
// block scrollbars while animating, if they're not needed now
|
|
|
|
let boxHeight = this._notificationBox.height;
|
|
|
|
if (this._scrollView.height >= boxHeight)
|
|
|
|
this._scrollView.vscrollbar_policy = St.PolicyType.NEVER;
|
|
|
|
|
|
|
|
let widget = obj.sourceBox;
|
|
|
|
let [, natHeight] = widget.get_preferred_height(-1);
|
|
|
|
widget.height = 0;
|
|
|
|
widget.ease({
|
|
|
|
height: natHeight,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
duration: 250,
|
|
|
|
onComplete: () => {
|
|
|
|
this._scrollView.vscrollbar_policy = St.PolicyType.AUTOMATIC;
|
|
|
|
widget.set_height(-1);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_titleChanged(source, obj) {
|
|
|
|
obj.titleLabel.text = source.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
_countChanged(source, obj) {
|
|
|
|
// A change in the number of notifications may change whether we show
|
|
|
|
// details.
|
|
|
|
let newDetailed = this._shouldShowDetails(source);
|
|
|
|
let oldDetailed = obj.detailed;
|
|
|
|
|
|
|
|
obj.detailed = newDetailed;
|
|
|
|
|
|
|
|
if (obj.detailed || oldDetailed !== newDetailed) {
|
|
|
|
// A new notification was pushed, or a previous notification was destroyed.
|
|
|
|
// Give up, and build the list again.
|
|
|
|
|
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
} else {
|
|
|
|
let count = source.unseenCount;
|
2019-11-29 14:05:12 -05:00
|
|
|
obj.countLabel.text = `${count}`;
|
2019-11-28 16:35:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
obj.sourceBox.visible = obj.visible && (source.unseenCount > 0);
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
|
|
|
|
_visibleChanged(source, obj) {
|
|
|
|
if (obj.visible === source.policy.showInLockScreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj.visible = source.policy.showInLockScreen;
|
|
|
|
obj.sourceBox.visible = obj.visible && source.unseenCount > 0;
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
|
|
|
|
_detailedChanged(source, obj) {
|
|
|
|
let newDetailed = this._shouldShowDetails(source);
|
|
|
|
if (obj.detailed === newDetailed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj.detailed = newDetailed;
|
|
|
|
|
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onSourceDestroy(source, obj) {
|
|
|
|
this._removeSource(source, obj);
|
|
|
|
this._updateVisibility();
|
|
|
|
}
|
|
|
|
|
|
|
|
_removeSource(source, obj) {
|
|
|
|
obj.sourceBox.destroy();
|
|
|
|
obj.sourceBox = obj.titleLabel = obj.countLabel = null;
|
|
|
|
|
|
|
|
source.disconnect(obj.sourceDestroyId);
|
|
|
|
source.disconnect(obj.sourceCountChangedId);
|
|
|
|
source.disconnect(obj.sourceTitleChangedId);
|
|
|
|
source.policy.disconnect(obj.policyChangedId);
|
|
|
|
|
|
|
|
this._sources.delete(source);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-11-28 16:16:53 -05:00
|
|
|
var Clock = GObject.registerClass(
|
|
|
|
class UnlockDialogClock extends St.BoxLayout {
|
|
|
|
_init() {
|
|
|
|
super._init({ style_class: 'unlock-dialog-clock', vertical: true });
|
|
|
|
|
|
|
|
this._time = new St.Label({
|
|
|
|
style_class: 'unlock-dialog-clock-time',
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
|
|
|
this._date = new St.Label({
|
|
|
|
style_class: 'unlock-dialog-clock-date',
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
|
|
|
|
|
|
|
this.add_child(this._time);
|
|
|
|
this.add_child(this._date);
|
|
|
|
|
|
|
|
this._wallClock = new GnomeDesktop.WallClock({ time_only: true });
|
|
|
|
this._wallClock.connect('notify::clock', this._updateClock.bind(this));
|
|
|
|
|
|
|
|
this._updateClock();
|
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
_updateClock() {
|
|
|
|
this._time.text = this._wallClock.clock;
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
/* Translators: This is a time format for a date in
|
|
|
|
long format */
|
2020-02-10 17:11:26 -05:00
|
|
|
let dateFormat = Shell.util_translate_time_string(N_('%A %B %-d'));
|
2019-11-28 16:16:53 -05:00
|
|
|
this._date.text = date.toLocaleFormat(dateFormat);
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
this._wallClock.run_dispose();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-11-29 11:36:47 -05:00
|
|
|
var UnlockDialogLayout = GObject.registerClass(
|
|
|
|
class UnlockDialogLayout extends Clutter.LayoutManager {
|
2019-11-29 12:36:01 -05:00
|
|
|
_init(stack, notifications) {
|
2019-11-29 11:36:47 -05:00
|
|
|
super._init();
|
|
|
|
|
2019-11-29 12:36:01 -05:00
|
|
|
this._stack = stack;
|
2019-11-29 11:36:47 -05:00
|
|
|
this._notifications = notifications;
|
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_width(container, forHeight) {
|
2019-11-29 12:36:01 -05:00
|
|
|
return this._stack.get_preferred_width(forHeight);
|
2019-11-29 11:36:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_height(container, forWidth) {
|
2019-11-29 12:36:01 -05:00
|
|
|
return this._stack.get_preferred_height(forWidth);
|
2019-11-29 11:36:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_allocate(container, box, flags) {
|
|
|
|
let [width, height] = box.get_size();
|
|
|
|
|
|
|
|
let tenthOfHeight = height / 10.0;
|
|
|
|
let thirdOfHeight = height / 3.0;
|
|
|
|
|
2019-11-29 12:36:01 -05:00
|
|
|
let [, , stackWidth, stackHeight] =
|
|
|
|
this._stack.get_preferred_size();
|
2019-11-29 11:36:47 -05:00
|
|
|
|
|
|
|
let [, , notificationsWidth, notificationsHeight] =
|
|
|
|
this._notifications.get_preferred_size();
|
|
|
|
|
2019-11-29 12:36:01 -05:00
|
|
|
let columnWidth = Math.max(stackWidth, notificationsWidth);
|
2019-11-29 11:36:47 -05:00
|
|
|
|
|
|
|
let columnX1 = Math.floor((width - columnWidth) / 2.0);
|
|
|
|
let actorBox = new Clutter.ActorBox();
|
|
|
|
|
|
|
|
// Notifications
|
|
|
|
let maxNotificationsHeight = Math.min(
|
|
|
|
notificationsHeight,
|
2019-11-29 12:36:01 -05:00
|
|
|
height - tenthOfHeight - stackHeight);
|
2019-11-29 11:36:47 -05:00
|
|
|
|
|
|
|
actorBox.x1 = columnX1;
|
|
|
|
actorBox.y1 = height - maxNotificationsHeight;
|
|
|
|
actorBox.x2 = columnX1 + columnWidth;
|
|
|
|
actorBox.y2 = actorBox.y1 + maxNotificationsHeight;
|
|
|
|
|
|
|
|
this._notifications.allocate(actorBox, flags);
|
|
|
|
|
|
|
|
// Authentication Box
|
2019-11-29 12:36:01 -05:00
|
|
|
let stackY = Math.min(
|
2019-11-29 11:36:47 -05:00
|
|
|
thirdOfHeight,
|
2019-11-29 12:36:01 -05:00
|
|
|
height - stackHeight - maxNotificationsHeight);
|
2019-11-29 11:36:47 -05:00
|
|
|
|
|
|
|
actorBox.x1 = columnX1;
|
2019-11-29 12:36:01 -05:00
|
|
|
actorBox.y1 = stackY;
|
2019-11-29 11:36:47 -05:00
|
|
|
actorBox.x2 = columnX1 + columnWidth;
|
2019-11-29 12:36:01 -05:00
|
|
|
actorBox.y2 = stackY + stackHeight;
|
2019-11-29 11:36:47 -05:00
|
|
|
|
2019-11-29 12:36:01 -05:00
|
|
|
this._stack.allocate(actorBox, flags);
|
2019-11-29 11:36:47 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-09-20 07:17:40 -04:00
|
|
|
var UnlockDialog = GObject.registerClass({
|
2019-11-28 16:22:55 -05:00
|
|
|
Signals: {
|
|
|
|
'failed': {},
|
|
|
|
'wake-up-screen': {},
|
|
|
|
},
|
2019-09-20 07:17:40 -04:00
|
|
|
}, class UnlockDialog extends St.Widget {
|
|
|
|
_init(parentActor) {
|
|
|
|
super._init({
|
|
|
|
accessible_role: Atk.Role.WINDOW,
|
|
|
|
style_class: 'login-dialog',
|
|
|
|
visible: false,
|
2019-12-02 10:35:00 -05:00
|
|
|
can_focus: true,
|
2019-11-29 12:37:10 -05:00
|
|
|
reactive: true,
|
2019-09-20 07:17:40 -04:00
|
|
|
});
|
2013-07-16 07:31:22 -04:00
|
|
|
|
2019-09-20 07:17:40 -04:00
|
|
|
parentActor.add_child(this);
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2019-11-29 12:37:10 -05:00
|
|
|
this._activePage = null;
|
|
|
|
|
|
|
|
let tapAction = new Clutter.TapAction();
|
|
|
|
tapAction.connect('tap', this._showPrompt.bind(this));
|
|
|
|
this.add_action(tapAction);
|
|
|
|
|
2019-11-28 17:16:55 -05:00
|
|
|
// Background
|
|
|
|
this._backgroundGroup = new Clutter.Actor();
|
|
|
|
this.add_child(this._backgroundGroup);
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
|
|
|
this._updateBackgrounds();
|
|
|
|
this._monitorsChangedId =
|
|
|
|
Main.layoutManager.connect('monitors-changed', this._updateBackgrounds.bind(this));
|
|
|
|
|
2012-05-20 12:30:14 -04:00
|
|
|
this._userManager = AccountsService.UserManager.get_default();
|
|
|
|
this._userName = GLib.get_user_name();
|
|
|
|
this._user = this._userManager.get_user(this._userName);
|
|
|
|
|
2019-11-29 12:36:01 -05:00
|
|
|
// Authentication & Clock stack
|
|
|
|
let stack = new Shell.Stack();
|
|
|
|
|
2019-11-29 11:36:47 -05:00
|
|
|
this._promptBox = new St.BoxLayout({ vertical: true });
|
2019-11-29 12:36:01 -05:00
|
|
|
stack.add_child(this._promptBox);
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2019-11-28 16:16:53 -05:00
|
|
|
this._clock = new Clock();
|
2019-11-29 12:36:01 -05:00
|
|
|
stack.add_child(this._clock);
|
2019-11-29 12:37:10 -05:00
|
|
|
this._showClock();
|
2019-11-28 16:16:53 -05:00
|
|
|
|
2012-10-24 11:53:19 -04:00
|
|
|
this.allowCancel = false;
|
2012-08-07 11:38:12 -04:00
|
|
|
|
2019-12-02 09:01:20 -05:00
|
|
|
Main.ctrlAltTabManager.addGroup(this, _('Unlock Window'), 'dialog-password-symbolic');
|
2012-08-10 23:53:59 -04:00
|
|
|
|
2019-11-28 16:35:13 -05:00
|
|
|
// Notifications
|
|
|
|
this._notificationsBox = new NotificationsBox();
|
|
|
|
this._notificationsBox.connect('wake-up-screen', () => this.emit('wake-up-screen'));
|
2019-11-29 11:36:47 -05:00
|
|
|
|
|
|
|
// Main Box
|
|
|
|
let mainBox = new Clutter.Actor();
|
|
|
|
mainBox.add_constraint(new Layout.MonitorConstraint({ primary: true }));
|
2019-11-29 12:36:01 -05:00
|
|
|
mainBox.add_child(stack);
|
2019-11-29 11:36:47 -05:00
|
|
|
mainBox.add_child(this._notificationsBox);
|
|
|
|
mainBox.layout_manager = new UnlockDialogLayout(
|
2019-11-29 12:36:01 -05:00
|
|
|
stack,
|
2019-11-29 11:36:47 -05:00
|
|
|
this._notificationsBox);
|
|
|
|
this.add_child(mainBox);
|
2019-11-28 16:35:13 -05:00
|
|
|
|
2013-08-14 09:47:27 -04:00
|
|
|
this._idleMonitor = Meta.IdleMonitor.get_core();
|
2017-12-01 19:27:35 -05:00
|
|
|
this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, this._escape.bind(this));
|
2019-09-20 07:17:40 -04:00
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2019-11-29 12:37:10 -05:00
|
|
|
vfunc_key_press_event(keyEvent) {
|
|
|
|
if (this._activePage === this._promptBox ||
|
|
|
|
(this._promptBox && this._promptBox.visible))
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
let unichar = keyEvent.unicode_value;
|
|
|
|
|
|
|
|
this._showPrompt();
|
|
|
|
|
|
|
|
if (GLib.unichar_isgraph(unichar))
|
|
|
|
this.addCharacter(unichar);
|
|
|
|
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
}
|
|
|
|
|
2019-11-28 17:16:55 -05:00
|
|
|
_createBackground(monitorIndex) {
|
|
|
|
let monitor = Main.layoutManager.monitors[monitorIndex];
|
|
|
|
let widget = new St.Widget({
|
|
|
|
style_class: 'screen-shield-background',
|
|
|
|
x: monitor.x,
|
|
|
|
y: monitor.y,
|
|
|
|
width: monitor.width,
|
|
|
|
height: monitor.height,
|
|
|
|
});
|
|
|
|
|
|
|
|
let bgManager = new Background.BackgroundManager({
|
|
|
|
container: widget,
|
|
|
|
monitorIndex,
|
|
|
|
controlPosition: false,
|
|
|
|
settingsSchema: SCREENSAVER_SCHEMA,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._bgManagers.push(bgManager);
|
|
|
|
|
|
|
|
this._backgroundGroup.add_child(widget);
|
2020-01-07 14:43:35 -05:00
|
|
|
|
2020-02-11 14:19:50 -05:00
|
|
|
const themeContext = St.ThemeContext.get_for_stage(global.stage);
|
|
|
|
|
|
|
|
let effect = new Shell.BlurEffect({
|
2020-01-07 14:43:35 -05:00
|
|
|
brightness: BLUR_BRIGHTNESS,
|
2020-02-11 14:19:50 -05:00
|
|
|
sigma: BLUR_SIGMA * themeContext.scale_factor,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._scaleChangedId = themeContext.connect('notify::scale-factor', () => {
|
|
|
|
effect.sigma = BLUR_SIGMA * themeContext.scale_factor;
|
|
|
|
});
|
|
|
|
|
|
|
|
widget.add_effect(effect);
|
2019-11-28 17:16:55 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_updateBackgrounds() {
|
|
|
|
for (let i = 0; i < this._bgManagers.length; i++)
|
|
|
|
this._bgManagers[i].destroy();
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
|
|
|
this._backgroundGroup.destroy_all_children();
|
|
|
|
|
|
|
|
for (let i = 0; i < Main.layoutManager.monitors.length; i++)
|
|
|
|
this._createBackground(i);
|
|
|
|
}
|
|
|
|
|
2019-12-02 09:01:20 -05:00
|
|
|
_ensureAuthPrompt() {
|
|
|
|
if (this._authPrompt)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._authPrompt = new AuthPrompt.AuthPrompt(new Gdm.Client(), AuthPrompt.AuthPromptMode.UNLOCK_ONLY);
|
|
|
|
this._authPrompt.connect('failed', this._fail.bind(this));
|
|
|
|
this._authPrompt.connect('cancelled', this._fail.bind(this));
|
|
|
|
this._authPrompt.connect('reset', this._onReset.bind(this));
|
|
|
|
|
|
|
|
this._promptBox.add_child(this._authPrompt);
|
|
|
|
|
|
|
|
this._authPrompt.reset();
|
|
|
|
this._updateSensitivity(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
_maybeDestroyAuthPrompt() {
|
|
|
|
let focus = global.stage.key_focus;
|
|
|
|
if (focus === null ||
|
2020-02-01 10:23:59 -05:00
|
|
|
(this._authPrompt && this._authPrompt.contains(focus)))
|
2019-12-02 09:01:20 -05:00
|
|
|
this.grab_key_focus();
|
|
|
|
|
|
|
|
if (this._authPrompt) {
|
|
|
|
this._authPrompt.destroy();
|
|
|
|
this._authPrompt = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_updateSensitivity(sensitive) {
|
2013-07-16 07:31:22 -04:00
|
|
|
this._authPrompt.updateSensitivity(sensitive);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-11-01 11:19:17 -04:00
|
|
|
|
2019-11-29 12:37:10 -05:00
|
|
|
_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,
|
2019-12-02 09:01:20 -05:00
|
|
|
onComplete: () => {
|
|
|
|
this._promptBox.hide();
|
|
|
|
this._maybeDestroyAuthPrompt();
|
|
|
|
},
|
2019-11-29 12:37:10 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
this._clock.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: CROSSFADE_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_showPrompt() {
|
2019-12-02 09:01:20 -05:00
|
|
|
this._ensureAuthPrompt();
|
|
|
|
|
2019-11-29 12:37:10 -05:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_fail() {
|
2019-11-29 14:14:26 -05:00
|
|
|
this._showClock();
|
2013-07-22 11:07:35 -04:00
|
|
|
this.emit('failed');
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-10-03 17:15:41 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onReset(authPrompt, beginRequest) {
|
2013-07-28 17:49:50 -04:00
|
|
|
let userName;
|
|
|
|
if (beginRequest == AuthPrompt.BeginRequestType.PROVIDE_USERNAME) {
|
|
|
|
this._authPrompt.setUser(this._user);
|
|
|
|
userName = this._userName;
|
|
|
|
} else {
|
|
|
|
userName = null;
|
|
|
|
}
|
|
|
|
|
2019-08-19 15:06:04 -04:00
|
|
|
this._authPrompt.begin({ userName });
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-07-28 17:49:50 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_escape() {
|
2013-07-28 16:06:04 -04:00
|
|
|
if (this.allowCancel)
|
2013-07-22 11:07:35 -04:00
|
|
|
this._authPrompt.cancel();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-03 13:26:30 -04:00
|
|
|
|
2019-09-20 07:17:40 -04:00
|
|
|
_onDestroy() {
|
2013-07-22 11:07:35 -04:00
|
|
|
this.popModal();
|
2012-08-16 15:24:53 -04:00
|
|
|
|
|
|
|
if (this._idleWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._idleWatchId);
|
|
|
|
this._idleWatchId = 0;
|
|
|
|
}
|
2019-11-28 17:16:55 -05:00
|
|
|
|
|
|
|
if (this._monitorsChangedId) {
|
|
|
|
Main.layoutManager.disconnect(this._monitorsChangedId);
|
|
|
|
delete this._monitorsChangedId;
|
|
|
|
}
|
2020-02-11 14:19:50 -05:00
|
|
|
|
|
|
|
let themeContext = St.ThemeContext.get_for_stage(global.stage);
|
|
|
|
if (this._scaleChangedId) {
|
|
|
|
themeContext.disconnect(this._scaleChangedId);
|
|
|
|
delete this._scaleChangedId;
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
cancel() {
|
2019-12-02 09:01:20 -05:00
|
|
|
if (this._authPrompt)
|
|
|
|
this._authPrompt.cancel();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-05 00:55:54 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
addCharacter(unichar) {
|
2019-11-29 12:37:10 -05:00
|
|
|
this._showPrompt();
|
2013-07-16 07:31:22 -04:00
|
|
|
this._authPrompt.addCharacter(unichar);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-07-18 08:58:58 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
finish(onComplete) {
|
2019-12-02 09:01:20 -05:00
|
|
|
this._ensureAuthPrompt();
|
2013-07-22 11:07:35 -04:00
|
|
|
this._authPrompt.finish(onComplete);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-07-16 07:31:22 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
open(timestamp) {
|
2019-09-20 07:17:40 -04:00
|
|
|
this.show();
|
2013-07-16 07:31:22 -04:00
|
|
|
|
|
|
|
if (this._isModal)
|
|
|
|
return true;
|
2013-07-18 08:58:58 -04:00
|
|
|
|
2019-09-20 07:17:40 -04:00
|
|
|
let modalParams = {
|
|
|
|
timestamp,
|
|
|
|
actionMode: Shell.ActionMode.UNLOCK_SCREEN,
|
|
|
|
};
|
|
|
|
if (!Main.pushModal(this, modalParams))
|
2013-07-16 07:31:22 -04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
this._isModal = true;
|
|
|
|
|
|
|
|
return true;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-07-16 07:31:22 -04:00
|
|
|
|
2020-01-30 09:44:43 -05:00
|
|
|
activate() {
|
|
|
|
this._showPrompt();
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
popModal(timestamp) {
|
2013-07-16 07:31:22 -04:00
|
|
|
if (this._isModal) {
|
2019-09-20 07:17:40 -04:00
|
|
|
Main.popModal(this, timestamp);
|
2013-07-16 07:31:22 -04:00
|
|
|
this._isModal = false;
|
|
|
|
}
|
2013-07-18 08:58:58 -04:00
|
|
|
}
|
2019-09-20 07:17:40 -04:00
|
|
|
});
|