2012-05-20 16:30:14 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2023-07-10 09:53:00 +00:00
|
|
|
|
|
|
|
import AccountsService from 'gi://AccountsService';
|
|
|
|
import Atk from 'gi://Atk';
|
|
|
|
import Clutter from 'gi://Clutter';
|
|
|
|
import Gdm from 'gi://Gdm';
|
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
import GnomeDesktop from 'gi://GnomeDesktop';
|
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
import GObject from 'gi://GObject';
|
|
|
|
import Shell from 'gi://Shell';
|
|
|
|
import St from 'gi://St';
|
|
|
|
|
|
|
|
import * as Background from './background.js';
|
|
|
|
import * as Layout from './layout.js';
|
|
|
|
import * as Main from './main.js';
|
|
|
|
import * as MessageTray from './messageTray.js';
|
|
|
|
import * as SwipeTracker from './swipeTracker.js';
|
|
|
|
import {formatDateWithCFormatString} from '../misc/dateUtils.js';
|
|
|
|
import * as AuthPrompt from '../gdm/authPrompt.js';
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2012-08-16 19:24:53 +00:00
|
|
|
// The timeout before going back automatically to the lock screen (in seconds)
|
|
|
|
const IDLE_TIMEOUT = 2 * 60;
|
|
|
|
|
2020-02-11 18:35:22 +00:00
|
|
|
// The timeout before showing the unlock hint (in seconds)
|
|
|
|
const HINT_TIMEOUT = 4;
|
|
|
|
|
2019-11-29 17:37:10 +00:00
|
|
|
const CROSSFADE_TIME = 300;
|
2020-02-02 09:43:55 +00:00
|
|
|
const FADE_OUT_TRANSLATION = 200;
|
|
|
|
const FADE_OUT_SCALE = 0.3;
|
2019-11-29 17:37:10 +00:00
|
|
|
|
2022-12-01 18:14:04 +00:00
|
|
|
const BLUR_BRIGHTNESS = 0.65;
|
|
|
|
const BLUR_SIGMA = 45;
|
2020-01-07 19:43:35 +00:00
|
|
|
|
2019-11-29 19:08:20 +00:00
|
|
|
const SUMMARY_ICON_SIZE = 32;
|
2019-11-28 21:35:13 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
const NotificationsBox = GObject.registerClass({
|
2019-11-28 21:35:13 +00:00
|
|
|
Signals: { 'wake-up-screen': {} },
|
|
|
|
}, class NotificationsBox extends St.BoxLayout {
|
|
|
|
_init() {
|
|
|
|
super._init({
|
|
|
|
vertical: true,
|
|
|
|
name: 'unlockDialogNotifications',
|
|
|
|
});
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2021-11-27 07:50:23 +00:00
|
|
|
this._settings = new Gio.Settings({
|
|
|
|
schema_id: 'org.gnome.desktop.notifications',
|
|
|
|
});
|
|
|
|
|
2019-11-28 21:35:13 +00:00
|
|
|
this._sources = new Map();
|
|
|
|
Main.messageTray.getSources().forEach(source => {
|
|
|
|
this._sourceAdded(Main.messageTray, source, true);
|
|
|
|
});
|
|
|
|
this._updateVisibility();
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
Main.messageTray.connectObject('source-added',
|
|
|
|
this._sourceAdded.bind(this), this);
|
2019-11-28 21:35:13 +00:00
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
|
|
|
}
|
|
|
|
|
|
|
|
_onDestroy() {
|
|
|
|
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 19:05:45 +00:00
|
|
|
let textBox = new St.BoxLayout({
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
2019-11-28 21:35:13 +00:00
|
|
|
box.add_child(textBox);
|
|
|
|
|
|
|
|
let title = new St.Label({
|
|
|
|
text: source.title,
|
|
|
|
style_class: 'unlock-dialog-notification-label',
|
2019-11-29 19:05:45 +00:00
|
|
|
x_expand: true,
|
|
|
|
x_align: Clutter.ActorAlign.START,
|
2019-11-28 21:35:13 +00:00
|
|
|
});
|
|
|
|
textBox.add(title);
|
|
|
|
|
|
|
|
let count = source.unseenCount;
|
|
|
|
let countLabel = new St.Label({
|
2022-02-07 14:14:06 +00:00
|
|
|
text: `${count}`,
|
2020-02-13 18:06:51 +00:00
|
|
|
visible: count > 1,
|
2019-11-28 21:35:13 +00: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({
|
2020-03-22 20:14:34 +00:00
|
|
|
text: source.title.replace(/\n/g, ' '),
|
2019-11-28 21:35:13 +00:00
|
|
|
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) {
|
2020-03-22 20:14:34 +00:00
|
|
|
const bodyText = n.bannerBodyText.replace(/\n/g, ' ');
|
2019-11-28 21:35:13 +00:00
|
|
|
body = n.bannerBodyMarkup
|
2020-03-22 20:14:34 +00:00
|
|
|
? bodyText
|
|
|
|
: GLib.markup_escape_text(bodyText, -1);
|
2019-11-28 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let label = new St.Label({ style_class: 'unlock-dialog-notification-count-text' });
|
2022-02-07 14:14:06 +00:00
|
|
|
label.clutter_text.set_markup(`<b>${n.title}</b> ${body}`);
|
2019-11-28 21:35:13 +00:00
|
|
|
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 14:58:57 +00: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 21:35:13 +00: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 14:58:57 +00:00
|
|
|
|
|
|
|
this._updateSourceBoxStyle(source, obj, box);
|
2019-11-28 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
2021-11-27 07:50:23 +00:00
|
|
|
_wakeUpScreenForSource(source) {
|
|
|
|
if (!this._settings.get_boolean('show-banners'))
|
|
|
|
return;
|
|
|
|
const obj = this._sources.get(source);
|
|
|
|
if (obj?.sourceBox.visible)
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
}
|
|
|
|
|
2019-11-28 21:35:13 +00:00
|
|
|
_sourceAdded(tray, source, initial) {
|
|
|
|
let obj = {
|
|
|
|
visible: source.policy.showInLockScreen,
|
|
|
|
detailed: this._shouldShowDetails(source),
|
|
|
|
sourceBox: null,
|
|
|
|
titleLabel: null,
|
|
|
|
countLabel: null,
|
2020-02-05 14:58:57 +00:00
|
|
|
hasCriticalNotification: false,
|
2019-11-28 21:35:13 +00: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);
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
source.connectObject(
|
|
|
|
'notify::count', () => this._countChanged(source, obj),
|
|
|
|
'notify::title', () => this._titleChanged(source, obj),
|
|
|
|
'destroy', () => {
|
|
|
|
this._removeSource(source, obj);
|
|
|
|
this._updateVisibility();
|
|
|
|
}, this);
|
2019-11-28 21:35:13 +00:00
|
|
|
obj.policyChangedId = source.policy.connect('notify', (policy, pspec) => {
|
|
|
|
if (pspec.name === 'show-in-lock-screen')
|
|
|
|
this._visibleChanged(source, obj);
|
|
|
|
else
|
|
|
|
this._detailedChanged(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();
|
2021-11-27 07:50:23 +00:00
|
|
|
this._wakeUpScreenForSource(source);
|
2019-11-28 21:35:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_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;
|
2022-02-07 14:14:06 +00:00
|
|
|
obj.countLabel.text = `${count}`;
|
2020-02-13 18:06:51 +00:00
|
|
|
obj.countLabel.visible = count > 1;
|
2019-11-28 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
obj.sourceBox.visible = obj.visible && (source.unseenCount > 0);
|
|
|
|
|
|
|
|
this._updateVisibility();
|
2021-11-27 07:50:23 +00:00
|
|
|
this._wakeUpScreenForSource(source);
|
2019-11-28 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_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();
|
2021-11-27 07:50:23 +00:00
|
|
|
this._wakeUpScreenForSource(source);
|
2019-11-28 21:35:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_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);
|
|
|
|
}
|
|
|
|
|
|
|
|
_removeSource(source, obj) {
|
|
|
|
obj.sourceBox.destroy();
|
|
|
|
obj.sourceBox = obj.titleLabel = obj.countLabel = null;
|
|
|
|
|
|
|
|
source.policy.disconnect(obj.policyChangedId);
|
|
|
|
|
|
|
|
this._sources.delete(source);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
const Clock = GObject.registerClass(
|
2019-11-28 21:16:53 +00:00
|
|
|
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,
|
|
|
|
});
|
2020-02-11 18:35:22 +00:00
|
|
|
this._hint = new St.Label({
|
|
|
|
style_class: 'unlock-dialog-clock-hint',
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
opacity: 0,
|
|
|
|
});
|
2019-11-28 21:16:53 +00:00
|
|
|
|
|
|
|
this.add_child(this._time);
|
|
|
|
this.add_child(this._date);
|
2020-02-11 18:35:22 +00:00
|
|
|
this.add_child(this._hint);
|
2019-11-28 21:16:53 +00:00
|
|
|
|
|
|
|
this._wallClock = new GnomeDesktop.WallClock({ time_only: true });
|
|
|
|
this._wallClock.connect('notify::clock', this._updateClock.bind(this));
|
|
|
|
|
2020-02-11 18:35:22 +00:00
|
|
|
this._seat = Clutter.get_default_backend().get_default_seat();
|
2021-08-15 22:36:59 +00:00
|
|
|
this._seat.connectObject('notify::touch-mode',
|
|
|
|
this._updateHint.bind(this), this);
|
2020-02-11 18:35:22 +00:00
|
|
|
|
2022-09-07 18:24:44 +00:00
|
|
|
this._monitorManager = global.backend.get_monitor_manager();
|
2021-08-15 22:36:59 +00:00
|
|
|
this._monitorManager.connectObject('power-save-mode-changed',
|
|
|
|
() => (this._hint.opacity = 0), this);
|
2020-02-11 18:35:22 +00:00
|
|
|
|
2021-05-06 20:31:11 +00:00
|
|
|
this._idleMonitor = global.backend.get_core_idle_monitor();
|
2020-02-11 18:35:22 +00:00
|
|
|
this._idleWatchId = this._idleMonitor.add_idle_watch(HINT_TIMEOUT * 1000, () => {
|
|
|
|
this._hint.ease({
|
|
|
|
opacity: 255,
|
|
|
|
duration: CROSSFADE_TIME,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-11-28 21:16:53 +00:00
|
|
|
this._updateClock();
|
2020-02-11 18:35:22 +00:00
|
|
|
this._updateHint();
|
2019-11-28 21:16:53 +00:00
|
|
|
|
|
|
|
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 22:11:26 +00:00
|
|
|
let dateFormat = Shell.util_translate_time_string(N_('%A %B %-d'));
|
2023-07-08 00:58:11 +00:00
|
|
|
this._date.text = formatDateWithCFormatString(date, dateFormat);
|
2019-11-28 21:16:53 +00:00
|
|
|
}
|
|
|
|
|
2020-02-11 18:35:22 +00:00
|
|
|
_updateHint() {
|
|
|
|
this._hint.text = this._seat.touch_mode
|
|
|
|
? _('Swipe up to unlock')
|
|
|
|
: _('Click or press a key to unlock');
|
|
|
|
}
|
|
|
|
|
2019-11-28 21:16:53 +00:00
|
|
|
_onDestroy() {
|
|
|
|
this._wallClock.run_dispose();
|
2020-02-11 18:35:22 +00:00
|
|
|
|
|
|
|
this._idleMonitor.remove_watch(this._idleWatchId);
|
2019-11-28 21:16:53 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
const UnlockDialogLayout = GObject.registerClass(
|
2019-11-29 16:36:47 +00:00
|
|
|
class UnlockDialogLayout extends Clutter.LayoutManager {
|
2020-02-14 15:29:51 +00:00
|
|
|
_init(stack, notifications, switchUserButton) {
|
2019-11-29 16:36:47 +00:00
|
|
|
super._init();
|
|
|
|
|
2019-11-29 17:36:01 +00:00
|
|
|
this._stack = stack;
|
2019-11-29 16:36:47 +00:00
|
|
|
this._notifications = notifications;
|
2020-02-14 15:29:51 +00:00
|
|
|
this._switchUserButton = switchUserButton;
|
2019-11-29 16:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_width(container, forHeight) {
|
2019-11-29 17:36:01 +00:00
|
|
|
return this._stack.get_preferred_width(forHeight);
|
2019-11-29 16:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vfunc_get_preferred_height(container, forWidth) {
|
2019-11-29 17:36:01 +00:00
|
|
|
return this._stack.get_preferred_height(forWidth);
|
2019-11-29 16:36:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-09 19:30:26 +00:00
|
|
|
vfunc_allocate(container, box) {
|
2019-11-29 16:36:47 +00:00
|
|
|
let [width, height] = box.get_size();
|
|
|
|
|
|
|
|
let tenthOfHeight = height / 10.0;
|
|
|
|
let thirdOfHeight = height / 3.0;
|
|
|
|
|
2019-11-29 17:36:01 +00:00
|
|
|
let [, , stackWidth, stackHeight] =
|
|
|
|
this._stack.get_preferred_size();
|
2019-11-29 16:36:47 +00:00
|
|
|
|
|
|
|
let [, , notificationsWidth, notificationsHeight] =
|
|
|
|
this._notifications.get_preferred_size();
|
|
|
|
|
2019-11-29 17:36:01 +00:00
|
|
|
let columnWidth = Math.max(stackWidth, notificationsWidth);
|
2019-11-29 16:36:47 +00:00
|
|
|
|
|
|
|
let columnX1 = Math.floor((width - columnWidth) / 2.0);
|
|
|
|
let actorBox = new Clutter.ActorBox();
|
|
|
|
|
|
|
|
// Notifications
|
|
|
|
let maxNotificationsHeight = Math.min(
|
|
|
|
notificationsHeight,
|
2019-11-29 17:36:01 +00:00
|
|
|
height - tenthOfHeight - stackHeight);
|
2019-11-29 16:36:47 +00:00
|
|
|
|
|
|
|
actorBox.x1 = columnX1;
|
|
|
|
actorBox.y1 = height - maxNotificationsHeight;
|
|
|
|
actorBox.x2 = columnX1 + columnWidth;
|
|
|
|
actorBox.y2 = actorBox.y1 + maxNotificationsHeight;
|
|
|
|
|
2020-05-09 19:30:26 +00:00
|
|
|
this._notifications.allocate(actorBox);
|
2019-11-29 16:36:47 +00:00
|
|
|
|
|
|
|
// Authentication Box
|
2019-11-29 17:36:01 +00:00
|
|
|
let stackY = Math.min(
|
2019-11-29 16:36:47 +00:00
|
|
|
thirdOfHeight,
|
2019-11-29 17:36:01 +00:00
|
|
|
height - stackHeight - maxNotificationsHeight);
|
2019-11-29 16:36:47 +00:00
|
|
|
|
|
|
|
actorBox.x1 = columnX1;
|
2019-11-29 17:36:01 +00:00
|
|
|
actorBox.y1 = stackY;
|
2019-11-29 16:36:47 +00:00
|
|
|
actorBox.x2 = columnX1 + columnWidth;
|
2019-11-29 17:36:01 +00:00
|
|
|
actorBox.y2 = stackY + stackHeight;
|
2019-11-29 16:36:47 +00:00
|
|
|
|
2020-05-09 19:30:26 +00:00
|
|
|
this._stack.allocate(actorBox);
|
2020-02-14 15:29:51 +00:00
|
|
|
|
|
|
|
// Switch User button
|
|
|
|
if (this._switchUserButton.visible) {
|
|
|
|
let [, , natWidth, natHeight] =
|
|
|
|
this._switchUserButton.get_preferred_size();
|
|
|
|
|
|
|
|
const textDirection = this._switchUserButton.get_text_direction();
|
|
|
|
if (textDirection === Clutter.TextDirection.RTL)
|
|
|
|
actorBox.x1 = box.x1 + natWidth;
|
|
|
|
else
|
|
|
|
actorBox.x1 = box.x2 - (natWidth * 2);
|
|
|
|
|
|
|
|
actorBox.y1 = box.y2 - (natHeight * 2);
|
|
|
|
actorBox.x2 = actorBox.x1 + natWidth;
|
|
|
|
actorBox.y2 = actorBox.y1 + natHeight;
|
|
|
|
|
2020-05-09 19:30:26 +00:00
|
|
|
this._switchUserButton.allocate(actorBox);
|
2020-02-14 15:29:51 +00:00
|
|
|
}
|
2019-11-29 16:36:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export const UnlockDialog = GObject.registerClass({
|
2019-11-28 21:22:55 +00:00
|
|
|
Signals: {
|
|
|
|
'failed': {},
|
|
|
|
'wake-up-screen': {},
|
|
|
|
},
|
2019-09-20 11:17:40 +00:00
|
|
|
}, class UnlockDialog extends St.Widget {
|
|
|
|
_init(parentActor) {
|
|
|
|
super._init({
|
|
|
|
accessible_role: Atk.Role.WINDOW,
|
2020-08-26 00:06:46 +00:00
|
|
|
style_class: 'unlock-dialog',
|
2019-09-20 11:17:40 +00:00
|
|
|
visible: false,
|
2019-11-29 17:37:10 +00:00
|
|
|
reactive: true,
|
2019-09-20 11:17:40 +00:00
|
|
|
});
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
parentActor.add_child(this);
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2020-02-13 20:36:51 +00:00
|
|
|
this._gdmClient = new Gdm.Client();
|
|
|
|
|
2017-07-17 20:48:03 +00:00
|
|
|
try {
|
|
|
|
this._gdmClient.set_enabled_extensions([
|
|
|
|
Gdm.UserVerifierChoiceList.interface_info().name,
|
|
|
|
]);
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
|
2020-02-02 11:10:10 +00:00
|
|
|
this._adjustment = new St.Adjustment({
|
2020-06-16 20:03:07 +00:00
|
|
|
actor: this,
|
2020-02-02 11:10:10 +00:00
|
|
|
lower: 0,
|
|
|
|
upper: 2,
|
|
|
|
page_size: 1,
|
|
|
|
page_increment: 1,
|
|
|
|
});
|
|
|
|
this._adjustment.connect('notify::value', () => {
|
|
|
|
this._setTransitionProgress(this._adjustment.value);
|
|
|
|
});
|
|
|
|
|
2021-03-01 16:53:55 +00:00
|
|
|
this._swipeTracker = new SwipeTracker.SwipeTracker(this,
|
|
|
|
Clutter.Orientation.VERTICAL,
|
|
|
|
Shell.ActionMode.UNLOCK_SCREEN);
|
2020-02-02 11:23:32 +00:00
|
|
|
this._swipeTracker.connect('begin', this._swipeBegin.bind(this));
|
|
|
|
this._swipeTracker.connect('update', this._swipeUpdate.bind(this));
|
|
|
|
this._swipeTracker.connect('end', this._swipeEnd.bind(this));
|
|
|
|
|
2020-02-11 16:46:11 +00:00
|
|
|
this.connect('scroll-event', (o, event) => {
|
|
|
|
if (this._swipeTracker.canHandleScrollEvent(event))
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
|
|
|
let direction = event.get_scroll_direction();
|
|
|
|
if (direction === Clutter.ScrollDirection.UP)
|
|
|
|
this._showClock();
|
|
|
|
else if (direction === Clutter.ScrollDirection.DOWN)
|
|
|
|
this._showPrompt();
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
});
|
|
|
|
|
2019-11-29 17:37:10 +00:00
|
|
|
this._activePage = null;
|
|
|
|
|
|
|
|
let tapAction = new Clutter.TapAction();
|
|
|
|
tapAction.connect('tap', this._showPrompt.bind(this));
|
|
|
|
this.add_action(tapAction);
|
|
|
|
|
2019-11-28 22:16:55 +00:00
|
|
|
// Background
|
|
|
|
this._backgroundGroup = new Clutter.Actor();
|
|
|
|
this.add_child(this._backgroundGroup);
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
2020-06-30 11:08:03 +00:00
|
|
|
const themeContext = St.ThemeContext.get_for_stage(global.stage);
|
2021-08-15 22:36:59 +00:00
|
|
|
themeContext.connectObject('notify::scale-factor',
|
|
|
|
() => this._updateBackgroundEffects(), this);
|
2020-06-30 11:08:03 +00:00
|
|
|
|
2019-11-28 22:16:55 +00:00
|
|
|
this._updateBackgrounds();
|
2021-08-15 22:36:59 +00:00
|
|
|
Main.layoutManager.connectObject('monitors-changed',
|
|
|
|
this._updateBackgrounds.bind(this), this);
|
2019-11-28 22:16:55 +00:00
|
|
|
|
2012-05-20 16:30:14 +00:00
|
|
|
this._userManager = AccountsService.UserManager.get_default();
|
|
|
|
this._userName = GLib.get_user_name();
|
|
|
|
this._user = this._userManager.get_user(this._userName);
|
|
|
|
|
2019-11-29 17:36:01 +00:00
|
|
|
// Authentication & Clock stack
|
2020-02-02 11:23:32 +00:00
|
|
|
this._stack = new Shell.Stack();
|
2019-11-29 17:36:01 +00:00
|
|
|
|
2019-11-29 16:36:47 +00:00
|
|
|
this._promptBox = new St.BoxLayout({ vertical: true });
|
2020-02-02 09:43:55 +00:00
|
|
|
this._promptBox.set_pivot_point(0.5, 0.5);
|
2020-02-02 11:10:10 +00:00
|
|
|
this._promptBox.hide();
|
2020-02-02 11:23:32 +00:00
|
|
|
this._stack.add_child(this._promptBox);
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2019-11-28 21:16:53 +00:00
|
|
|
this._clock = new Clock();
|
2020-02-02 09:43:55 +00:00
|
|
|
this._clock.set_pivot_point(0.5, 0.5);
|
2020-02-02 11:23:32 +00:00
|
|
|
this._stack.add_child(this._clock);
|
2019-11-29 17:37:10 +00:00
|
|
|
this._showClock();
|
2019-11-28 21:16:53 +00:00
|
|
|
|
2012-10-24 15:53:19 +00:00
|
|
|
this.allowCancel = false;
|
2012-08-07 15:38:12 +00:00
|
|
|
|
2019-12-02 14:01:20 +00:00
|
|
|
Main.ctrlAltTabManager.addGroup(this, _('Unlock Window'), 'dialog-password-symbolic');
|
2012-08-11 03:53:59 +00:00
|
|
|
|
2019-11-28 21:35:13 +00:00
|
|
|
// Notifications
|
|
|
|
this._notificationsBox = new NotificationsBox();
|
|
|
|
this._notificationsBox.connect('wake-up-screen', () => this.emit('wake-up-screen'));
|
2019-11-29 16:36:47 +00:00
|
|
|
|
2020-02-14 15:29:51 +00:00
|
|
|
// Switch User button
|
|
|
|
this._otherUserButton = new St.Button({
|
2022-12-01 18:14:04 +00:00
|
|
|
style_class: 'login-dialog-button switch-user-button',
|
2020-02-19 17:06:38 +00:00
|
|
|
accessible_name: _('Log in as another user'),
|
2021-09-04 09:33:00 +00:00
|
|
|
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
|
2020-02-19 13:30:05 +00:00
|
|
|
reactive: false,
|
|
|
|
opacity: 0,
|
2020-02-14 15:35:48 +00:00
|
|
|
x_align: Clutter.ActorAlign.END,
|
|
|
|
y_align: Clutter.ActorAlign.END,
|
2022-03-21 15:44:24 +00:00
|
|
|
icon_name: 'system-users-symbolic',
|
2020-02-14 15:29:51 +00:00
|
|
|
});
|
2020-02-19 13:30:05 +00:00
|
|
|
this._otherUserButton.set_pivot_point(0.5, 0.5);
|
2020-02-14 15:29:51 +00:00
|
|
|
this._otherUserButton.connect('clicked', this._otherUserClicked.bind(this));
|
|
|
|
|
2020-04-25 08:29:16 +00:00
|
|
|
this._screenSaverSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.screensaver' });
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
this._screenSaverSettings.connectObject('changed::user-switch-enabled',
|
|
|
|
this._updateUserSwitchVisibility.bind(this), this);
|
2020-04-25 08:29:16 +00:00
|
|
|
|
2021-05-06 13:32:48 +00:00
|
|
|
this._lockdownSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' });
|
|
|
|
this._lockdownSettings.connect('changed::disable-user-switching',
|
|
|
|
this._updateUserSwitchVisibility.bind(this));
|
|
|
|
|
2021-08-15 22:36:59 +00:00
|
|
|
this._user.connectObject('notify::is-loaded',
|
|
|
|
this._updateUserSwitchVisibility.bind(this), this);
|
2020-04-25 08:29:16 +00:00
|
|
|
|
|
|
|
this._updateUserSwitchVisibility();
|
2020-02-14 15:29:51 +00:00
|
|
|
|
2019-11-29 16:36:47 +00:00
|
|
|
// Main Box
|
2020-02-19 16:15:48 +00:00
|
|
|
let mainBox = new St.Widget();
|
2019-11-29 16:36:47 +00:00
|
|
|
mainBox.add_constraint(new Layout.MonitorConstraint({ primary: true }));
|
2020-02-02 11:23:32 +00:00
|
|
|
mainBox.add_child(this._stack);
|
2019-11-29 16:36:47 +00:00
|
|
|
mainBox.add_child(this._notificationsBox);
|
2020-02-14 15:29:51 +00:00
|
|
|
mainBox.add_child(this._otherUserButton);
|
2019-11-29 16:36:47 +00:00
|
|
|
mainBox.layout_manager = new UnlockDialogLayout(
|
2020-02-02 11:23:32 +00:00
|
|
|
this._stack,
|
2020-02-14 15:29:51 +00:00
|
|
|
this._notificationsBox,
|
|
|
|
this._otherUserButton);
|
2019-11-29 16:36:47 +00:00
|
|
|
this.add_child(mainBox);
|
2019-11-28 21:35:13 +00:00
|
|
|
|
2021-05-06 20:31:11 +00:00
|
|
|
this._idleMonitor = global.backend.get_core_idle_monitor();
|
2017-12-02 00:27:35 +00:00
|
|
|
this._idleWatchId = this._idleMonitor.add_idle_watch(IDLE_TIMEOUT * 1000, this._escape.bind(this));
|
2019-09-20 11:17:40 +00:00
|
|
|
|
|
|
|
this.connect('destroy', this._onDestroy.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2023-08-08 16:14:04 +00:00
|
|
|
vfunc_key_press_event(event) {
|
2019-11-29 17:37:10 +00:00
|
|
|
if (this._activePage === this._promptBox ||
|
|
|
|
(this._promptBox && this._promptBox.visible))
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
2023-08-08 16:14:04 +00:00
|
|
|
const keyval = event.get_key_symbol();
|
2020-02-14 19:19:37 +00:00
|
|
|
if (keyval === Clutter.KEY_Shift_L ||
|
|
|
|
keyval === Clutter.KEY_Shift_R ||
|
|
|
|
keyval === Clutter.KEY_Shift_Lock ||
|
|
|
|
keyval === Clutter.KEY_Caps_Lock)
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
|
2023-08-08 16:14:04 +00:00
|
|
|
let unichar = event.get_key_unicode();
|
2019-11-29 17:37:10 +00:00
|
|
|
|
|
|
|
this._showPrompt();
|
|
|
|
|
|
|
|
if (GLib.unichar_isgraph(unichar))
|
2020-04-22 19:14:13 +00:00
|
|
|
this._authPrompt.addCharacter(unichar);
|
2019-11-29 17:37:10 +00:00
|
|
|
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
}
|
|
|
|
|
2022-04-06 10:51:45 +00:00
|
|
|
vfunc_captured_event(event) {
|
|
|
|
if (Main.keyboard.maybeHandleEvent(event))
|
|
|
|
return Clutter.EVENT_STOP;
|
|
|
|
|
|
|
|
return Clutter.EVENT_PROPAGATE;
|
|
|
|
}
|
|
|
|
|
2019-11-28 22:16:55 +00: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,
|
2020-06-30 11:08:03 +00:00
|
|
|
effect: new Shell.BlurEffect({ name: 'blur' }),
|
2019-11-28 22:16:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
let bgManager = new Background.BackgroundManager({
|
|
|
|
container: widget,
|
|
|
|
monitorIndex,
|
|
|
|
controlPosition: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
this._bgManagers.push(bgManager);
|
|
|
|
|
|
|
|
this._backgroundGroup.add_child(widget);
|
2020-06-30 11:08:03 +00:00
|
|
|
}
|
2020-01-07 19:43:35 +00:00
|
|
|
|
2020-06-30 11:08:03 +00:00
|
|
|
_updateBackgroundEffects() {
|
2020-02-11 19:19:50 +00:00
|
|
|
const themeContext = St.ThemeContext.get_for_stage(global.stage);
|
|
|
|
|
2020-06-30 11:08:03 +00:00
|
|
|
for (const widget of this._backgroundGroup) {
|
2020-08-15 10:23:27 +00:00
|
|
|
const effect = widget.get_effect('blur');
|
|
|
|
|
|
|
|
if (effect) {
|
|
|
|
effect.set({
|
|
|
|
brightness: BLUR_BRIGHTNESS,
|
|
|
|
sigma: BLUR_SIGMA * themeContext.scale_factor,
|
|
|
|
});
|
|
|
|
}
|
2020-06-30 11:08:03 +00:00
|
|
|
}
|
2019-11-28 22:16:55 +00: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);
|
2020-06-30 11:08:03 +00:00
|
|
|
this._updateBackgroundEffects();
|
2019-11-28 22:16:55 +00:00
|
|
|
}
|
|
|
|
|
2019-12-02 14:01:20 +00:00
|
|
|
_ensureAuthPrompt() {
|
2021-10-05 15:01:19 +00:00
|
|
|
if (!this._authPrompt) {
|
|
|
|
this._authPrompt = new AuthPrompt.AuthPrompt(this._gdmClient,
|
|
|
|
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);
|
|
|
|
}
|
2019-12-02 14:01:20 +00:00
|
|
|
|
|
|
|
this._authPrompt.reset();
|
2020-02-19 13:24:51 +00:00
|
|
|
this._authPrompt.updateSensitivity(true);
|
2019-12-02 14:01:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_maybeDestroyAuthPrompt() {
|
|
|
|
let focus = global.stage.key_focus;
|
|
|
|
if (focus === null ||
|
2020-02-14 15:05:23 +00:00
|
|
|
(this._authPrompt && this._authPrompt.contains(focus)) ||
|
|
|
|
(this._otherUserButton && focus === this._otherUserButton))
|
2019-12-02 14:01:20 +00:00
|
|
|
this.grab_key_focus();
|
|
|
|
|
|
|
|
if (this._authPrompt) {
|
|
|
|
this._authPrompt.destroy();
|
|
|
|
this._authPrompt = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-29 17:37:10 +00:00
|
|
|
_showClock() {
|
|
|
|
if (this._activePage === this._clock)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._activePage = this._clock;
|
|
|
|
|
2020-02-02 11:10:10 +00:00
|
|
|
this._adjustment.ease(0, {
|
2019-11-29 17:37:10 +00:00
|
|
|
duration: CROSSFADE_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
2020-02-02 11:10:10 +00:00
|
|
|
onComplete: () => this._maybeDestroyAuthPrompt(),
|
2019-11-29 17:37:10 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_showPrompt() {
|
2019-12-02 14:01:20 +00:00
|
|
|
this._ensureAuthPrompt();
|
|
|
|
|
2019-11-29 17:37:10 +00:00
|
|
|
if (this._activePage === this._promptBox)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._activePage = this._promptBox;
|
|
|
|
|
2020-02-02 11:10:10 +00:00
|
|
|
this._adjustment.ease(1, {
|
|
|
|
duration: CROSSFADE_TIME,
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_QUAD,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_setTransitionProgress(progress) {
|
|
|
|
this._promptBox.visible = progress > 0;
|
|
|
|
this._clock.visible = progress < 1;
|
|
|
|
|
2020-02-19 13:30:05 +00:00
|
|
|
this._otherUserButton.set({
|
|
|
|
reactive: progress > 0,
|
|
|
|
can_focus: progress > 0,
|
|
|
|
});
|
|
|
|
|
2020-02-02 09:43:55 +00:00
|
|
|
const { scaleFactor } = St.ThemeContext.get_for_stage(global.stage);
|
|
|
|
|
|
|
|
this._promptBox.set({
|
2020-02-02 11:10:10 +00:00
|
|
|
opacity: 255 * progress,
|
|
|
|
scale_x: FADE_OUT_SCALE + (1 - FADE_OUT_SCALE) * progress,
|
|
|
|
scale_y: FADE_OUT_SCALE + (1 - FADE_OUT_SCALE) * progress,
|
|
|
|
translation_y: FADE_OUT_TRANSLATION * (1 - progress) * scaleFactor,
|
2019-11-29 17:37:10 +00:00
|
|
|
});
|
|
|
|
|
2020-02-02 11:10:10 +00:00
|
|
|
this._clock.set({
|
|
|
|
opacity: 255 * (1 - progress),
|
|
|
|
scale_x: FADE_OUT_SCALE + (1 - FADE_OUT_SCALE) * (1 - progress),
|
|
|
|
scale_y: FADE_OUT_SCALE + (1 - FADE_OUT_SCALE) * (1 - progress),
|
|
|
|
translation_y: -FADE_OUT_TRANSLATION * progress * scaleFactor,
|
2019-11-29 17:37:10 +00:00
|
|
|
});
|
2020-02-19 13:30:05 +00:00
|
|
|
|
|
|
|
this._otherUserButton.set({
|
|
|
|
opacity: 255 * progress,
|
|
|
|
scale_x: FADE_OUT_SCALE + (1 - FADE_OUT_SCALE) * progress,
|
|
|
|
scale_y: FADE_OUT_SCALE + (1 - FADE_OUT_SCALE) * progress,
|
|
|
|
});
|
2019-11-29 17:37:10 +00:00
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_fail() {
|
2019-11-29 19:14:26 +00:00
|
|
|
this._showClock();
|
2013-07-22 15:07:35 +00:00
|
|
|
this.emit('failed');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-03 21:15:41 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onReset(authPrompt, beginRequest) {
|
2013-07-28 21:49:50 +00:00
|
|
|
let userName;
|
|
|
|
if (beginRequest == AuthPrompt.BeginRequestType.PROVIDE_USERNAME) {
|
|
|
|
this._authPrompt.setUser(this._user);
|
|
|
|
userName = this._userName;
|
|
|
|
} else {
|
|
|
|
userName = null;
|
|
|
|
}
|
|
|
|
|
2019-08-19 19:06:04 +00:00
|
|
|
this._authPrompt.begin({ userName });
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-28 21:49:50 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_escape() {
|
2020-03-27 23:35:36 +00:00
|
|
|
if (this._authPrompt && this.allowCancel)
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt.cancel();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-03 17:26:30 +00:00
|
|
|
|
2020-02-02 11:23:32 +00:00
|
|
|
_swipeBegin(tracker, monitor) {
|
|
|
|
if (monitor !== Main.layoutManager.primaryIndex)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._adjustment.remove_transition('value');
|
|
|
|
|
|
|
|
this._ensureAuthPrompt();
|
|
|
|
|
|
|
|
let progress = this._adjustment.value;
|
|
|
|
tracker.confirmSwipe(this._stack.height,
|
|
|
|
[0, 1],
|
|
|
|
progress,
|
|
|
|
Math.round(progress));
|
|
|
|
}
|
|
|
|
|
|
|
|
_swipeUpdate(tracker, progress) {
|
|
|
|
this._adjustment.value = progress;
|
|
|
|
}
|
|
|
|
|
|
|
|
_swipeEnd(tracker, duration, endProgress) {
|
|
|
|
this._activePage = endProgress
|
|
|
|
? this._promptBox
|
|
|
|
: this._clock;
|
|
|
|
|
|
|
|
this._adjustment.ease(endProgress, {
|
|
|
|
mode: Clutter.AnimationMode.EASE_OUT_CUBIC,
|
|
|
|
duration,
|
|
|
|
onComplete: () => {
|
|
|
|
if (this._activePage === this._clock)
|
|
|
|
this._maybeDestroyAuthPrompt();
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-14 15:05:23 +00:00
|
|
|
_otherUserClicked() {
|
|
|
|
Gdm.goto_login_session_sync(null);
|
|
|
|
|
|
|
|
this._authPrompt.cancel();
|
|
|
|
}
|
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
_onDestroy() {
|
2013-07-22 15:07:35 +00:00
|
|
|
this.popModal();
|
2012-08-16 19:24:53 +00:00
|
|
|
|
|
|
|
if (this._idleWatchId) {
|
|
|
|
this._idleMonitor.remove_watch(this._idleWatchId);
|
|
|
|
this._idleWatchId = 0;
|
|
|
|
}
|
2019-11-28 22:16:55 +00:00
|
|
|
|
2020-02-13 20:36:51 +00:00
|
|
|
if (this._gdmClient) {
|
|
|
|
this._gdmClient = null;
|
|
|
|
delete this._gdmClient;
|
|
|
|
}
|
2020-04-25 08:29:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_updateUserSwitchVisibility() {
|
|
|
|
this._otherUserButton.visible = this._userManager.can_switch() &&
|
2021-05-06 13:32:48 +00:00
|
|
|
this._screenSaverSettings.get_boolean('user-switch-enabled') &&
|
|
|
|
!this._lockdownSettings.get_boolean('disable-user-switching');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-05-20 16:30:14 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
cancel() {
|
2019-12-02 14:01:20 +00:00
|
|
|
if (this._authPrompt)
|
|
|
|
this._authPrompt.cancel();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-05 05:55:54 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
finish(onComplete) {
|
2021-10-08 15:08:17 +00:00
|
|
|
if (!this._authPrompt) {
|
|
|
|
onComplete();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-22 15:07:35 +00:00
|
|
|
this._authPrompt.finish(onComplete);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
open(timestamp) {
|
2019-09-20 11:17:40 +00:00
|
|
|
this.show();
|
2013-07-16 11:31:22 +00:00
|
|
|
|
|
|
|
if (this._isModal)
|
|
|
|
return true;
|
2013-07-18 12:58:58 +00:00
|
|
|
|
2019-09-20 11:17:40 +00:00
|
|
|
let modalParams = {
|
|
|
|
timestamp,
|
|
|
|
actionMode: Shell.ActionMode.UNLOCK_SCREEN,
|
|
|
|
};
|
2022-05-13 12:30:00 +00:00
|
|
|
let grab = Main.pushModal(Main.uiGroup, modalParams);
|
2021-11-25 09:49:42 +00:00
|
|
|
if (grab.get_seat_state() !== Clutter.GrabState.ALL) {
|
|
|
|
Main.popModal(grab);
|
2013-07-16 11:31:22 +00:00
|
|
|
return false;
|
2021-11-25 09:49:42 +00:00
|
|
|
}
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2021-11-25 09:49:42 +00:00
|
|
|
this._grab = grab;
|
2013-07-16 11:31:22 +00:00
|
|
|
this._isModal = true;
|
|
|
|
|
|
|
|
return true;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-07-16 11:31:22 +00:00
|
|
|
|
2020-01-30 14:44:43 +00:00
|
|
|
activate() {
|
|
|
|
this._showPrompt();
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
popModal(timestamp) {
|
2013-07-16 11:31:22 +00:00
|
|
|
if (this._isModal) {
|
2021-11-25 09:49:42 +00:00
|
|
|
Main.popModal(this._grab, timestamp);
|
|
|
|
this._grab = null;
|
2013-07-16 11:31:22 +00:00
|
|
|
this._isModal = false;
|
|
|
|
}
|
2013-07-18 12:58:58 +00:00
|
|
|
}
|
2019-09-20 11:17:40 +00:00
|
|
|
});
|