2012-02-06 22:28:48 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2019-02-09 03:21:36 +00:00
|
|
|
const { AccountsService, Clutter, Cogl, Gio, GLib,
|
|
|
|
GnomeDesktop, GObject, Meta, Shell, St } = imports.gi;
|
2012-08-20 17:56:08 +00:00
|
|
|
const Cairo = imports.cairo;
|
2012-05-21 16:42:45 +00:00
|
|
|
const Signals = imports.signals;
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
const Background = imports.ui.background;
|
2012-02-06 22:28:48 +00:00
|
|
|
const GnomeSession = imports.misc.gnomeSession;
|
2012-08-14 13:39:17 +00:00
|
|
|
const Layout = imports.ui.layout;
|
2013-10-10 08:21:47 +00:00
|
|
|
const OVirt = imports.gdm.oVirt;
|
2012-08-18 12:05:52 +00:00
|
|
|
const LoginManager = imports.misc.loginManager;
|
2012-02-06 22:28:48 +00:00
|
|
|
const Lightbox = imports.ui.lightbox;
|
|
|
|
const Main = imports.ui.main;
|
2012-09-01 19:59:53 +00:00
|
|
|
const Overview = imports.ui.overview;
|
2012-05-22 22:02:00 +00:00
|
|
|
const MessageTray = imports.ui.messageTray;
|
2012-07-08 15:42:15 +00:00
|
|
|
const ShellDBus = imports.ui.shellDBus;
|
2013-06-27 12:54:19 +00:00
|
|
|
const SmartcardManager = imports.misc.smartcardManager;
|
2019-10-07 17:38:19 +00:00
|
|
|
const Params = imports.misc.params;
|
2012-02-06 22:28:48 +00:00
|
|
|
|
|
|
|
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
|
|
|
|
const LOCK_ENABLED_KEY = 'lock-enabled';
|
2012-12-25 00:13:52 +00:00
|
|
|
const LOCK_DELAY_KEY = 'lock-delay';
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2017-03-17 14:48:22 +00:00
|
|
|
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
|
|
|
|
const DISABLE_LOCK_KEY = 'disable-lock-screen';
|
|
|
|
|
2013-01-17 19:39:54 +00:00
|
|
|
const LOCKED_STATE_STR = 'screenShield.locked';
|
2019-10-07 17:38:19 +00:00
|
|
|
|
|
|
|
const BLUR_BRIGHTNESS = 0.55;
|
|
|
|
const BLUR_RADIUS = 70;
|
|
|
|
|
2012-05-24 20:47:48 +00:00
|
|
|
// fraction of screen height the arrow must reach before completing
|
|
|
|
// the slide up automatically
|
2017-07-18 17:47:27 +00:00
|
|
|
var ARROW_DRAG_THRESHOLD = 0.1;
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2017-07-18 17:47:27 +00:00
|
|
|
var SUMMARY_ICON_SIZE = 48;
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2013-01-29 15:04:19 +00:00
|
|
|
// ScreenShield animation time
|
|
|
|
// - STANDARD_FADE_TIME is used when the session goes idle
|
|
|
|
// - MANUAL_FADE_TIME is used for lowering the shield when asked by the user,
|
|
|
|
// or when cancelling the dialog
|
|
|
|
// - CURTAIN_SLIDE_TIME is used when raising the shield before unlocking
|
2019-08-01 23:13:10 +00:00
|
|
|
var STANDARD_FADE_TIME = 10000;
|
|
|
|
var MANUAL_FADE_TIME = 300;
|
|
|
|
var CURTAIN_SLIDE_TIME = 300;
|
2012-06-02 22:10:23 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var Clock = class {
|
|
|
|
constructor() {
|
2012-05-27 22:50:56 +00:00
|
|
|
this.actor = new St.BoxLayout({ style_class: 'screen-shield-clock',
|
|
|
|
vertical: true });
|
|
|
|
|
|
|
|
this._time = new St.Label({ style_class: 'screen-shield-clock-time' });
|
|
|
|
this._date = new St.Label({ style_class: 'screen-shield-clock-date' });
|
|
|
|
|
|
|
|
this.actor.add(this._time, { x_align: St.Align.MIDDLE });
|
|
|
|
this.actor.add(this._date, { x_align: St.Align.MIDDLE });
|
|
|
|
|
|
|
|
this._wallClock = new GnomeDesktop.WallClock({ time_only: true });
|
2017-12-02 00:27:35 +00:00
|
|
|
this._wallClock.connect('notify::clock', this._updateClock.bind(this));
|
2012-05-27 22:50:56 +00:00
|
|
|
|
|
|
|
this._updateClock();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-27 22:50:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateClock() {
|
2012-05-27 22:50:56 +00:00
|
|
|
this._time.text = this._wallClock.clock;
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
/* Translators: This is a time format for a date in
|
|
|
|
long format */
|
2014-11-08 16:45:13 +00:00
|
|
|
let dateFormat = Shell.util_translate_time_string(N_("%A, %B %d"));
|
2014-10-16 12:38:13 +00:00
|
|
|
this._date.text = date.toLocaleFormat(dateFormat);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-27 22:50:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
destroy() {
|
2012-05-27 22:50:56 +00:00
|
|
|
this.actor.destroy();
|
|
|
|
this._wallClock.run_dispose();
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-05-27 22:50:56 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
var NotificationsBox = class {
|
|
|
|
constructor() {
|
2012-05-22 22:02:00 +00:00
|
|
|
this.actor = new St.BoxLayout({ vertical: true,
|
|
|
|
name: 'screenShieldNotifications',
|
2015-02-05 16:42:19 +00:00
|
|
|
style_class: 'screen-shield-notifications-container' });
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2012-12-03 18:43:04 +00:00
|
|
|
this._scrollView = new St.ScrollView({ x_fill: false, x_align: St.Align.START,
|
2018-11-27 12:45:36 +00:00
|
|
|
hscrollbar_policy: St.PolicyType.NEVER });
|
2013-01-30 18:47:55 +00:00
|
|
|
this._notificationBox = new St.BoxLayout({ vertical: true,
|
2015-02-08 17:56:37 +00:00
|
|
|
style_class: 'screen-shield-notifications-container' });
|
2012-12-03 18:43:04 +00:00
|
|
|
this._scrollView.add_actor(this._notificationBox);
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2012-12-03 18:43:04 +00:00
|
|
|
this.actor.add(this._scrollView, { x_fill: true, x_align: St.Align.START });
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2014-01-14 22:49:47 +00:00
|
|
|
this._sources = new Map();
|
2017-10-31 00:38:18 +00:00
|
|
|
Main.messageTray.getSources().forEach(source => {
|
2013-01-30 18:47:55 +00:00
|
|
|
this._sourceAdded(Main.messageTray, source, true);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-08-16 20:38:22 +00:00
|
|
|
this._updateVisibility();
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this._sourceAddedId = Main.messageTray.connect('source-added', this._sourceAdded.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
destroy() {
|
2013-01-30 18:47:55 +00:00
|
|
|
if (this._sourceAddedId) {
|
|
|
|
Main.messageTray.disconnect(this._sourceAddedId);
|
|
|
|
this._sourceAddedId = 0;
|
2012-05-22 22:02:00 +00:00
|
|
|
}
|
|
|
|
|
2014-01-14 22:49:47 +00:00
|
|
|
let items = this._sources.entries();
|
|
|
|
for (let [source, obj] of items) {
|
2013-01-30 18:47:55 +00:00
|
|
|
this._removeSource(source, obj);
|
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
|
|
|
this.actor.destroy();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateVisibility() {
|
2017-10-31 00:38:18 +00:00
|
|
|
this._notificationBox.visible =
|
|
|
|
this._notificationBox.get_children().some(a => a.visible);
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2015-02-11 16:01:11 +00:00
|
|
|
this.actor.visible = this._notificationBox.visible;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_makeNotificationCountText(count, isChat) {
|
2012-08-06 15:28:55 +00:00
|
|
|
if (isChat)
|
|
|
|
return ngettext("%d new message", "%d new messages", count).format(count);
|
2012-05-22 22:02:00 +00:00
|
|
|
else
|
2012-08-06 15:28:55 +00:00
|
|
|
return ngettext("%d new notification", "%d new notifications", count).format(count);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_makeNotificationSource(source, box) {
|
2012-05-22 22:02:00 +00:00
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
2018-07-06 08:55:23 +00:00
|
|
|
box.add(sourceActor, { y_fill: true });
|
2012-05-22 22:02:00 +00:00
|
|
|
|
|
|
|
let textBox = new St.BoxLayout({ vertical: true });
|
2012-10-10 21:07:39 +00:00
|
|
|
box.add(textBox, { y_fill: false, y_align: St.Align.START });
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
let title = new St.Label({ text: source.title,
|
2012-05-22 22:02:00 +00:00
|
|
|
style_class: 'screen-shield-notification-label' });
|
2013-01-30 18:47:55 +00:00
|
|
|
textBox.add(title);
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2012-08-06 15:28:55 +00:00
|
|
|
let count = source.unseenCount;
|
|
|
|
let countLabel = new St.Label({ text: this._makeNotificationCountText(count, source.isChat),
|
2012-05-22 22:02:00 +00:00
|
|
|
style_class: 'screen-shield-notification-count-text' });
|
|
|
|
textBox.add(countLabel);
|
|
|
|
|
2012-08-06 15:28:55 +00:00
|
|
|
box.visible = count != 0;
|
2013-01-30 18:47:55 +00:00
|
|
|
return [title, countLabel];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-30 18:47:55 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_makeNotificationDetailedSource(source, box) {
|
2013-01-30 18:47:55 +00:00
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
2013-02-14 16:13:13 +00:00
|
|
|
let sourceBin = new St.Bin({ y_align: St.Align.START,
|
|
|
|
x_align: St.Align.START,
|
2018-07-06 08:55:23 +00:00
|
|
|
child: sourceActor });
|
2013-02-14 16:13:13 +00:00
|
|
|
box.add(sourceBin);
|
2013-01-30 18:47:55 +00:00
|
|
|
|
|
|
|
let textBox = new St.BoxLayout({ vertical: true });
|
|
|
|
box.add(textBox, { y_fill: false, y_align: St.Align.START });
|
|
|
|
|
|
|
|
let title = new St.Label({ text: source.title,
|
|
|
|
style_class: 'screen-shield-notification-label' });
|
|
|
|
textBox.add(title);
|
|
|
|
|
|
|
|
let visible = false;
|
|
|
|
for (let i = 0; i < source.notifications.length; i++) {
|
|
|
|
let n = source.notifications[i];
|
|
|
|
|
2015-02-11 16:01:11 +00:00
|
|
|
if (n.acknowledged)
|
2013-01-30 18:47:55 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
let body = '';
|
2013-01-31 12:33:31 +00:00
|
|
|
if (n.bannerBodyText) {
|
2019-08-19 19:33:15 +00:00
|
|
|
body = n.bannerBodyMarkup
|
|
|
|
? n.bannerBodyText
|
|
|
|
: GLib.markup_escape_text(n.bannerBodyText, -1);
|
2013-01-31 12:33:31 +00:00
|
|
|
}
|
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
let label = new St.Label({ style_class: 'screen-shield-notification-count-text' });
|
|
|
|
label.clutter_text.set_markup('<b>' + n.title + '</b> ' + body);
|
|
|
|
textBox.add(label);
|
|
|
|
|
|
|
|
visible = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
box.visible = visible;
|
|
|
|
return [title, null];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-30 18:47:55 +00:00
|
|
|
|
2018-11-01 20:56:25 +00:00
|
|
|
_shouldShowDetails(source) {
|
|
|
|
return source.policy.detailsInLockScreen ||
|
|
|
|
source.narrowestPrivacyScope == MessageTray.PrivacyScope.SYSTEM;
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_showSource(source, obj, box) {
|
2013-01-30 18:47:55 +00:00
|
|
|
if (obj.detailed) {
|
|
|
|
[obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box);
|
|
|
|
} else {
|
|
|
|
[obj.titleLabel, obj.countLabel] = this._makeNotificationSource(source, box);
|
|
|
|
}
|
|
|
|
|
2015-02-11 16:01:11 +00:00
|
|
|
box.visible = obj.visible && (source.unseenCount > 0);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_sourceAdded(tray, source, initial) {
|
2012-05-22 22:02:00 +00:00
|
|
|
let obj = {
|
2013-01-30 18:47:55 +00:00
|
|
|
visible: source.policy.showInLockScreen,
|
2018-11-01 20:56:25 +00:00
|
|
|
detailed: this._shouldShowDetails(source),
|
2012-05-22 22:02:00 +00:00
|
|
|
sourceDestroyId: 0,
|
2013-01-30 18:47:55 +00:00
|
|
|
sourceCountChangedId: 0,
|
|
|
|
sourceTitleChangedId: 0,
|
|
|
|
sourceUpdatedId: 0,
|
2012-05-22 22:02:00 +00:00
|
|
|
sourceBox: null,
|
2013-01-30 18:47:55 +00:00
|
|
|
titleLabel: null,
|
2012-05-22 22:02:00 +00:00
|
|
|
countLabel: null,
|
|
|
|
};
|
|
|
|
|
2015-02-08 17:56:37 +00:00
|
|
|
obj.sourceBox = new St.BoxLayout({ style_class: 'screen-shield-notification-source',
|
|
|
|
x_expand: true });
|
2013-01-30 18:47:55 +00:00
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
this._notificationBox.add(obj.sourceBox, { x_fill: false, x_align: St.Align.START });
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
obj.sourceCountChangedId = source.connect('count-updated', source => {
|
2013-01-30 18:47:55 +00:00
|
|
|
this._countChanged(source, obj);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
obj.sourceTitleChangedId = source.connect('title-changed', source => {
|
2013-01-30 18:47:55 +00:00
|
|
|
this._titleChanged(source, obj);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
obj.policyChangedId = source.policy.connect('policy-changed', (policy, key) => {
|
2013-01-30 18:47:55 +00:00
|
|
|
if (key == 'show-in-lock-screen')
|
|
|
|
this._visibleChanged(source, obj);
|
|
|
|
else
|
|
|
|
this._detailedChanged(source, obj);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
obj.sourceDestroyId = source.connect('destroy', source => {
|
2013-01-30 18:47:55 +00:00
|
|
|
this._onSourceDestroy(source, obj);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
this._sources.set(source, obj);
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2012-12-03 18:43:04 +00:00
|
|
|
if (!initial) {
|
|
|
|
// block scrollbars while animating, if they're not needed now
|
|
|
|
let boxHeight = this._notificationBox.height;
|
|
|
|
if (this._scrollView.height >= boxHeight)
|
2018-11-27 12:45:36 +00:00
|
|
|
this._scrollView.vscrollbar_policy = St.PolicyType.NEVER;
|
2012-12-03 18:43:04 +00:00
|
|
|
|
|
|
|
let widget = obj.sourceBox;
|
|
|
|
let [, natHeight] = widget.get_preferred_height(-1);
|
|
|
|
widget.height = 0;
|
2018-07-20 19:46:19 +00:00
|
|
|
widget.ease({
|
|
|
|
height: natHeight,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
duration: 250,
|
|
|
|
onComplete: () => {
|
|
|
|
this._scrollView.vscrollbar_policy = St.PolicyType.AUTOMATIC;
|
|
|
|
widget.set_height(-1);
|
|
|
|
}
|
|
|
|
});
|
2013-07-14 14:20:49 +00:00
|
|
|
|
2012-08-16 20:38:22 +00:00
|
|
|
this._updateVisibility();
|
2015-02-26 22:31:46 +00:00
|
|
|
if (obj.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
2012-12-03 18:43:04 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_titleChanged(source, obj) {
|
2013-01-30 18:47:55 +00:00
|
|
|
obj.titleLabel.text = source.title;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_countChanged(source, obj) {
|
2018-11-01 20:56:25 +00:00
|
|
|
// 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) {
|
2013-01-30 18:47:55 +00:00
|
|
|
// A new notification was pushed, or a previous notification was destroyed.
|
|
|
|
// Give up, and build the list again.
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
} else {
|
|
|
|
let count = source.unseenCount;
|
|
|
|
obj.countLabel.text = this._makeNotificationCountText(count, source.isChat);
|
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2015-02-11 16:01:11 +00:00
|
|
|
obj.sourceBox.visible = obj.visible && (source.unseenCount > 0);
|
2013-07-14 14:20:49 +00:00
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
this._updateVisibility();
|
2013-07-14 14:20:49 +00:00
|
|
|
if (obj.sourceBox.visible)
|
2014-03-10 18:16:03 +00:00
|
|
|
this.emit('wake-up-screen');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_visibleChanged(source, obj) {
|
2013-01-30 18:47:55 +00:00
|
|
|
if (obj.visible == source.policy.showInLockScreen)
|
2012-05-22 22:02:00 +00:00
|
|
|
return;
|
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
obj.visible = source.policy.showInLockScreen;
|
2015-02-11 16:01:11 +00:00
|
|
|
obj.sourceBox.visible = obj.visible && source.unseenCount > 0;
|
2012-05-22 22:02:00 +00:00
|
|
|
|
|
|
|
this._updateVisibility();
|
2013-07-14 14:20:49 +00:00
|
|
|
if (obj.sourceBox.visible)
|
2014-03-10 18:16:03 +00:00
|
|
|
this.emit('wake-up-screen');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_detailedChanged(source, obj) {
|
2018-11-01 20:56:25 +00:00
|
|
|
let newDetailed = this._shouldShowDetails(source);
|
|
|
|
if (obj.detailed == newDetailed)
|
2013-01-30 18:47:55 +00:00
|
|
|
return;
|
|
|
|
|
2018-11-01 20:56:25 +00:00
|
|
|
obj.detailed = newDetailed;
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onSourceDestroy(source, obj) {
|
2013-01-30 18:47:55 +00:00
|
|
|
this._removeSource(source, obj);
|
2012-05-22 22:02:00 +00:00
|
|
|
this._updateVisibility();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_removeSource(source, obj) {
|
2013-01-30 18:47:55 +00:00
|
|
|
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);
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2013-01-30 18:47:55 +00:00
|
|
|
this._sources.delete(source);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
|
|
|
};
|
2014-03-10 18:16:03 +00:00
|
|
|
Signals.addSignalMethods(NotificationsBox.prototype);
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2012-08-31 14:36:40 +00:00
|
|
|
function clamp(value, min, max) {
|
|
|
|
return Math.max(min, Math.min(max, value));
|
|
|
|
}
|
|
|
|
|
2012-02-06 22:28:48 +00:00
|
|
|
/**
|
|
|
|
* If you are setting org.gnome.desktop.session.idle-delay directly in dconf,
|
|
|
|
* rather than through System Settings, you also need to set
|
|
|
|
* org.gnome.settings-daemon.plugins.power.sleep-display-ac and
|
|
|
|
* org.gnome.settings-daemon.plugins.power.sleep-display-battery to the same value.
|
|
|
|
* This will ensure that the screen blanks at the right time when it fades out.
|
2014-08-21 20:48:43 +00:00
|
|
|
* https://bugzilla.gnome.org/show_bug.cgi?id=668703 explains the dependency.
|
2012-02-06 22:28:48 +00:00
|
|
|
*/
|
2017-10-31 01:19:44 +00:00
|
|
|
var ScreenShield = class {
|
|
|
|
constructor() {
|
2012-05-22 21:22:38 +00:00
|
|
|
this.actor = Main.layoutManager.screenShieldGroup;
|
|
|
|
|
2012-08-26 21:15:59 +00:00
|
|
|
this._lockScreenState = MessageTray.State.HIDDEN;
|
2019-02-12 14:02:09 +00:00
|
|
|
this._lockScreenGroup = new St.Widget({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
reactive: true,
|
|
|
|
can_focus: true,
|
|
|
|
name: 'lockScreenGroup',
|
|
|
|
visible: false,
|
|
|
|
});
|
2013-03-11 18:26:18 +00:00
|
|
|
this._lockScreenGroup.connect('key-press-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onLockScreenKeyPress.bind(this));
|
2012-09-02 12:48:08 +00:00
|
|
|
this._lockScreenGroup.connect('scroll-event',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._onLockScreenScroll.bind(this));
|
2012-08-11 03:53:59 +00:00
|
|
|
Main.ctrlAltTabManager.addGroup(this._lockScreenGroup, _("Lock"), 'changes-prevent-symbolic');
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2012-08-14 13:39:17 +00:00
|
|
|
this._lockScreenContents = new St.Widget({ layout_manager: new Clutter.BinLayout(),
|
|
|
|
name: 'lockScreenContents' });
|
|
|
|
this._lockScreenContents.add_constraint(new Layout.MonitorConstraint({ primary: true }));
|
|
|
|
|
|
|
|
this._lockScreenGroup.add_actor(this._lockScreenContents);
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2012-08-31 14:36:40 +00:00
|
|
|
this._dragAction = new Clutter.GestureAction();
|
2017-12-02 00:27:35 +00:00
|
|
|
this._dragAction.connect('gesture-begin', this._onDragBegin.bind(this));
|
|
|
|
this._dragAction.connect('gesture-progress', this._onDragMotion.bind(this));
|
|
|
|
this._dragAction.connect('gesture-end', this._onDragEnd.bind(this));
|
2012-08-31 14:36:40 +00:00
|
|
|
this._lockScreenGroup.add_action(this._dragAction);
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2012-08-14 13:39:17 +00:00
|
|
|
this._lockDialogGroup = new St.Widget({ x_expand: true,
|
|
|
|
y_expand: true,
|
2013-08-12 13:14:37 +00:00
|
|
|
reactive: true,
|
2012-09-01 19:59:53 +00:00
|
|
|
pivot_point: new Clutter.Point({ x: 0.5, y: 0.5 }),
|
2012-08-14 13:39:17 +00:00
|
|
|
name: 'lockDialogGroup' });
|
|
|
|
|
2012-05-24 20:47:48 +00:00
|
|
|
this.actor.add_actor(this._lockDialogGroup);
|
|
|
|
this.actor.add_actor(this._lockScreenGroup);
|
|
|
|
|
2019-10-07 17:32:31 +00:00
|
|
|
this._backgroundGroup = new Clutter.Actor();
|
|
|
|
this._lockDialogGroup.add_actor(this._backgroundGroup);
|
|
|
|
this._backgroundGroup.lower_bottom();
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
|
|
|
this._updateBackgrounds();
|
|
|
|
Main.layoutManager.connect('monitors-changed', this._updateBackgrounds.bind(this));
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
this._presence = new GnomeSession.Presence((proxy, error) => {
|
2012-02-06 22:28:48 +00:00
|
|
|
if (error) {
|
|
|
|
logError(error, 'Error while reading gnome-session presence');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._onStatusChanged(proxy.status);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
|
|
|
this._presence.connectSignal('StatusChanged', (proxy, senderName, [status]) => {
|
2012-02-06 22:28:48 +00:00
|
|
|
this._onStatusChanged(status);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2012-07-08 15:42:15 +00:00
|
|
|
this._screenSaverDBus = new ShellDBus.ScreenSaverDBus(this);
|
|
|
|
|
2013-06-27 12:54:19 +00:00
|
|
|
this._smartcardManager = SmartcardManager.getSmartcardManager();
|
|
|
|
this._smartcardManager.connect('smartcard-inserted',
|
2017-10-31 00:38:18 +00:00
|
|
|
(manager, token) => {
|
2013-06-27 12:54:19 +00:00
|
|
|
if (this._isLocked && token.UsedToLogin)
|
|
|
|
this._liftShield(true, 0);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2013-06-27 12:54:19 +00:00
|
|
|
|
2013-10-10 08:21:47 +00:00
|
|
|
this._oVirtCredentialsManager = OVirt.getOVirtCredentialsManager();
|
|
|
|
this._oVirtCredentialsManager.connect('user-authenticated',
|
2017-10-31 00:38:18 +00:00
|
|
|
() => {
|
2013-10-10 08:21:47 +00:00
|
|
|
if (this._isLocked)
|
|
|
|
this._liftShield(true, 0);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2013-10-10 08:21:47 +00:00
|
|
|
|
2012-08-18 12:05:52 +00:00
|
|
|
this._loginManager = LoginManager.getLoginManager();
|
2012-10-23 13:48:49 +00:00
|
|
|
this._loginManager.connect('prepare-for-sleep',
|
2017-12-02 00:27:35 +00:00
|
|
|
this._prepareForSleep.bind(this));
|
2012-10-23 13:48:49 +00:00
|
|
|
|
2015-05-13 19:42:13 +00:00
|
|
|
this._loginSession = null;
|
2017-10-31 00:38:18 +00:00
|
|
|
this._loginManager.getCurrentSessionProxy(sessionProxy => {
|
|
|
|
this._loginSession = sessionProxy;
|
|
|
|
this._loginSession.connectSignal('Lock',
|
2019-01-28 00:42:00 +00:00
|
|
|
() => this.lock(false));
|
2017-10-31 00:38:18 +00:00
|
|
|
this._loginSession.connectSignal('Unlock',
|
2019-01-28 00:42:00 +00:00
|
|
|
() => this.deactivate(false));
|
2017-12-02 00:27:35 +00:00
|
|
|
this._loginSession.connect('g-properties-changed', this._syncInhibitor.bind(this));
|
2017-10-31 00:38:18 +00:00
|
|
|
this._syncInhibitor();
|
|
|
|
});
|
2012-08-17 12:24:17 +00:00
|
|
|
|
2014-06-24 19:17:09 +00:00
|
|
|
this._settings = new Gio.Settings({ schema_id: SCREENSAVER_SCHEMA });
|
2019-01-30 00:18:24 +00:00
|
|
|
this._settings.connect(`changed::${LOCK_ENABLED_KEY}`, this._syncInhibitor.bind(this));
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2017-03-17 14:48:22 +00:00
|
|
|
this._lockSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
|
2019-01-30 00:18:24 +00:00
|
|
|
this._lockSettings.connect(`changed::${DISABLE_LOCK_KEY}`, this._syncInhibitor.bind(this));
|
2017-03-17 14:48:22 +00:00
|
|
|
|
2012-05-21 16:42:45 +00:00
|
|
|
this._isModal = false;
|
2012-05-27 22:50:56 +00:00
|
|
|
this._hasLockScreen = false;
|
2012-08-26 14:53:08 +00:00
|
|
|
this._isGreeter = false;
|
|
|
|
this._isActive = false;
|
2013-02-02 16:10:45 +00:00
|
|
|
this._isLocked = false;
|
2012-09-21 22:06:26 +00:00
|
|
|
this._inUnlockAnimation = false;
|
2012-10-16 14:38:32 +00:00
|
|
|
this._activationTime = 0;
|
2013-01-17 22:55:17 +00:00
|
|
|
this._becameActiveId = 0;
|
2013-01-27 14:45:04 +00:00
|
|
|
this._lockTimeoutId = 0;
|
2012-05-22 21:22:38 +00:00
|
|
|
|
2013-08-17 17:40:09 +00:00
|
|
|
// The "long" lightbox is used for the longer (20 seconds) fade from session
|
|
|
|
// to idle status, the "short" is used for quickly fading to black when locking
|
|
|
|
// manually
|
|
|
|
this._longLightbox = new Lightbox.Lightbox(Main.uiGroup,
|
|
|
|
{ inhibitEvents: true,
|
|
|
|
fadeFactor: 1 });
|
2017-12-02 00:27:35 +00:00
|
|
|
this._longLightbox.connect('shown', this._onLongLightboxShown.bind(this));
|
2013-08-17 17:40:09 +00:00
|
|
|
this._shortLightbox = new Lightbox.Lightbox(Main.uiGroup,
|
|
|
|
{ inhibitEvents: true,
|
|
|
|
fadeFactor: 1 });
|
2017-12-02 00:27:35 +00:00
|
|
|
this._shortLightbox.connect('shown', this._onShortLightboxShown.bind(this));
|
2012-10-28 11:26:21 +00:00
|
|
|
|
2013-08-14 13:47:27 +00:00
|
|
|
this.idleMonitor = Meta.IdleMonitor.get_core();
|
2018-01-03 07:55:38 +00:00
|
|
|
this._cursorTracker = Meta.CursorTracker.get_for_display(global.display);
|
2015-05-13 19:41:07 +00:00
|
|
|
|
|
|
|
this._syncInhibitor();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2015-05-13 19:41:07 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_setActive(active) {
|
2015-05-13 19:41:07 +00:00
|
|
|
let prevIsActive = this._isActive;
|
|
|
|
this._isActive = active;
|
|
|
|
|
|
|
|
if (prevIsActive != this._isActive)
|
|
|
|
this.emit('active-changed');
|
|
|
|
|
2016-05-12 07:25:49 +00:00
|
|
|
if (this._loginSession)
|
|
|
|
this._loginSession.SetLockedHintRemote(active);
|
|
|
|
|
2015-05-13 19:41:07 +00:00
|
|
|
this._syncInhibitor();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-22 21:22:38 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_createBackground(monitorIndex) {
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 22:32:25 +00:00
|
|
|
let monitor = Main.layoutManager.monitors[monitorIndex];
|
|
|
|
let widget = new St.Widget({ style_class: 'screen-shield-background',
|
2019-10-07 17:38:19 +00:00
|
|
|
clip_to_allocation: true,
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 22:32:25 +00:00
|
|
|
x: monitor.x,
|
|
|
|
y: monitor.y,
|
|
|
|
width: monitor.width,
|
|
|
|
height: monitor.height });
|
|
|
|
|
|
|
|
let bgManager = new Background.BackgroundManager({ container: widget,
|
2012-12-24 14:20:39 +00:00
|
|
|
monitorIndex: monitorIndex,
|
2013-08-19 22:51:34 +00:00
|
|
|
controlPosition: false,
|
|
|
|
settingsSchema: SCREENSAVER_SCHEMA });
|
2012-12-24 14:20:39 +00:00
|
|
|
|
|
|
|
this._bgManagers.push(bgManager);
|
|
|
|
|
ScreenShield: fix positioning of background with multimonitor
Previously, we would create one StBin per monitor, but each was positioned
at 0,0 and sized as the screen, so they would overlap and draw the box shadows
on top of the other backgrounds.
Instead, we need to size appropriately the bin, and then we need to position
the actual MetaBacgroundActor at 0,0, so add a flag to BackgroundManager
for this.
Also, get rid of MetaBackgroundGroup, they do nothing because the screenshield
is not a descendant of the MetaWindowGroup and because the widget in between
blocks the propagation of the visible region. At the same time, use a
widget, not a bin, because StBin requires you to set .child, not call add_child().
https://bugzilla.gnome.org/show_bug.cgi?id=694394
2013-02-21 22:32:25 +00:00
|
|
|
this._backgroundGroup.add_child(widget);
|
2019-10-07 17:38:19 +00:00
|
|
|
|
|
|
|
widget.add_effect(new Shell.BlurEffect({
|
|
|
|
blur_radius: BLUR_RADIUS,
|
|
|
|
vertical: true,
|
|
|
|
}));
|
|
|
|
widget.add_effect(new Shell.BlurEffect({
|
|
|
|
blur_radius: BLUR_RADIUS,
|
|
|
|
brightness: BLUR_BRIGHTNESS,
|
|
|
|
}));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_updateBackgrounds() {
|
2019-10-07 17:32:31 +00:00
|
|
|
let isGreeter = Main.sessionMode.isGreeter;
|
|
|
|
this._backgroundGroup.visible = !isGreeter;
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
for (let i = 0; i < this._bgManagers.length; i++)
|
|
|
|
this._bgManagers[i].destroy();
|
|
|
|
|
2019-10-07 17:32:31 +00:00
|
|
|
if (isGreeter)
|
|
|
|
return;
|
|
|
|
|
2012-12-24 14:20:39 +00:00
|
|
|
this._bgManagers = [];
|
2013-04-04 20:59:39 +00:00
|
|
|
this._backgroundGroup.destroy_all_children();
|
2012-12-24 14:20:39 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < Main.layoutManager.monitors.length; i++)
|
|
|
|
this._createBackground(i);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-12-24 14:20:39 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_liftShield(onPrimary, velocity) {
|
2013-01-27 14:45:04 +00:00
|
|
|
if (this._isLocked) {
|
2013-06-08 14:03:14 +00:00
|
|
|
if (this._ensureUnlockDialog(onPrimary, true /* allowCancel */))
|
|
|
|
this._hideLockScreen(true /* animate */, velocity);
|
2013-01-27 14:45:04 +00:00
|
|
|
} else {
|
|
|
|
this.deactivate(true /* animate */);
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-27 14:45:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_maybeCancelDialog() {
|
2013-06-08 17:04:36 +00:00
|
|
|
if (!this._dialog)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._dialog.cancel();
|
|
|
|
if (this._isGreeter) {
|
|
|
|
// LoginDialog.cancel() will grab the key focus
|
|
|
|
// on its own, so ensure it stays on lock screen
|
|
|
|
// instead
|
|
|
|
this._lockScreenGroup.grab_key_focus();
|
|
|
|
} else {
|
|
|
|
this._dialog = null;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-06-08 17:04:36 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_becomeModal() {
|
2012-11-26 19:18:57 +00:00
|
|
|
if (this._isModal)
|
|
|
|
return true;
|
|
|
|
|
2014-12-11 14:35:40 +00:00
|
|
|
this._isModal = Main.pushModal(this.actor, { actionMode: Shell.ActionMode.LOCK_SCREEN });
|
2012-11-26 19:18:57 +00:00
|
|
|
if (this._isModal)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// We failed to get a pointer grab, it means that
|
|
|
|
// something else has it. Try with a keyboard grab only
|
|
|
|
this._isModal = Main.pushModal(this.actor, { options: Meta.ModalOptions.POINTER_ALREADY_GRABBED,
|
2014-12-11 14:35:40 +00:00
|
|
|
actionMode: Shell.ActionMode.LOCK_SCREEN });
|
2012-11-26 19:18:57 +00:00
|
|
|
return this._isModal;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-11-26 19:18:57 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onLockScreenKeyPress(actor, event) {
|
2012-09-12 19:52:59 +00:00
|
|
|
let symbol = event.get_key_symbol();
|
2012-11-05 20:38:50 +00:00
|
|
|
let unichar = event.get_key_unicode();
|
2012-09-12 19:52:59 +00:00
|
|
|
|
2012-10-03 21:13:25 +00:00
|
|
|
// Do nothing if the lock screen is not fully shown.
|
|
|
|
// This avoids reusing the previous (and stale) unlock
|
|
|
|
// dialog if esc is pressed while the curtain is going
|
|
|
|
// down after cancel.
|
|
|
|
|
|
|
|
if (this._lockScreenState != MessageTray.State.SHOWN)
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-10-03 21:13:25 +00:00
|
|
|
|
2013-07-16 16:40:50 +00:00
|
|
|
let isEnter = (symbol == Clutter.KEY_Return ||
|
|
|
|
symbol == Clutter.KEY_KP_Enter ||
|
|
|
|
symbol == Clutter.KEY_ISO_Enter);
|
2016-10-21 16:03:44 +00:00
|
|
|
let isEscape = (symbol == Clutter.KEY_Escape);
|
|
|
|
let isLiftChar = (GLib.unichar_isprint(unichar) &&
|
|
|
|
(this._isLocked || !GLib.unichar_isgraph(unichar)));
|
|
|
|
if (!isEnter && !isEscape && !isLiftChar)
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2013-06-08 16:59:20 +00:00
|
|
|
if (this._isLocked &&
|
|
|
|
this._ensureUnlockDialog(true, true) &&
|
2013-06-08 14:03:14 +00:00
|
|
|
GLib.unichar_isgraph(unichar))
|
2013-03-05 05:55:54 +00:00
|
|
|
this._dialog.addCharacter(unichar);
|
|
|
|
|
2012-11-05 20:38:50 +00:00
|
|
|
this._liftShield(true, 0);
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onLockScreenScroll(actor, event) {
|
2012-09-02 12:48:08 +00:00
|
|
|
if (this._lockScreenState != MessageTray.State.SHOWN)
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-09-02 12:48:08 +00:00
|
|
|
|
|
|
|
let delta = 0;
|
2014-08-15 16:43:22 +00:00
|
|
|
if (event.get_scroll_direction() == Clutter.ScrollDirection.SMOOTH)
|
|
|
|
delta = Math.abs(event.get_scroll_delta()[0]);
|
|
|
|
else
|
2012-09-02 12:48:08 +00:00
|
|
|
delta = 5;
|
|
|
|
|
|
|
|
this._lockScreenScrollCounter += delta;
|
|
|
|
|
|
|
|
// 7 standard scrolls to lift up
|
|
|
|
if (this._lockScreenScrollCounter > 35) {
|
2013-01-27 14:45:04 +00:00
|
|
|
this._liftShield(true, 0);
|
2012-09-02 12:48:08 +00:00
|
|
|
}
|
|
|
|
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_STOP;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-09-02 12:48:08 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_syncInhibitor() {
|
2017-03-17 14:48:22 +00:00
|
|
|
let lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY);
|
|
|
|
let lockLocked = this._lockSettings.get_boolean(DISABLE_LOCK_KEY);
|
2015-05-13 19:42:13 +00:00
|
|
|
let inhibit = (this._loginSession && this._loginSession.Active &&
|
2017-03-17 14:48:22 +00:00
|
|
|
!this._isActive && lockEnabled && !lockLocked);
|
2015-05-13 19:41:07 +00:00
|
|
|
if (inhibit) {
|
|
|
|
this._loginManager.inhibit(_("GNOME needs to lock the screen"),
|
2017-10-31 00:38:18 +00:00
|
|
|
inhibitor => {
|
|
|
|
if (this._inhibitor)
|
|
|
|
this._inhibitor.close(null);
|
|
|
|
this._inhibitor = inhibitor;
|
|
|
|
});
|
2015-05-13 19:41:07 +00:00
|
|
|
} else {
|
|
|
|
if (this._inhibitor)
|
|
|
|
this._inhibitor.close(null);
|
|
|
|
this._inhibitor = null;
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-23 13:48:49 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_prepareForSleep(loginManager, aboutToSuspend) {
|
2012-10-23 13:48:49 +00:00
|
|
|
if (aboutToSuspend) {
|
2015-05-13 19:41:07 +00:00
|
|
|
if (this._settings.get_boolean(LOCK_ENABLED_KEY))
|
|
|
|
this.lock(true);
|
2012-10-23 13:48:49 +00:00
|
|
|
} else {
|
2014-03-14 22:12:28 +00:00
|
|
|
this._wakeUpScreen();
|
2012-10-23 13:48:49 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-23 13:48:49 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDragBegin() {
|
2018-07-20 19:46:19 +00:00
|
|
|
this._lockScreenGroup.remove_all_transitions();
|
2012-08-26 21:15:59 +00:00
|
|
|
this._lockScreenState = MessageTray.State.HIDING;
|
2013-01-27 14:45:04 +00:00
|
|
|
|
|
|
|
if (this._isLocked)
|
|
|
|
this._ensureUnlockDialog(false, false);
|
2012-08-31 14:36:40 +00:00
|
|
|
|
|
|
|
return true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-31 14:36:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onDragMotion() {
|
2019-02-01 13:41:55 +00:00
|
|
|
let [, origY] = this._dragAction.get_press_coords(0);
|
|
|
|
let [, currentY] = this._dragAction.get_motion_coords(0);
|
2012-08-31 14:36:40 +00:00
|
|
|
|
2019-01-29 20:18:46 +00:00
|
|
|
let newY = currentY - origY;
|
|
|
|
newY = clamp(newY, -global.stage.height, 0);
|
2012-08-31 14:36:40 +00:00
|
|
|
|
2019-01-29 20:18:46 +00:00
|
|
|
this._lockScreenGroup.y = newY;
|
2012-08-31 14:36:40 +00:00
|
|
|
|
2019-01-29 20:18:46 +00:00
|
|
|
return true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2019-01-31 14:08:10 +00:00
|
|
|
_onDragEnd(_action, _actor, _eventX, _eventY, _modifiers) {
|
2013-06-26 13:47:33 +00:00
|
|
|
if (this._lockScreenState != MessageTray.State.HIDING)
|
|
|
|
return;
|
2012-09-04 00:51:53 +00:00
|
|
|
if (this._lockScreenGroup.y < -(ARROW_DRAG_THRESHOLD * global.stage.height)) {
|
2012-05-24 20:47:48 +00:00
|
|
|
// Complete motion automatically
|
2019-01-31 14:08:00 +00:00
|
|
|
let [velocity_, velocityX_, velocityY] = this._dragAction.get_velocity(0);
|
2013-01-27 14:45:04 +00:00
|
|
|
this._liftShield(true, -velocityY);
|
2012-05-24 20:47:48 +00:00
|
|
|
} else {
|
|
|
|
// restore the lock screen to its original place
|
|
|
|
// try to use the same speed as the normal animation
|
|
|
|
let h = global.stage.height;
|
2018-07-20 19:46:19 +00:00
|
|
|
let duration = MANUAL_FADE_TIME * (-this._lockScreenGroup.y) / h;
|
|
|
|
this._lockScreenGroup.remove_all_transitions();
|
|
|
|
this._lockScreenGroup.ease({
|
|
|
|
y: 0,
|
|
|
|
duration,
|
|
|
|
mode: Clutter.AnimationMode.EASE_IN_QUAD,
|
|
|
|
onComplete: () => {
|
|
|
|
this._lockScreenGroup.fixed_position_set = false;
|
|
|
|
this._lockScreenState = MessageTray.State.SHOWN;
|
|
|
|
}
|
|
|
|
});
|
2012-08-07 16:07:07 +00:00
|
|
|
|
2013-06-08 17:04:36 +00:00
|
|
|
this._maybeCancelDialog();
|
2012-05-24 20:47:48 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onStatusChanged(status) {
|
2012-10-28 11:26:21 +00:00
|
|
|
if (status != GnomeSession.PresenceStatus.IDLE)
|
|
|
|
return;
|
2012-05-21 16:42:45 +00:00
|
|
|
|
2013-06-08 17:04:36 +00:00
|
|
|
this._maybeCancelDialog();
|
2012-05-21 16:42:45 +00:00
|
|
|
|
2019-03-15 01:13:27 +00:00
|
|
|
if (this._longLightbox.actor.visible) {
|
|
|
|
// We're in the process of showing.
|
2013-01-17 22:55:17 +00:00
|
|
|
return;
|
2012-10-28 11:26:21 +00:00
|
|
|
}
|
2012-10-16 14:38:32 +00:00
|
|
|
|
2013-06-04 16:58:58 +00:00
|
|
|
if (!this._becomeModal()) {
|
|
|
|
// We could not become modal, so we can't activate the
|
|
|
|
// screenshield. The user is probably very upset at this
|
|
|
|
// point, but any application using global grabs is broken
|
|
|
|
// Just tell him to stop using this app
|
2013-08-17 17:40:09 +00:00
|
|
|
//
|
2013-06-04 16:58:58 +00:00
|
|
|
// XXX: another option is to kick the user into the gdm login
|
|
|
|
// screen, where we're not affected by grabs
|
|
|
|
Main.notifyError(_("Unable to lock"),
|
|
|
|
_("Lock was blocked by an application"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-17 22:55:17 +00:00
|
|
|
if (this._activationTime == 0)
|
|
|
|
this._activationTime = GLib.get_monotonic_time();
|
2012-10-28 11:26:21 +00:00
|
|
|
|
2013-01-27 14:45:04 +00:00
|
|
|
let shouldLock = this._settings.get_boolean(LOCK_ENABLED_KEY) && !this._isLocked;
|
|
|
|
|
|
|
|
if (shouldLock) {
|
2019-08-01 23:13:10 +00:00
|
|
|
let lockTimeout = Math.max(
|
|
|
|
STANDARD_FADE_TIME,
|
|
|
|
this._settings.get_uint(LOCK_DELAY_KEY) * 1000);
|
2019-08-19 18:50:33 +00:00
|
|
|
this._lockTimeoutId = GLib.timeout_add(
|
|
|
|
GLib.PRIORITY_DEFAULT,
|
|
|
|
lockTimeout,
|
|
|
|
() => {
|
|
|
|
this._lockTimeoutId = 0;
|
|
|
|
this.lock(false);
|
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(this._lockTimeoutId, '[gnome-shell] this.lock');
|
2013-01-27 14:45:04 +00:00
|
|
|
}
|
2013-08-17 17:40:09 +00:00
|
|
|
|
|
|
|
this._activateFade(this._longLightbox, STANDARD_FADE_TIME);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-08-17 17:40:09 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_activateFade(lightbox, time) {
|
2016-11-03 18:06:26 +00:00
|
|
|
Main.uiGroup.set_child_above_sibling(lightbox.actor, null);
|
2013-08-17 17:40:09 +00:00
|
|
|
lightbox.show(time);
|
|
|
|
|
|
|
|
if (this._becameActiveId == 0)
|
2017-12-02 00:27:35 +00:00
|
|
|
this._becameActiveId = this.idleMonitor.add_user_active_watch(this._onUserBecameActive.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-28 11:26:21 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onUserBecameActive() {
|
2013-01-17 22:55:17 +00:00
|
|
|
// This function gets called here when the user becomes active
|
2013-08-17 17:40:09 +00:00
|
|
|
// after we activated a lightbox
|
|
|
|
// There are two possibilities here:
|
|
|
|
// - we're called when already locked/active; isLocked or isActive is true,
|
2013-01-17 22:55:17 +00:00
|
|
|
// we just go back to the lock screen curtain
|
2013-08-17 17:40:09 +00:00
|
|
|
// (isActive == isLocked == true: normal case
|
|
|
|
// isActive == false, isLocked == true: during the fade for manual locking
|
|
|
|
// isActive == true, isLocked == false: after session idle, before lock-delay)
|
|
|
|
// - we're called because the session is IDLE but before the lightbox
|
|
|
|
// is fully shown; at this point isActive is false, so we just hide
|
|
|
|
// the lightbox, reset the activationTime and go back to the unlocked
|
|
|
|
// desktop
|
|
|
|
// using deactivate() is a little of overkill, but it ensures we
|
|
|
|
// don't forget of some bit like modal, DBus properties or idle watches
|
|
|
|
//
|
|
|
|
// Note: if the (long) lightbox is shown then we're necessarily
|
|
|
|
// active, because we call activate() without animation.
|
2013-01-17 22:55:17 +00:00
|
|
|
|
2013-01-18 05:24:32 +00:00
|
|
|
this.idleMonitor.remove_watch(this._becameActiveId);
|
2013-01-17 22:55:17 +00:00
|
|
|
this._becameActiveId = 0;
|
|
|
|
|
2013-08-17 17:40:09 +00:00
|
|
|
if (this._isActive || this._isLocked) {
|
|
|
|
this._longLightbox.hide();
|
|
|
|
this._shortLightbox.hide();
|
|
|
|
} else {
|
2013-01-27 14:45:04 +00:00
|
|
|
this.deactivate(false);
|
2012-02-06 22:28:48 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onLongLightboxShown() {
|
2013-01-27 14:45:04 +00:00
|
|
|
this.activate(false);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-17 22:55:17 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onShortLightboxShown() {
|
2013-08-17 17:40:09 +00:00
|
|
|
this._completeLockScreenShown();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-08-17 17:40:09 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
showDialog() {
|
2014-07-31 14:38:44 +00:00
|
|
|
if (!this._becomeModal()) {
|
|
|
|
// In the login screen, this is a hard error. Fail-whale
|
|
|
|
log('Could not acquire modal grab for the login screen. Aborting login process.');
|
|
|
|
Meta.quit(Meta.ExitCode.ERROR);
|
|
|
|
}
|
2012-08-26 14:53:08 +00:00
|
|
|
|
|
|
|
this.actor.show();
|
|
|
|
this._isGreeter = Main.sessionMode.isGreeter;
|
2013-01-27 14:45:04 +00:00
|
|
|
this._isLocked = true;
|
2013-06-08 14:03:14 +00:00
|
|
|
if (this._ensureUnlockDialog(true, true))
|
|
|
|
this._hideLockScreen(false, 0);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_hideLockScreenComplete() {
|
2013-03-02 20:21:20 +00:00
|
|
|
if (Main.sessionMode.currentMode == 'lock-screen')
|
|
|
|
Main.sessionMode.popMode('lock-screen');
|
|
|
|
|
|
|
|
this._lockScreenState = MessageTray.State.HIDDEN;
|
|
|
|
this._lockScreenGroup.hide();
|
2014-10-06 20:38:03 +00:00
|
|
|
|
2014-10-08 13:39:44 +00:00
|
|
|
if (this._dialog) {
|
2019-09-20 11:14:40 +00:00
|
|
|
this._dialog.grab_key_focus();
|
|
|
|
this._dialog.navigate_focus(null, St.DirectionType.TAB_FORWARD, false);
|
2014-10-08 13:39:44 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-02 20:21:20 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_hideLockScreen(animate, velocity) {
|
2013-01-27 14:45:04 +00:00
|
|
|
if (this._lockScreenState == MessageTray.State.HIDDEN)
|
|
|
|
return;
|
|
|
|
|
2012-08-26 21:15:59 +00:00
|
|
|
this._lockScreenState = MessageTray.State.HIDING;
|
|
|
|
|
2018-07-20 19:46:19 +00:00
|
|
|
this._lockScreenGroup.remove_all_transitions();
|
2013-06-03 21:45:31 +00:00
|
|
|
|
2012-05-26 15:04:25 +00:00
|
|
|
if (animate) {
|
|
|
|
// Tween the lock screen out of screen
|
2012-08-31 14:36:40 +00:00
|
|
|
// if velocity is not specified (i.e. we come here from pressing ESC),
|
|
|
|
// use the same speed regardless of original position
|
|
|
|
// if velocity is specified, it's in pixels per milliseconds
|
2012-05-26 15:04:25 +00:00
|
|
|
let h = global.stage.height;
|
2012-08-31 14:36:40 +00:00
|
|
|
let delta = (h + this._lockScreenGroup.y);
|
2019-08-01 23:13:10 +00:00
|
|
|
let minVelocity = global.stage.height / CURTAIN_SLIDE_TIME;
|
2012-08-31 14:36:40 +00:00
|
|
|
|
2019-01-31 13:43:52 +00:00
|
|
|
velocity = Math.max(minVelocity, velocity);
|
2018-07-20 19:46:19 +00:00
|
|
|
let duration = delta / velocity;
|
|
|
|
|
|
|
|
this._lockScreenGroup.ease({
|
|
|
|
y: -h,
|
|
|
|
duration,
|
|
|
|
mode: Clutter.AnimationMode.EASE_IN_QUAD,
|
|
|
|
onComplete: () => this._hideLockScreenComplete()
|
|
|
|
});
|
2012-05-26 15:04:25 +00:00
|
|
|
} else {
|
2013-03-02 20:21:20 +00:00
|
|
|
this._hideLockScreenComplete();
|
2012-05-26 15:04:25 +00:00
|
|
|
}
|
|
|
|
|
2013-08-14 14:59:39 +00:00
|
|
|
this._cursorTracker.set_pointer_visible(true);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-26 21:15:59 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_ensureUnlockDialog(onPrimary, allowCancel) {
|
2012-05-26 15:04:25 +00:00
|
|
|
if (!this._dialog) {
|
2012-09-04 17:28:19 +00:00
|
|
|
let constructor = Main.sessionMode.unlockDialog;
|
2012-11-06 22:41:51 +00:00
|
|
|
if (!constructor) {
|
2012-05-26 15:04:25 +00:00
|
|
|
// This session mode has no locking capabilities
|
2013-01-27 14:45:04 +00:00
|
|
|
this.deactivate(true);
|
2013-06-08 14:03:14 +00:00
|
|
|
return false;
|
2012-05-26 15:04:25 +00:00
|
|
|
}
|
|
|
|
|
2012-11-06 22:41:51 +00:00
|
|
|
this._dialog = new constructor(this._lockDialogGroup);
|
|
|
|
|
|
|
|
|
2012-10-14 16:34:22 +00:00
|
|
|
let time = global.get_current_time();
|
2013-03-05 06:51:28 +00:00
|
|
|
if (!this._dialog.open(time, onPrimary)) {
|
|
|
|
// This is kind of an impossible error: we're already modal
|
|
|
|
// by the time we reach this...
|
|
|
|
log('Could not open login dialog: failed to acquire grab');
|
|
|
|
this.deactivate(true);
|
2013-06-08 14:03:14 +00:00
|
|
|
return false;
|
2013-03-05 06:51:28 +00:00
|
|
|
}
|
2012-05-26 15:04:25 +00:00
|
|
|
|
2017-12-02 00:27:35 +00:00
|
|
|
this._dialog.connect('failed', this._onUnlockFailed.bind(this));
|
2012-05-26 15:04:25 +00:00
|
|
|
}
|
2012-10-24 15:53:19 +00:00
|
|
|
|
|
|
|
this._dialog.allowCancel = allowCancel;
|
2013-06-08 14:03:14 +00:00
|
|
|
return true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-02-06 22:28:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onUnlockFailed() {
|
2013-05-12 15:32:02 +00:00
|
|
|
this._resetLockScreen({ animateLockScreen: true,
|
2013-08-17 17:40:09 +00:00
|
|
|
fadeToBlack: false });
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_resetLockScreen(params) {
|
2013-01-27 14:45:04 +00:00
|
|
|
// Don't reset the lock screen unless it is completely hidden
|
|
|
|
// This prevents the shield going down if the lock-delay timeout
|
|
|
|
// fires while the user is dragging (which has the potential
|
|
|
|
// to confuse our state)
|
|
|
|
if (this._lockScreenState != MessageTray.State.HIDDEN)
|
2012-12-29 14:25:03 +00:00
|
|
|
return;
|
|
|
|
|
2012-08-26 14:53:08 +00:00
|
|
|
this._ensureLockScreen();
|
2012-09-01 19:59:53 +00:00
|
|
|
this._lockDialogGroup.scale_x = 1;
|
|
|
|
this._lockDialogGroup.scale_y = 1;
|
|
|
|
|
2012-08-03 17:42:43 +00:00
|
|
|
this._lockScreenGroup.show();
|
2012-08-26 21:15:59 +00:00
|
|
|
this._lockScreenState = MessageTray.State.SHOWING;
|
2012-08-03 17:42:43 +00:00
|
|
|
|
2013-08-17 17:40:09 +00:00
|
|
|
let fadeToBlack = params.fadeToBlack;
|
|
|
|
|
2013-05-12 15:32:02 +00:00
|
|
|
if (params.animateLockScreen) {
|
2012-08-03 17:42:43 +00:00
|
|
|
this._lockScreenGroup.y = -global.screen_height;
|
2018-07-20 19:46:19 +00:00
|
|
|
this._lockScreenGroup.remove_all_transitions();
|
|
|
|
this._lockScreenGroup.ease({
|
|
|
|
y: 0,
|
|
|
|
duration: MANUAL_FADE_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => {
|
|
|
|
this._lockScreenShown({ fadeToBlack, animateFade: true });
|
|
|
|
}
|
|
|
|
});
|
2012-08-13 23:43:59 +00:00
|
|
|
} else {
|
|
|
|
this._lockScreenGroup.fixed_position_set = false;
|
2013-08-17 17:40:09 +00:00
|
|
|
this._lockScreenShown({ fadeToBlack: fadeToBlack,
|
|
|
|
animateFade: false });
|
2012-08-13 23:43:59 +00:00
|
|
|
}
|
2012-08-03 17:42:43 +00:00
|
|
|
|
2012-05-24 20:47:48 +00:00
|
|
|
this._lockScreenGroup.grab_key_focus();
|
2012-08-26 14:53:08 +00:00
|
|
|
|
|
|
|
if (Main.sessionMode.currentMode != 'lock-screen')
|
|
|
|
Main.sessionMode.pushMode('lock-screen');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-21 16:42:45 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_lockScreenShown(params) {
|
2012-09-19 11:11:27 +00:00
|
|
|
if (this._dialog && !this._isGreeter) {
|
2012-09-19 02:34:49 +00:00
|
|
|
this._dialog.destroy();
|
2012-09-19 11:11:27 +00:00
|
|
|
this._dialog = null;
|
|
|
|
}
|
2012-09-19 02:34:49 +00:00
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
let motionId = global.stage.connect('captured-event', (stage, event) => {
|
2012-08-31 15:51:32 +00:00
|
|
|
if (event.type() == Clutter.EventType.MOTION) {
|
2013-09-12 11:04:47 +00:00
|
|
|
this._cursorTracker.set_pointer_visible(true);
|
2012-08-31 15:51:32 +00:00
|
|
|
global.stage.disconnect(motionId);
|
|
|
|
}
|
|
|
|
|
2013-11-29 18:17:34 +00:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2013-09-12 11:04:47 +00:00
|
|
|
this._cursorTracker.set_pointer_visible(false);
|
2012-08-31 15:51:32 +00:00
|
|
|
|
2012-08-26 21:15:59 +00:00
|
|
|
this._lockScreenState = MessageTray.State.SHOWN;
|
|
|
|
this._lockScreenGroup.fixed_position_set = false;
|
2012-09-02 12:48:08 +00:00
|
|
|
this._lockScreenScrollCounter = 0;
|
2012-08-26 21:15:59 +00:00
|
|
|
|
2013-08-17 17:40:09 +00:00
|
|
|
if (params.fadeToBlack && params.animateFade) {
|
|
|
|
// Take a beat
|
|
|
|
|
2019-08-19 18:50:33 +00:00
|
|
|
let id = GLib.timeout_add(GLib.PRIORITY_DEFAULT, MANUAL_FADE_TIME, () => {
|
2013-08-17 17:40:09 +00:00
|
|
|
this._activateFade(this._shortLightbox, MANUAL_FADE_TIME);
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] this._activateFade');
|
2013-08-17 17:40:09 +00:00
|
|
|
} else {
|
|
|
|
if (params.fadeToBlack)
|
|
|
|
this._activateFade(this._shortLightbox, 0);
|
|
|
|
|
|
|
|
this._completeLockScreenShown();
|
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-08-17 17:40:09 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_completeLockScreenShown() {
|
2015-05-13 19:41:07 +00:00
|
|
|
this._setActive(true);
|
2012-08-26 21:15:59 +00:00
|
|
|
this.emit('lock-screen-shown');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-26 21:15:59 +00:00
|
|
|
|
2012-05-27 22:50:56 +00:00
|
|
|
// Some of the actors in the lock screen are heavy in
|
|
|
|
// resources, so we only create them when needed
|
2017-10-31 00:03:21 +00:00
|
|
|
_ensureLockScreen() {
|
2012-08-26 14:53:08 +00:00
|
|
|
if (this._hasLockScreen)
|
|
|
|
return;
|
|
|
|
|
2012-05-27 22:50:56 +00:00
|
|
|
this._lockScreenContentsBox = new St.BoxLayout({ x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
2012-10-10 21:17:38 +00:00
|
|
|
vertical: true,
|
|
|
|
style_class: 'screen-shield-contents-box' });
|
2012-05-27 22:50:56 +00:00
|
|
|
this._clock = new Clock();
|
|
|
|
this._lockScreenContentsBox.add(this._clock.actor, { x_fill: true,
|
|
|
|
y_fill: true });
|
|
|
|
|
2012-08-14 13:39:17 +00:00
|
|
|
this._lockScreenContents.add_actor(this._lockScreenContentsBox);
|
2012-05-27 22:50:56 +00:00
|
|
|
|
2012-10-16 15:08:54 +00:00
|
|
|
this._notificationsBox = new NotificationsBox();
|
2017-12-02 00:27:35 +00:00
|
|
|
this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', this._wakeUpScreen.bind(this));
|
2012-10-16 15:08:54 +00:00
|
|
|
this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true,
|
|
|
|
y_fill: true,
|
|
|
|
expand: true });
|
2012-05-22 22:02:00 +00:00
|
|
|
|
2012-05-27 22:50:56 +00:00
|
|
|
this._hasLockScreen = true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-27 22:50:56 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_wakeUpScreen() {
|
2014-03-10 18:16:03 +00:00
|
|
|
this._onUserBecameActive();
|
|
|
|
this.emit('wake-up-screen');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2014-03-10 18:16:03 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_clearLockScreen() {
|
2012-05-27 22:50:56 +00:00
|
|
|
this._clock.destroy();
|
|
|
|
this._clock = null;
|
|
|
|
|
2012-05-22 22:02:00 +00:00
|
|
|
if (this._notificationsBox) {
|
2014-03-10 18:16:03 +00:00
|
|
|
this._notificationsBox.disconnect(this._wakeUpScreenId);
|
2012-05-22 22:02:00 +00:00
|
|
|
this._notificationsBox.destroy();
|
|
|
|
this._notificationsBox = null;
|
|
|
|
}
|
|
|
|
|
2012-12-29 14:24:03 +00:00
|
|
|
this._lockScreenContentsBox.destroy();
|
2012-08-20 17:56:08 +00:00
|
|
|
|
2012-05-27 22:50:56 +00:00
|
|
|
this._hasLockScreen = false;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-27 22:50:56 +00:00
|
|
|
|
2012-05-21 16:42:45 +00:00
|
|
|
get locked() {
|
2013-01-27 14:45:04 +00:00
|
|
|
return this._isLocked;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-27 14:45:04 +00:00
|
|
|
|
|
|
|
get active() {
|
2012-08-26 14:53:08 +00:00
|
|
|
return this._isActive;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-21 16:42:45 +00:00
|
|
|
|
2012-10-16 14:38:32 +00:00
|
|
|
get activationTime() {
|
|
|
|
return this._activationTime;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-16 14:38:32 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
deactivate(animate) {
|
2013-08-06 13:22:48 +00:00
|
|
|
if (this._dialog)
|
2019-01-28 00:42:00 +00:00
|
|
|
this._dialog.finish(() => this._continueDeactivate(animate));
|
2013-08-06 13:22:48 +00:00
|
|
|
else
|
2013-08-06 13:49:00 +00:00
|
|
|
this._continueDeactivate(animate);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-18 12:58:58 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_continueDeactivate(animate) {
|
2013-01-27 14:45:04 +00:00
|
|
|
this._hideLockScreen(animate, 0);
|
|
|
|
|
2013-05-12 17:41:21 +00:00
|
|
|
if (this._hasLockScreen)
|
|
|
|
this._clearLockScreen();
|
|
|
|
|
2013-02-01 10:36:21 +00:00
|
|
|
if (Main.sessionMode.currentMode == 'lock-screen')
|
|
|
|
Main.sessionMode.popMode('lock-screen');
|
|
|
|
if (Main.sessionMode.currentMode == 'unlock-dialog')
|
|
|
|
Main.sessionMode.popMode('unlock-dialog');
|
|
|
|
|
2013-06-06 20:09:28 +00:00
|
|
|
if (this._isGreeter) {
|
|
|
|
// We don't want to "deactivate" any more than
|
|
|
|
// this. In particular, we don't want to drop
|
|
|
|
// the modal, hide ourselves or destroy the dialog
|
|
|
|
// But we do want to set isActive to false, so that
|
|
|
|
// gnome-session will reset the idle counter, and
|
|
|
|
// gnome-settings-daemon will stop blanking the screen
|
|
|
|
|
|
|
|
this._activationTime = 0;
|
2015-05-13 19:41:07 +00:00
|
|
|
this._setActive(false);
|
2013-06-06 20:09:28 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-22 16:06:11 +00:00
|
|
|
if (this._dialog && !this._isGreeter)
|
|
|
|
this._dialog.popModal();
|
|
|
|
|
|
|
|
if (this._isModal) {
|
|
|
|
Main.popModal(this.actor);
|
|
|
|
this._isModal = false;
|
|
|
|
}
|
|
|
|
|
2018-07-20 19:46:19 +00:00
|
|
|
this._lockDialogGroup.ease({
|
2012-09-01 19:59:53 +00:00
|
|
|
scale_x: 0,
|
|
|
|
scale_y: 0,
|
2018-07-20 19:46:19 +00:00
|
|
|
duration: animate ? Overview.ANIMATION_TIME : 0,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
onComplete: () => this._completeDeactivate()
|
2012-09-01 19:59:53 +00:00
|
|
|
});
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-09-01 19:59:53 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_completeDeactivate() {
|
2013-06-06 20:09:28 +00:00
|
|
|
if (this._dialog) {
|
2012-09-04 17:28:19 +00:00
|
|
|
this._dialog.destroy();
|
|
|
|
this._dialog = null;
|
2012-05-26 15:04:25 +00:00
|
|
|
}
|
|
|
|
|
2013-08-17 17:40:09 +00:00
|
|
|
this._longLightbox.hide();
|
|
|
|
this._shortLightbox.hide();
|
2013-01-27 14:45:04 +00:00
|
|
|
this.actor.hide();
|
2012-08-26 14:53:08 +00:00
|
|
|
|
2013-01-17 22:55:17 +00:00
|
|
|
if (this._becameActiveId != 0) {
|
2013-01-18 05:24:32 +00:00
|
|
|
this.idleMonitor.remove_watch(this._becameActiveId);
|
2013-01-17 22:55:17 +00:00
|
|
|
this._becameActiveId = 0;
|
|
|
|
}
|
|
|
|
|
2013-01-27 14:45:04 +00:00
|
|
|
if (this._lockTimeoutId != 0) {
|
2019-08-19 18:50:33 +00:00
|
|
|
GLib.source_remove(this._lockTimeoutId);
|
2013-01-27 14:45:04 +00:00
|
|
|
this._lockTimeoutId = 0;
|
|
|
|
}
|
|
|
|
|
2012-10-16 14:38:32 +00:00
|
|
|
this._activationTime = 0;
|
2015-05-13 19:41:07 +00:00
|
|
|
this._setActive(false);
|
2012-10-28 11:26:21 +00:00
|
|
|
this._isLocked = false;
|
2013-02-02 16:10:45 +00:00
|
|
|
this.emit('locked-changed');
|
2013-01-17 19:39:54 +00:00
|
|
|
global.set_runtime_state(LOCKED_STATE_STR, null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-24 20:47:48 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
activate(animate) {
|
2012-10-16 14:38:32 +00:00
|
|
|
if (this._activationTime == 0)
|
|
|
|
this._activationTime = GLib.get_monotonic_time();
|
|
|
|
|
2012-05-21 16:42:45 +00:00
|
|
|
this.actor.show();
|
2012-08-26 14:53:08 +00:00
|
|
|
|
|
|
|
if (Main.sessionMode.currentMode != 'unlock-dialog' &&
|
|
|
|
Main.sessionMode.currentMode != 'lock-screen') {
|
|
|
|
this._isGreeter = Main.sessionMode.isGreeter;
|
|
|
|
if (!this._isGreeter)
|
|
|
|
Main.sessionMode.pushMode('unlock-dialog');
|
|
|
|
}
|
|
|
|
|
2013-05-12 15:32:02 +00:00
|
|
|
this._resetLockScreen({ animateLockScreen: animate,
|
2013-08-17 17:40:09 +00:00
|
|
|
fadeToBlack: true });
|
2018-02-05 10:37:09 +00:00
|
|
|
// On wayland, a crash brings down the entire session, so we don't
|
|
|
|
// need to defend against being restarted unlocked
|
|
|
|
if (!Meta.is_wayland_compositor())
|
|
|
|
global.set_runtime_state(LOCKED_STATE_STR, GLib.Variant.new('b', true));
|
2012-05-21 16:42:45 +00:00
|
|
|
|
2013-02-02 16:10:45 +00:00
|
|
|
// We used to set isActive and emit active-changed here,
|
2013-01-29 14:49:18 +00:00
|
|
|
// but now we do that from lockScreenShown, which means
|
|
|
|
// there is a 0.3 seconds window during which the lock
|
|
|
|
// screen is effectively visible and the screen is locked, but
|
|
|
|
// the DBus interface reports the screensaver is off.
|
|
|
|
// This is because when we emit ActiveChanged(true),
|
|
|
|
// gnome-settings-daemon blanks the screen, and we don't want
|
|
|
|
// blank during the animation.
|
|
|
|
// This is not a problem for the idle fade case, because we
|
|
|
|
// activate without animation in that case.
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-27 14:45:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
lock(animate) {
|
2017-03-17 14:48:22 +00:00
|
|
|
if (this._lockSettings.get_boolean(DISABLE_LOCK_KEY)) {
|
2019-01-29 01:18:52 +00:00
|
|
|
log('Screen lock is locked down, not locking'); // lock, lock - who's there?
|
2017-03-17 14:48:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-26 19:18:57 +00:00
|
|
|
// Warn the user if we can't become modal
|
|
|
|
if (!this._becomeModal()) {
|
|
|
|
Main.notifyError(_("Unable to lock"),
|
|
|
|
_("Lock was blocked by an application"));
|
|
|
|
return;
|
2013-01-27 14:45:04 +00:00
|
|
|
}
|
|
|
|
|
2013-05-16 15:51:31 +00:00
|
|
|
// Clear the clipboard - otherwise, its contents may be leaked
|
|
|
|
// to unauthorized parties by pasting into the unlock dialog's
|
|
|
|
// password entry and unmasking the entry
|
|
|
|
St.Clipboard.get_default().set_text(St.ClipboardType.CLIPBOARD, '');
|
|
|
|
St.Clipboard.get_default().set_text(St.ClipboardType.PRIMARY, '');
|
|
|
|
|
2013-06-08 15:22:43 +00:00
|
|
|
let userManager = AccountsService.UserManager.get_default();
|
|
|
|
let user = userManager.get_user(GLib.get_user_name());
|
|
|
|
|
|
|
|
if (this._isGreeter)
|
|
|
|
this._isLocked = true;
|
|
|
|
else
|
|
|
|
this._isLocked = user.password_mode != AccountsService.UserPasswordMode.NONE;
|
|
|
|
|
2013-01-27 14:45:04 +00:00
|
|
|
this.activate(animate);
|
2013-02-02 16:10:45 +00:00
|
|
|
|
|
|
|
this.emit('locked-changed');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-01-17 19:39:54 +00:00
|
|
|
|
|
|
|
// If the previous shell crashed, and gnome-session restarted us, then re-lock
|
2017-10-31 00:03:21 +00:00
|
|
|
lockIfWasLocked() {
|
2013-07-25 22:21:30 +00:00
|
|
|
if (!this._settings.get_boolean(LOCK_ENABLED_KEY))
|
|
|
|
return;
|
2013-01-17 19:39:54 +00:00
|
|
|
let wasLocked = global.get_runtime_state('b', LOCKED_STATE_STR);
|
|
|
|
if (wasLocked === null)
|
|
|
|
return;
|
2017-10-31 00:38:18 +00:00
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
|
2013-01-17 19:39:54 +00:00
|
|
|
this.lock(false);
|
2019-07-22 18:37:33 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2013-01-17 19:39:54 +00:00
|
|
|
}
|
2017-10-31 01:19:44 +00:00
|
|
|
};
|
2012-05-21 16:42:45 +00:00
|
|
|
Signals.addSignalMethods(ScreenShield.prototype);
|