2012-02-06 17:28:48 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
2013-06-08 11:22:43 -04:00
|
|
|
const AccountsService = imports.gi.AccountsService;
|
2012-08-20 13:56:08 -04:00
|
|
|
const Cairo = imports.cairo;
|
2012-02-06 17:28:48 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
|
|
|
const Gio = imports.gi.Gio;
|
2012-08-17 13:30:46 -04:00
|
|
|
const GLib = imports.gi.GLib;
|
2012-05-27 18:50:56 -04:00
|
|
|
const GnomeDesktop = imports.gi.GnomeDesktop;
|
2013-07-18 17:20:10 -04:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2012-02-06 17:28:48 -05:00
|
|
|
const Lang = imports.lang;
|
2012-08-20 13:56:08 -04:00
|
|
|
const Mainloop = imports.mainloop;
|
2012-02-06 17:28:48 -05:00
|
|
|
const Meta = imports.gi.Meta;
|
2012-12-12 08:14:13 -05:00
|
|
|
const Shell = imports.gi.Shell;
|
2012-05-21 12:42:45 -04:00
|
|
|
const Signals = imports.signals;
|
2012-02-06 17:28:48 -05:00
|
|
|
const St = imports.gi.St;
|
2012-08-20 13:56:08 -04:00
|
|
|
const TweenerEquations = imports.tweener.equations;
|
2012-02-06 17:28:48 -05:00
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
const Background = imports.ui.background;
|
2012-02-06 17:28:48 -05:00
|
|
|
const GnomeSession = imports.misc.gnomeSession;
|
2012-08-14 09:39:17 -04:00
|
|
|
const Layout = imports.ui.layout;
|
2013-10-10 04:21:47 -04:00
|
|
|
const OVirt = imports.gdm.oVirt;
|
2012-08-18 08:05:52 -04:00
|
|
|
const LoginManager = imports.misc.loginManager;
|
2012-02-06 17:28:48 -05:00
|
|
|
const Lightbox = imports.ui.lightbox;
|
|
|
|
const Main = imports.ui.main;
|
2012-09-01 15:59:53 -04:00
|
|
|
const Overview = imports.ui.overview;
|
2012-05-22 18:02:00 -04:00
|
|
|
const MessageTray = imports.ui.messageTray;
|
2012-07-08 11:42:15 -04:00
|
|
|
const ShellDBus = imports.ui.shellDBus;
|
2013-06-27 08:54:19 -04:00
|
|
|
const SmartcardManager = imports.misc.smartcardManager;
|
2012-05-24 16:47:48 -04:00
|
|
|
const Tweener = imports.ui.tweener;
|
2012-10-18 19:44:28 -04:00
|
|
|
const Util = imports.misc.util;
|
2012-02-06 17:28:48 -05:00
|
|
|
|
|
|
|
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
|
|
|
|
const LOCK_ENABLED_KEY = 'lock-enabled';
|
2012-12-24 19:13:52 -05:00
|
|
|
const LOCK_DELAY_KEY = 'lock-delay';
|
2012-02-06 17:28:48 -05:00
|
|
|
|
2013-01-17 14:39:54 -05:00
|
|
|
const LOCKED_STATE_STR = 'screenShield.locked';
|
2012-05-24 16:47:48 -04:00
|
|
|
// fraction of screen height the arrow must reach before completing
|
|
|
|
// the slide up automatically
|
2012-09-03 20:51:53 -04:00
|
|
|
const ARROW_DRAG_THRESHOLD = 0.1;
|
2012-05-24 16:47:48 -04:00
|
|
|
|
2012-08-20 13:56:08 -04:00
|
|
|
// Parameters for the arrow animation
|
|
|
|
const N_ARROWS = 3;
|
|
|
|
const ARROW_ANIMATION_TIME = 0.6;
|
|
|
|
const ARROW_ANIMATION_PEAK_OPACITY = 0.4;
|
2012-12-29 09:24:03 -05:00
|
|
|
const ARROW_IDLE_TIME = 30000; // ms
|
2012-08-20 13:56:08 -04:00
|
|
|
|
2012-05-22 18:02:00 -04:00
|
|
|
const SUMMARY_ICON_SIZE = 48;
|
|
|
|
|
2013-01-29 10:04:19 -05: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
|
2012-12-24 09:20:39 -05:00
|
|
|
// - BACKGROUND_FADE_TIME is used when the background changes to crossfade to new background
|
2013-01-29 10:04:19 -05:00
|
|
|
// - CURTAIN_SLIDE_TIME is used when raising the shield before unlocking
|
2012-06-02 18:10:23 -04:00
|
|
|
const STANDARD_FADE_TIME = 10;
|
2013-03-25 13:18:33 -04:00
|
|
|
const MANUAL_FADE_TIME = 0.3;
|
2012-12-24 09:20:39 -05:00
|
|
|
const BACKGROUND_FADE_TIME = 1.0;
|
2013-01-29 10:04:19 -05:00
|
|
|
const CURTAIN_SLIDE_TIME = 0.3;
|
2012-06-02 18:10:23 -04:00
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
const Clock = new Lang.Class({
|
|
|
|
Name: 'ScreenShieldClock',
|
|
|
|
|
|
|
|
CLOCK_FORMAT_KEY: 'clock-format',
|
|
|
|
CLOCK_SHOW_SECONDS_KEY: 'clock-show-seconds',
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
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 });
|
|
|
|
this._wallClock.connect('notify::clock', Lang.bind(this, this._updateClock));
|
|
|
|
|
|
|
|
this._updateClock();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateClock: function() {
|
|
|
|
this._time.text = this._wallClock.clock;
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
/* Translators: This is a time format for a date in
|
|
|
|
long format */
|
|
|
|
this._date.text = date.toLocaleFormat(_("%A, %B %d"));
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
this.actor.destroy();
|
|
|
|
this._wallClock.run_dispose();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-05-22 18:02:00 -04:00
|
|
|
const NotificationsBox = new Lang.Class({
|
|
|
|
Name: 'NotificationsBox',
|
|
|
|
|
|
|
|
_init: function() {
|
|
|
|
this.actor = new St.BoxLayout({ vertical: true,
|
|
|
|
name: 'screenShieldNotifications',
|
2012-08-06 13:02:12 -04:00
|
|
|
style_class: 'screen-shield-notifications-box' });
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this._musicBin = new St.Bin({ style_class: 'screen-shield-notifications-box',
|
|
|
|
visible: false });
|
|
|
|
|
2012-12-03 13:43:04 -05:00
|
|
|
this._scrollView = new St.ScrollView({ x_fill: false, x_align: St.Align.START,
|
|
|
|
hscrollbar_policy: Gtk.PolicyType.NEVER });
|
2013-01-30 13:47:55 -05:00
|
|
|
this._notificationBox = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'screen-shield-notifications-box' });
|
2012-12-03 13:43:04 -05:00
|
|
|
this._scrollView.add_actor(this._notificationBox);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this.actor.add(this._musicBin);
|
2012-12-03 13:43:04 -05:00
|
|
|
this.actor.add(this._scrollView, { x_fill: true, x_align: St.Align.START });
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2014-01-14 17:49:47 -05:00
|
|
|
this._sources = new Map();
|
2013-01-30 13:47:55 -05:00
|
|
|
Main.messageTray.getSources().forEach(Lang.bind(this, function(source) {
|
|
|
|
this._sourceAdded(Main.messageTray, source, true);
|
2012-05-22 18:02:00 -04:00
|
|
|
}));
|
2012-08-16 16:38:22 -04:00
|
|
|
this._updateVisibility();
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this._sourceAddedId = Main.messageTray.connect('source-added', Lang.bind(this, this._sourceAdded));
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
2013-01-30 13:47:55 -05:00
|
|
|
if (this._sourceAddedId) {
|
|
|
|
Main.messageTray.disconnect(this._sourceAddedId);
|
|
|
|
this._sourceAddedId = 0;
|
2012-05-22 18:02:00 -04:00
|
|
|
}
|
|
|
|
|
2014-01-14 17:49:47 -05:00
|
|
|
let items = this._sources.entries();
|
|
|
|
for (let [source, obj] of items) {
|
2013-01-30 13:47:55 -05:00
|
|
|
this._removeSource(source, obj);
|
|
|
|
}
|
2012-05-22 18:02:00 -04:00
|
|
|
|
|
|
|
this.actor.destroy();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateVisibility: function() {
|
2013-01-30 13:47:55 -05:00
|
|
|
this._musicBin.visible = this._musicBin.child != null && this._musicBin.child.visible;
|
|
|
|
this._notificationBox.visible = this._notificationBox.get_children().some(function(a) {
|
2012-10-10 17:20:16 -04:00
|
|
|
return a.visible;
|
|
|
|
});
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this.actor.visible = this._musicBin.visible || this._notificationBox.visible;
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
2012-08-06 11:28:55 -04:00
|
|
|
_makeNotificationCountText: function(count, isChat) {
|
|
|
|
if (isChat)
|
|
|
|
return ngettext("%d new message", "%d new messages", count).format(count);
|
2012-05-22 18:02:00 -04:00
|
|
|
else
|
2012-08-06 11:28:55 -04:00
|
|
|
return ngettext("%d new notification", "%d new notifications", count).format(count);
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_makeNotificationSource: function(source, box) {
|
2012-05-22 18:02:00 -04:00
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
|
|
|
box.add(sourceActor.actor, { y_fill: true });
|
|
|
|
|
|
|
|
let textBox = new St.BoxLayout({ vertical: true });
|
2012-10-10 17:07:39 -04:00
|
|
|
box.add(textBox, { y_fill: false, y_align: St.Align.START });
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
let title = new St.Label({ text: source.title,
|
2012-05-22 18:02:00 -04:00
|
|
|
style_class: 'screen-shield-notification-label' });
|
2013-01-30 13:47:55 -05:00
|
|
|
textBox.add(title);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2012-08-06 11:28:55 -04:00
|
|
|
let count = source.unseenCount;
|
|
|
|
let countLabel = new St.Label({ text: this._makeNotificationCountText(count, source.isChat),
|
2012-05-22 18:02:00 -04:00
|
|
|
style_class: 'screen-shield-notification-count-text' });
|
|
|
|
textBox.add(countLabel);
|
|
|
|
|
2012-08-06 11:28:55 -04:00
|
|
|
box.visible = count != 0;
|
2013-01-30 13:47:55 -05:00
|
|
|
return [title, countLabel];
|
|
|
|
},
|
|
|
|
|
|
|
|
_makeNotificationDetailedSource: function(source, box) {
|
|
|
|
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
|
2013-02-14 11:13:13 -05:00
|
|
|
let sourceBin = new St.Bin({ y_align: St.Align.START,
|
|
|
|
x_align: St.Align.START,
|
|
|
|
child: sourceActor.actor });
|
|
|
|
box.add(sourceBin);
|
2013-01-30 13:47:55 -05: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];
|
|
|
|
|
|
|
|
if (n.acknowledged || n.isMusic)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
let body = '';
|
2013-01-31 07:33:31 -05:00
|
|
|
if (n.bannerBodyText) {
|
2013-11-04 09:55:40 -05:00
|
|
|
body = n.bannerBodyMarkup ? n.bannerBodyText
|
|
|
|
: GLib.markup_escape_text(n.bannerBodyText, -1);
|
2013-01-31 07:33:31 -05:00
|
|
|
}
|
|
|
|
|
2013-01-30 13:47:55 -05: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];
|
|
|
|
},
|
|
|
|
|
|
|
|
_showSource: function(source, obj, box) {
|
|
|
|
let musicNotification = source.getMusicNotification();
|
|
|
|
|
|
|
|
if (musicNotification != null &&
|
|
|
|
this._musicBin.child == null) {
|
2013-05-12 13:42:49 -04:00
|
|
|
musicNotification.acknowledged = true;
|
2013-01-30 13:47:55 -05:00
|
|
|
if (musicNotification.actor.get_parent() != null)
|
|
|
|
musicNotification.actor.get_parent().remove_actor(musicNotification.actor);
|
|
|
|
this._musicBin.child = musicNotification.actor;
|
|
|
|
this._musicBin.child.visible = obj.visible;
|
|
|
|
|
|
|
|
musicNotification.expand(false /* animate */);
|
|
|
|
|
|
|
|
obj.musicNotification = musicNotification;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 > (musicNotification ? 1 : 0));
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
2012-12-03 13:43:04 -05:00
|
|
|
_sourceAdded: function(tray, source, initial) {
|
2012-05-22 18:02:00 -04:00
|
|
|
let obj = {
|
2013-01-30 13:47:55 -05:00
|
|
|
visible: source.policy.showInLockScreen,
|
|
|
|
detailed: source.policy.detailsInLockScreen,
|
2012-05-22 18:02:00 -04:00
|
|
|
sourceDestroyId: 0,
|
2013-01-30 13:47:55 -05:00
|
|
|
sourceCountChangedId: 0,
|
|
|
|
sourceTitleChangedId: 0,
|
|
|
|
sourceUpdatedId: 0,
|
2013-05-12 13:42:49 -04:00
|
|
|
sourceNotifyId: 0,
|
2013-01-30 13:47:55 -05:00
|
|
|
musicNotification: null,
|
2012-05-22 18:02:00 -04:00
|
|
|
sourceBox: null,
|
2013-01-30 13:47:55 -05:00
|
|
|
titleLabel: null,
|
2012-05-22 18:02:00 -04:00
|
|
|
countLabel: null,
|
|
|
|
};
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
obj.sourceBox = new St.BoxLayout({ style_class: 'screen-shield-notification-source' });
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
this._notificationBox.add(obj.sourceBox, { x_fill: false, x_align: St.Align.START });
|
|
|
|
|
2013-05-12 13:42:49 -04:00
|
|
|
if (obj.musicNotification) {
|
|
|
|
obj.sourceNotifyId = source.connect('notify', Lang.bind(this, function(source, notification) {
|
|
|
|
notification.acknowledged = true;
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
obj.sourceCountChangedId = source.connect('count-updated', Lang.bind(this, function(source) {
|
|
|
|
this._countChanged(source, obj);
|
|
|
|
}));
|
|
|
|
obj.sourceTitleChangedId = source.connect('title-changed', Lang.bind(this, function(source) {
|
|
|
|
this._titleChanged(source, obj);
|
|
|
|
}));
|
|
|
|
obj.policyChangedId = source.policy.connect('policy-changed', Lang.bind(this, function(policy, key) {
|
|
|
|
if (key == 'show-in-lock-screen')
|
|
|
|
this._visibleChanged(source, obj);
|
|
|
|
else
|
|
|
|
this._detailedChanged(source, obj);
|
|
|
|
}));
|
|
|
|
obj.sourceDestroyId = source.connect('destroy', Lang.bind(this, function(source) {
|
|
|
|
this._onSourceDestroy(source, obj);
|
|
|
|
}));
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this._sources.set(source, obj);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2012-12-03 13:43:04 -05:00
|
|
|
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 = Gtk.PolicyType.NEVER;
|
|
|
|
|
|
|
|
let widget = obj.sourceBox;
|
|
|
|
let [, natHeight] = widget.get_preferred_height(-1);
|
|
|
|
widget.height = 0;
|
|
|
|
Tweener.addTween(widget,
|
|
|
|
{ height: natHeight,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
time: 0.25,
|
|
|
|
onComplete: function() {
|
|
|
|
this._scrollView.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
|
|
|
|
widget.set_height(-1);
|
|
|
|
},
|
|
|
|
onCompleteScope: this
|
|
|
|
});
|
2013-07-14 10:20:49 -04:00
|
|
|
|
2012-08-16 16:38:22 -04:00
|
|
|
this._updateVisibility();
|
2014-03-10 14:16:03 -04:00
|
|
|
this.emit('wake-up-screen');
|
2012-12-03 13:43:04 -05:00
|
|
|
}
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_titleChanged: function(source, obj) {
|
|
|
|
obj.titleLabel.text = source.title;
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_countChanged: function(source, obj) {
|
|
|
|
if (obj.detailed) {
|
|
|
|
// A new notification was pushed, or a previous notification was destroyed.
|
|
|
|
// Give up, and build the list again.
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05: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 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
obj.sourceBox.visible = obj.visible &&
|
|
|
|
(source.unseenCount > (obj.musicNotification ? 1 : 0));
|
2013-07-14 10:20:49 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this._updateVisibility();
|
2013-07-14 10:20:49 -04:00
|
|
|
if (obj.sourceBox.visible)
|
2014-03-10 14:16:03 -04:00
|
|
|
this.emit('wake-up-screen');
|
2013-01-30 13:47:55 -05:00
|
|
|
},
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_visibleChanged: function(source, obj) {
|
|
|
|
if (obj.visible == source.policy.showInLockScreen)
|
2012-05-22 18:02:00 -04:00
|
|
|
return;
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
obj.visible = source.policy.showInLockScreen;
|
|
|
|
if (obj.musicNotification)
|
|
|
|
obj.musicNotification.actor.visible = obj.visible;
|
|
|
|
obj.sourceBox.visible = obj.visible &&
|
|
|
|
source.unseenCount > (obj.musicNotification ? 1 : 0);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
|
|
|
this._updateVisibility();
|
2013-07-14 10:20:49 -04:00
|
|
|
if (obj.sourceBox.visible)
|
2014-03-10 14:16:03 -04:00
|
|
|
this.emit('wake-up-screen');
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_detailedChanged: function(source, obj) {
|
|
|
|
if (obj.detailed == source.policy.detailsInLockScreen)
|
|
|
|
return;
|
|
|
|
|
|
|
|
obj.detailed = source.policy.detailsInLockScreen;
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
obj.sourceBox.destroy_all_children();
|
|
|
|
obj.titleLabel = obj.countLabel = null;
|
|
|
|
this._showSource(source, obj, obj.sourceBox);
|
|
|
|
},
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_onSourceDestroy: function(source, obj) {
|
|
|
|
this._removeSource(source, obj);
|
2012-05-22 18:02:00 -04:00
|
|
|
this._updateVisibility();
|
|
|
|
},
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
_removeSource: function(source, obj) {
|
|
|
|
obj.sourceBox.destroy();
|
|
|
|
obj.sourceBox = obj.titleLabel = obj.countLabel = null;
|
|
|
|
|
2013-01-31 07:33:31 -05:00
|
|
|
if (obj.musicNotification) {
|
|
|
|
this._musicBin.child = null;
|
|
|
|
obj.musicNotification = null;
|
2013-05-12 13:42:49 -04:00
|
|
|
|
|
|
|
source.disconnect(obj.sourceNotifyId);
|
2013-01-31 07:33:31 -05:00
|
|
|
}
|
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
source.disconnect(obj.sourceDestroyId);
|
|
|
|
source.disconnect(obj.sourceCountChangedId);
|
|
|
|
source.disconnect(obj.sourceTitleChangedId);
|
|
|
|
source.policy.disconnect(obj.policyChangedId);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2013-01-30 13:47:55 -05:00
|
|
|
this._sources.delete(source);
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
});
|
2014-03-10 14:16:03 -04:00
|
|
|
Signals.addSignalMethods(NotificationsBox.prototype);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2012-08-21 15:13:33 -04:00
|
|
|
const Arrow = new Lang.Class({
|
|
|
|
Name: 'Arrow',
|
|
|
|
Extends: St.Bin,
|
|
|
|
|
|
|
|
_init: function(params) {
|
|
|
|
this.parent(params);
|
|
|
|
this.x_fill = this.y_fill = true;
|
|
|
|
this.set_offscreen_redirect(Clutter.OffscreenRedirect.ALWAYS);
|
|
|
|
|
|
|
|
this._drawingArea = new St.DrawingArea();
|
|
|
|
this._drawingArea.connect('repaint', Lang.bind(this, this._drawArrow));
|
|
|
|
this.child = this._drawingArea;
|
|
|
|
|
|
|
|
this._shadowHelper = null;
|
|
|
|
this._shadowWidth = this._shadowHeight = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
_drawArrow: function(arrow) {
|
|
|
|
let cr = arrow.get_context();
|
|
|
|
let [w, h] = arrow.get_surface_size();
|
|
|
|
let node = this.get_theme_node();
|
|
|
|
let thickness = node.get_length('-arrow-thickness');
|
|
|
|
|
|
|
|
Clutter.cairo_set_source_color(cr, node.get_foreground_color());
|
|
|
|
|
|
|
|
cr.setLineCap(Cairo.LineCap.ROUND);
|
|
|
|
cr.setLineWidth(thickness);
|
|
|
|
|
|
|
|
cr.moveTo(thickness / 2, h - thickness / 2);
|
|
|
|
cr.lineTo(w/2, thickness);
|
|
|
|
cr.lineTo(w - thickness / 2, h - thickness / 2);
|
|
|
|
cr.stroke();
|
2014-01-22 22:10:21 -05:00
|
|
|
cr.$dispose();
|
2012-08-21 15:13:33 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
vfunc_style_changed: function() {
|
|
|
|
let node = this.get_theme_node();
|
|
|
|
this._shadow = node.get_shadow('-arrow-shadow');
|
|
|
|
if (this._shadow)
|
|
|
|
this._shadowHelper = St.ShadowHelper.new(this._shadow);
|
|
|
|
else
|
|
|
|
this._shadowHelper = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
vfunc_paint: function() {
|
|
|
|
if (this._shadowHelper) {
|
|
|
|
this._shadowHelper.update(this._drawingArea);
|
|
|
|
|
|
|
|
let allocation = this._drawingArea.get_allocation_box();
|
|
|
|
let paintOpacity = this._drawingArea.get_paint_opacity();
|
|
|
|
this._shadowHelper.paint(allocation, paintOpacity);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._drawingArea.paint();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-31 10:36:40 -04:00
|
|
|
function clamp(value, min, max) {
|
|
|
|
return Math.max(min, Math.min(max, value));
|
|
|
|
}
|
|
|
|
|
2012-02-06 17:28:48 -05:00
|
|
|
/**
|
|
|
|
* To test screen shield, make sure to kill gnome-screensaver.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* https://bugzilla.gnome.org/show_bug.cgi?id=668703 explains the dependance.
|
|
|
|
*/
|
|
|
|
const ScreenShield = new Lang.Class({
|
|
|
|
Name: 'ScreenShield',
|
|
|
|
|
|
|
|
_init: function() {
|
2012-05-22 17:22:38 -04:00
|
|
|
this.actor = Main.layoutManager.screenShieldGroup;
|
|
|
|
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenState = MessageTray.State.HIDDEN;
|
2012-05-24 16:47:48 -04:00
|
|
|
this._lockScreenGroup = new St.Widget({ x_expand: true,
|
|
|
|
y_expand: true,
|
|
|
|
reactive: true,
|
|
|
|
can_focus: true,
|
2012-08-03 13:42:43 -04:00
|
|
|
name: 'lockScreenGroup',
|
2013-01-31 10:56:24 -05:00
|
|
|
visible: false,
|
2012-05-24 16:47:48 -04:00
|
|
|
});
|
2013-03-11 14:26:18 -04:00
|
|
|
this._lockScreenGroup.connect('key-press-event',
|
|
|
|
Lang.bind(this, this._onLockScreenKeyPress));
|
2012-09-02 08:48:08 -04:00
|
|
|
this._lockScreenGroup.connect('scroll-event',
|
|
|
|
Lang.bind(this, this._onLockScreenScroll));
|
2012-08-10 23:53:59 -04:00
|
|
|
Main.ctrlAltTabManager.addGroup(this._lockScreenGroup, _("Lock"), 'changes-prevent-symbolic');
|
2012-05-24 16:47:48 -04:00
|
|
|
|
2012-08-14 09:39:17 -04: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 16:47:48 -04:00
|
|
|
|
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 17:32:25 -05:00
|
|
|
this._backgroundGroup = new Clutter.Actor();
|
2012-12-24 09:20:39 -05:00
|
|
|
|
|
|
|
this._lockScreenGroup.add_actor(this._backgroundGroup);
|
|
|
|
this._backgroundGroup.lower_bottom();
|
|
|
|
this._bgManagers = [];
|
|
|
|
|
|
|
|
this._updateBackgrounds();
|
|
|
|
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._updateBackgrounds));
|
|
|
|
|
2012-12-29 09:24:03 -05:00
|
|
|
this._arrowAnimationId = 0;
|
|
|
|
this._arrowWatchId = 0;
|
|
|
|
this._arrowActiveWatchId = 0;
|
2012-08-20 13:56:08 -04:00
|
|
|
this._arrowContainer = new St.BoxLayout({ style_class: 'screen-shield-arrows',
|
|
|
|
vertical: true,
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
y_align: Clutter.ActorAlign.END,
|
|
|
|
// HACK: without these, ClutterBinLayout
|
|
|
|
// ignores alignment properties on the actor
|
|
|
|
x_expand: true,
|
|
|
|
y_expand: true });
|
|
|
|
|
|
|
|
for (let i = 0; i < N_ARROWS; i++) {
|
2012-08-21 15:13:33 -04:00
|
|
|
let arrow = new Arrow({ opacity: 0 });
|
2012-08-20 13:56:08 -04:00
|
|
|
this._arrowContainer.add_actor(arrow);
|
|
|
|
}
|
|
|
|
this._lockScreenContents.add_actor(this._arrowContainer);
|
2012-05-24 16:47:48 -04:00
|
|
|
|
2012-08-31 10:36:40 -04:00
|
|
|
this._dragAction = new Clutter.GestureAction();
|
|
|
|
this._dragAction.connect('gesture-begin', Lang.bind(this, this._onDragBegin));
|
|
|
|
this._dragAction.connect('gesture-progress', Lang.bind(this, this._onDragMotion));
|
|
|
|
this._dragAction.connect('gesture-end', Lang.bind(this, this._onDragEnd));
|
|
|
|
this._lockScreenGroup.add_action(this._dragAction);
|
2012-05-24 16:47:48 -04:00
|
|
|
|
2012-08-14 09:39:17 -04:00
|
|
|
this._lockDialogGroup = new St.Widget({ x_expand: true,
|
|
|
|
y_expand: true,
|
2013-08-12 09:14:37 -04:00
|
|
|
reactive: true,
|
2012-09-01 15:59:53 -04:00
|
|
|
pivot_point: new Clutter.Point({ x: 0.5, y: 0.5 }),
|
2012-08-14 09:39:17 -04:00
|
|
|
name: 'lockDialogGroup' });
|
|
|
|
|
2012-05-24 16:47:48 -04:00
|
|
|
this.actor.add_actor(this._lockDialogGroup);
|
|
|
|
this.actor.add_actor(this._lockScreenGroup);
|
|
|
|
|
2012-02-06 17:28:48 -05:00
|
|
|
this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
|
|
|
|
if (error) {
|
|
|
|
logError(error, 'Error while reading gnome-session presence');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._onStatusChanged(proxy.status);
|
|
|
|
}));
|
|
|
|
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
|
|
|
|
this._onStatusChanged(status);
|
|
|
|
}));
|
|
|
|
|
2012-07-08 11:42:15 -04:00
|
|
|
this._screenSaverDBus = new ShellDBus.ScreenSaverDBus(this);
|
|
|
|
|
2013-06-27 08:54:19 -04:00
|
|
|
this._smartcardManager = SmartcardManager.getSmartcardManager();
|
|
|
|
this._smartcardManager.connect('smartcard-inserted',
|
2014-03-13 13:36:42 -04:00
|
|
|
Lang.bind(this, function(manager, token) {
|
2013-06-27 08:54:19 -04:00
|
|
|
if (this._isLocked && token.UsedToLogin)
|
|
|
|
this._liftShield(true, 0);
|
|
|
|
}));
|
|
|
|
|
2013-10-10 04:21:47 -04:00
|
|
|
this._oVirtCredentialsManager = OVirt.getOVirtCredentialsManager();
|
|
|
|
this._oVirtCredentialsManager.connect('user-authenticated',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
if (this._isLocked)
|
|
|
|
this._liftShield(true, 0);
|
|
|
|
}));
|
|
|
|
|
2012-10-23 09:48:49 -04:00
|
|
|
this._inhibitor = null;
|
2013-03-14 11:37:40 -04:00
|
|
|
this._aboutToSuspend = false;
|
2012-08-18 08:05:52 -04:00
|
|
|
this._loginManager = LoginManager.getLoginManager();
|
2012-10-23 09:48:49 -04:00
|
|
|
this._loginManager.connect('prepare-for-sleep',
|
|
|
|
Lang.bind(this, this._prepareForSleep));
|
|
|
|
this._inhibitSuspend();
|
|
|
|
|
2013-03-25 13:25:30 -04:00
|
|
|
this._loginManager.getCurrentSessionProxy(Lang.bind(this,
|
|
|
|
function(sessionProxy) {
|
|
|
|
this._loginSession = sessionProxy;
|
|
|
|
this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
|
|
|
|
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
|
|
|
|
}));
|
2012-08-17 08:24:17 -04:00
|
|
|
|
2014-06-24 15:17:09 -04:00
|
|
|
this._settings = new Gio.Settings({ schema_id: SCREENSAVER_SCHEMA });
|
2012-02-06 17:28:48 -05:00
|
|
|
|
2012-05-21 12:42:45 -04:00
|
|
|
this._isModal = false;
|
2012-05-27 18:50:56 -04:00
|
|
|
this._hasLockScreen = false;
|
2012-08-26 10:53:08 -04:00
|
|
|
this._isGreeter = false;
|
|
|
|
this._isActive = false;
|
2013-02-02 11:10:45 -05:00
|
|
|
this._isLocked = false;
|
2012-09-21 18:06:26 -04:00
|
|
|
this._inUnlockAnimation = false;
|
2012-10-16 10:38:32 -04:00
|
|
|
this._activationTime = 0;
|
2013-01-17 17:55:17 -05:00
|
|
|
this._becameActiveId = 0;
|
2013-01-27 09:45:04 -05:00
|
|
|
this._lockTimeoutId = 0;
|
2012-05-22 17:22:38 -04:00
|
|
|
|
2013-08-17 13:40:09 -04: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 });
|
|
|
|
this._longLightbox.connect('shown', Lang.bind(this, this._onLongLightboxShown));
|
|
|
|
this._shortLightbox = new Lightbox.Lightbox(Main.uiGroup,
|
|
|
|
{ inhibitEvents: true,
|
|
|
|
fadeFactor: 1 });
|
|
|
|
this._shortLightbox.connect('shown', Lang.bind(this, this._onShortLightboxShown));
|
2012-10-28 07:26:21 -04:00
|
|
|
|
2013-08-14 09:47:27 -04:00
|
|
|
this.idleMonitor = Meta.IdleMonitor.get_core();
|
2013-08-14 10:59:39 -04:00
|
|
|
this._cursorTracker = Meta.CursorTracker.get_for_screen(global.screen);
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
2012-05-22 17:22:38 -04:00
|
|
|
|
2012-12-24 09:20:39 -05:00
|
|
|
_createBackground: function(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 17:32:25 -05:00
|
|
|
let monitor = Main.layoutManager.monitors[monitorIndex];
|
|
|
|
let widget = new St.Widget({ style_class: 'screen-shield-background',
|
|
|
|
x: monitor.x,
|
|
|
|
y: monitor.y,
|
|
|
|
width: monitor.width,
|
|
|
|
height: monitor.height });
|
|
|
|
|
|
|
|
let bgManager = new Background.BackgroundManager({ container: widget,
|
2012-12-24 09:20:39 -05:00
|
|
|
monitorIndex: monitorIndex,
|
2013-08-19 18:51:34 -04:00
|
|
|
controlPosition: false,
|
|
|
|
settingsSchema: SCREENSAVER_SCHEMA });
|
2012-12-24 09:20:39 -05: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 17:32:25 -05:00
|
|
|
this._backgroundGroup.add_child(widget);
|
2012-12-24 09:20:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateBackgrounds: function() {
|
|
|
|
for (let i = 0; i < this._bgManagers.length; i++)
|
|
|
|
this._bgManagers[i].destroy();
|
|
|
|
|
|
|
|
this._bgManagers = [];
|
2013-04-04 16:59:39 -04:00
|
|
|
this._backgroundGroup.destroy_all_children();
|
2012-12-24 09:20:39 -05:00
|
|
|
|
|
|
|
for (let i = 0; i < Main.layoutManager.monitors.length; i++)
|
|
|
|
this._createBackground(i);
|
|
|
|
},
|
|
|
|
|
2013-01-27 09:45:04 -05:00
|
|
|
_liftShield: function(onPrimary, velocity) {
|
|
|
|
if (this._isLocked) {
|
2013-06-08 10:03:14 -04:00
|
|
|
if (this._ensureUnlockDialog(onPrimary, true /* allowCancel */))
|
|
|
|
this._hideLockScreen(true /* animate */, velocity);
|
2013-01-27 09:45:04 -05:00
|
|
|
} else {
|
|
|
|
this.deactivate(true /* animate */);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-08 13:04:36 -04:00
|
|
|
_maybeCancelDialog: function() {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-11-26 14:18:57 -05:00
|
|
|
_becomeModal: function() {
|
|
|
|
if (this._isModal)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
this._isModal = Main.pushModal(this.actor, { keybindingMode: Shell.KeyBindingMode.LOCK_SCREEN });
|
|
|
|
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,
|
|
|
|
keybindingMode: Shell.KeyBindingMode.LOCK_SCREEN });
|
|
|
|
return this._isModal;
|
|
|
|
},
|
|
|
|
|
2013-03-11 14:26:18 -04:00
|
|
|
_onLockScreenKeyPress: function(actor, event) {
|
2012-09-12 15:52:59 -04:00
|
|
|
let symbol = event.get_key_symbol();
|
2012-11-05 15:38:50 -05:00
|
|
|
let unichar = event.get_key_unicode();
|
2012-09-12 15:52:59 -04:00
|
|
|
|
2012-10-03 17:13:25 -04: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 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-10-03 17:13:25 -04:00
|
|
|
|
2013-03-12 12:57:04 -04:00
|
|
|
let isEnter = (symbol == Clutter.KEY_Return || symbol == Clutter.KEY_KP_Enter);
|
|
|
|
if (!isEnter && !(GLib.unichar_isprint(unichar) || symbol == Clutter.KEY_Escape))
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-05-24 16:47:48 -04:00
|
|
|
|
2013-06-08 12:59:20 -04:00
|
|
|
if (this._isLocked &&
|
|
|
|
this._ensureUnlockDialog(true, true) &&
|
2013-06-08 10:03:14 -04:00
|
|
|
GLib.unichar_isgraph(unichar))
|
2013-03-05 00:55:54 -05:00
|
|
|
this._dialog.addCharacter(unichar);
|
|
|
|
|
2012-11-05 15:38:50 -05:00
|
|
|
this._liftShield(true, 0);
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
|
|
|
|
2012-09-02 08:48:08 -04:00
|
|
|
_onLockScreenScroll: function(actor, event) {
|
|
|
|
if (this._lockScreenState != MessageTray.State.SHOWN)
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2012-09-02 08:48:08 -04:00
|
|
|
|
|
|
|
let delta = 0;
|
|
|
|
if (event.get_scroll_direction() == Clutter.ScrollDirection.UP)
|
|
|
|
delta = 5;
|
|
|
|
else if (event.get_scroll_direction() == Clutter.ScrollDirection.SMOOTH)
|
|
|
|
delta = Math.max(0, event.get_scroll_delta()[0]);
|
|
|
|
|
|
|
|
this._lockScreenScrollCounter += delta;
|
|
|
|
|
|
|
|
// 7 standard scrolls to lift up
|
|
|
|
if (this._lockScreenScrollCounter > 35) {
|
2013-01-27 09:45:04 -05:00
|
|
|
this._liftShield(true, 0);
|
2012-09-02 08:48:08 -04:00
|
|
|
}
|
|
|
|
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_STOP;
|
2012-09-02 08:48:08 -04:00
|
|
|
},
|
|
|
|
|
2012-10-23 09:48:49 -04:00
|
|
|
_inhibitSuspend: function() {
|
|
|
|
this._loginManager.inhibit(_("GNOME needs to lock the screen"),
|
|
|
|
Lang.bind(this, function(inhibitor) {
|
|
|
|
this._inhibitor = inhibitor;
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
_uninhibitSuspend: function() {
|
|
|
|
if (this._inhibitor)
|
|
|
|
this._inhibitor.close(null);
|
|
|
|
this._inhibitor = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_prepareForSleep: function(loginManager, aboutToSuspend) {
|
2013-03-14 11:37:40 -04:00
|
|
|
this._aboutToSuspend = aboutToSuspend;
|
|
|
|
|
2012-10-23 09:48:49 -04:00
|
|
|
if (aboutToSuspend) {
|
|
|
|
if (!this._settings.get_boolean(LOCK_ENABLED_KEY)) {
|
|
|
|
this._uninhibitSuspend();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.lock(true);
|
|
|
|
} else {
|
|
|
|
this._inhibitSuspend();
|
2013-08-23 08:14:22 -04:00
|
|
|
|
2014-03-14 18:12:28 -04:00
|
|
|
this._wakeUpScreen();
|
2012-10-23 09:48:49 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-08-20 13:56:08 -04:00
|
|
|
_animateArrows: function() {
|
|
|
|
let arrows = this._arrowContainer.get_children();
|
|
|
|
let unitaryDelay = ARROW_ANIMATION_TIME / (arrows.length + 1);
|
|
|
|
let maxOpacity = 255 * ARROW_ANIMATION_PEAK_OPACITY;
|
|
|
|
for (let i = 0; i < arrows.length; i++) {
|
|
|
|
arrows.opacity = 0;
|
|
|
|
Tweener.addTween(arrows[i],
|
|
|
|
{ opacity: 0,
|
|
|
|
delay: unitaryDelay * (N_ARROWS - (i + 1)),
|
|
|
|
time: ARROW_ANIMATION_TIME,
|
|
|
|
transition: function(t, b, c, d) {
|
|
|
|
if (t < d/2)
|
|
|
|
return TweenerEquations.easeOutQuad(t, 0, maxOpacity, d/2);
|
|
|
|
else
|
|
|
|
return TweenerEquations.easeInQuad(t - d/2, maxOpacity, -maxOpacity, d/2);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_CONTINUE;
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDragBegin: function() {
|
|
|
|
Tweener.removeTweens(this._lockScreenGroup);
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenState = MessageTray.State.HIDING;
|
2013-01-27 09:45:04 -05:00
|
|
|
|
|
|
|
if (this._isLocked)
|
|
|
|
this._ensureUnlockDialog(false, false);
|
2012-08-31 10:36:40 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onDragMotion: function() {
|
|
|
|
let [origX, origY] = this._dragAction.get_press_coords(0);
|
|
|
|
let [currentX, currentY] = this._dragAction.get_motion_coords(0);
|
|
|
|
|
|
|
|
let newY = currentY - origY;
|
|
|
|
newY = clamp(newY, -global.stage.height, 0);
|
|
|
|
|
|
|
|
this._lockScreenGroup.y = newY;
|
|
|
|
|
|
|
|
return true;
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDragEnd: function(action, actor, eventX, eventY, modifiers) {
|
2013-06-26 09:47:33 -04:00
|
|
|
if (this._lockScreenState != MessageTray.State.HIDING)
|
|
|
|
return;
|
2012-09-03 20:51:53 -04:00
|
|
|
if (this._lockScreenGroup.y < -(ARROW_DRAG_THRESHOLD * global.stage.height)) {
|
2012-05-24 16:47:48 -04:00
|
|
|
// Complete motion automatically
|
2012-08-31 10:36:40 -04:00
|
|
|
let [velocity, velocityX, velocityY] = this._dragAction.get_velocity(0);
|
2013-01-27 09:45:04 -05:00
|
|
|
this._liftShield(true, -velocityY);
|
2012-05-24 16:47:48 -04: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;
|
2013-01-29 10:04:19 -05:00
|
|
|
let time = MANUAL_FADE_TIME * (-this._lockScreenGroup.y) / h;
|
2012-05-24 16:47:48 -04:00
|
|
|
Tweener.removeTweens(this._lockScreenGroup);
|
|
|
|
Tweener.addTween(this._lockScreenGroup,
|
|
|
|
{ y: 0,
|
|
|
|
time: time,
|
2012-10-23 20:26:20 -04:00
|
|
|
transition: 'easeInQuad',
|
2012-05-24 16:47:48 -04:00
|
|
|
onComplete: function() {
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenGroup.fixed_position_set = false;
|
|
|
|
this._lockScreenState = MessageTray.State.SHOWN;
|
|
|
|
},
|
|
|
|
onCompleteScope: this,
|
2012-05-24 16:47:48 -04:00
|
|
|
});
|
2012-08-07 12:07:07 -04:00
|
|
|
|
2013-06-08 13:04:36 -04:00
|
|
|
this._maybeCancelDialog();
|
2012-05-24 16:47:48 -04:00
|
|
|
}
|
2012-02-06 17:28:48 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onStatusChanged: function(status) {
|
2012-10-28 07:26:21 -04:00
|
|
|
if (status != GnomeSession.PresenceStatus.IDLE)
|
|
|
|
return;
|
2012-05-21 12:42:45 -04:00
|
|
|
|
2013-06-08 13:04:36 -04:00
|
|
|
this._maybeCancelDialog();
|
2012-05-21 12:42:45 -04:00
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
if (this._longLightbox.actor.visible ||
|
2013-01-17 17:55:17 -05:00
|
|
|
this._isActive) {
|
|
|
|
// We're either shown and active, or in the process of
|
|
|
|
// showing.
|
|
|
|
// The latter is a very unlikely condition (it requires
|
|
|
|
// idle-delay < 20), but in any case we have nothing
|
|
|
|
// to do at this point: either isActive is true, or
|
|
|
|
// it will soon be.
|
|
|
|
// isActive can also be true if the lightbox is hidden,
|
|
|
|
// in case the shield is down and the user hasn't unlocked yet
|
|
|
|
return;
|
2012-10-28 07:26:21 -04:00
|
|
|
}
|
2012-10-16 10:38:32 -04:00
|
|
|
|
2013-06-04 12:58:58 -04: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 13:40:09 -04:00
|
|
|
//
|
2013-06-04 12:58:58 -04: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 17:55:17 -05:00
|
|
|
if (this._activationTime == 0)
|
|
|
|
this._activationTime = GLib.get_monotonic_time();
|
2012-10-28 07:26:21 -04:00
|
|
|
|
2013-01-27 09:45:04 -05:00
|
|
|
let shouldLock = this._settings.get_boolean(LOCK_ENABLED_KEY) && !this._isLocked;
|
|
|
|
|
|
|
|
if (shouldLock) {
|
|
|
|
let lockTimeout = Math.max(STANDARD_FADE_TIME, this._settings.get_uint(LOCK_DELAY_KEY));
|
|
|
|
this._lockTimeoutId = Mainloop.timeout_add(lockTimeout * 1000,
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this._lockTimeoutId = 0;
|
2013-08-17 13:40:09 -04:00
|
|
|
this.lock(false);
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-01-27 09:45:04 -05:00
|
|
|
}));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._lockTimeoutId, '[gnome-shell] this.lock');
|
2013-01-27 09:45:04 -05:00
|
|
|
}
|
2013-08-17 13:40:09 -04:00
|
|
|
|
|
|
|
this._activateFade(this._longLightbox, STANDARD_FADE_TIME);
|
|
|
|
},
|
|
|
|
|
|
|
|
_activateFade: function(lightbox, time) {
|
|
|
|
lightbox.show(time);
|
|
|
|
|
|
|
|
if (this._becameActiveId == 0)
|
|
|
|
this._becameActiveId = this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onUserBecameActive));
|
2013-01-17 17:55:17 -05:00
|
|
|
},
|
2012-10-28 07:26:21 -04:00
|
|
|
|
2013-01-17 17:55:17 -05:00
|
|
|
_onUserBecameActive: function() {
|
|
|
|
// This function gets called here when the user becomes active
|
2013-08-17 13:40:09 -04: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 17:55:17 -05:00
|
|
|
// we just go back to the lock screen curtain
|
2013-08-17 13:40:09 -04: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 17:55:17 -05:00
|
|
|
|
2013-01-18 00:24:32 -05:00
|
|
|
this.idleMonitor.remove_watch(this._becameActiveId);
|
2013-01-17 17:55:17 -05:00
|
|
|
this._becameActiveId = 0;
|
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
if (this._isActive || this._isLocked) {
|
|
|
|
this._longLightbox.hide();
|
|
|
|
this._shortLightbox.hide();
|
|
|
|
} else {
|
2013-01-27 09:45:04 -05:00
|
|
|
this.deactivate(false);
|
2012-02-06 17:28:48 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
_onLongLightboxShown: function() {
|
2013-01-27 09:45:04 -05:00
|
|
|
this.activate(false);
|
2013-01-17 17:55:17 -05:00
|
|
|
},
|
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
_onShortLightboxShown: function() {
|
|
|
|
this._completeLockScreenShown();
|
|
|
|
},
|
|
|
|
|
2012-05-26 11:04:25 -04:00
|
|
|
showDialog: function() {
|
2012-09-04 14:47:20 -04:00
|
|
|
// Ensure that the stage window is mapped, before taking a grab
|
|
|
|
// otherwise X errors out
|
2012-10-24 10:17:43 -04:00
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
|
2012-11-26 14:18:57 -05: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-09-04 14:47:20 -04:00
|
|
|
}
|
|
|
|
|
2012-10-24 10:17:43 -04:00
|
|
|
return false;
|
2012-09-04 14:47:20 -04:00
|
|
|
}));
|
2012-08-26 10:53:08 -04:00
|
|
|
|
|
|
|
this.actor.show();
|
|
|
|
this._isGreeter = Main.sessionMode.isGreeter;
|
2013-01-27 09:45:04 -05:00
|
|
|
this._isLocked = true;
|
2013-06-08 10:03:14 -04:00
|
|
|
if (this._ensureUnlockDialog(true, true))
|
|
|
|
this._hideLockScreen(false, 0);
|
2012-05-26 11:04:25 -04:00
|
|
|
},
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2013-03-02 15:21:20 -05:00
|
|
|
_hideLockScreenComplete: function() {
|
|
|
|
if (Main.sessionMode.currentMode == 'lock-screen')
|
|
|
|
Main.sessionMode.popMode('lock-screen');
|
|
|
|
|
|
|
|
this._lockScreenState = MessageTray.State.HIDDEN;
|
|
|
|
this._lockScreenGroup.hide();
|
|
|
|
},
|
|
|
|
|
2012-08-31 10:36:40 -04:00
|
|
|
_hideLockScreen: function(animate, velocity) {
|
2013-01-27 09:45:04 -05:00
|
|
|
if (this._lockScreenState == MessageTray.State.HIDDEN)
|
|
|
|
return;
|
|
|
|
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenState = MessageTray.State.HIDING;
|
|
|
|
|
2013-06-03 17:45:31 -04:00
|
|
|
Tweener.removeTweens(this._lockScreenGroup);
|
|
|
|
|
2012-05-26 11:04:25 -04:00
|
|
|
if (animate) {
|
|
|
|
// Tween the lock screen out of screen
|
2012-08-31 10:36:40 -04: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 11:04:25 -04:00
|
|
|
let h = global.stage.height;
|
2012-08-31 10:36:40 -04:00
|
|
|
let delta = (h + this._lockScreenGroup.y);
|
|
|
|
let min_velocity = global.stage.height / (CURTAIN_SLIDE_TIME * 1000);
|
|
|
|
|
|
|
|
velocity = Math.max(min_velocity, velocity);
|
|
|
|
let time = (delta / velocity) / 1000;
|
|
|
|
|
2012-05-26 11:04:25 -04:00
|
|
|
Tweener.addTween(this._lockScreenGroup,
|
|
|
|
{ y: -h,
|
|
|
|
time: time,
|
2012-10-23 20:26:20 -04:00
|
|
|
transition: 'easeInQuad',
|
2013-03-02 15:21:20 -05:00
|
|
|
onComplete: Lang.bind(this, this._hideLockScreenComplete),
|
2012-05-26 11:04:25 -04:00
|
|
|
});
|
|
|
|
} else {
|
2013-03-02 15:21:20 -05:00
|
|
|
this._hideLockScreenComplete();
|
2012-05-26 11:04:25 -04:00
|
|
|
}
|
|
|
|
|
2013-08-14 10:59:39 -04:00
|
|
|
this._cursorTracker.set_pointer_visible(true);
|
2012-08-26 17:15:59 -04:00
|
|
|
},
|
|
|
|
|
2012-10-24 11:53:19 -04:00
|
|
|
_ensureUnlockDialog: function(onPrimary, allowCancel) {
|
2012-05-26 11:04:25 -04:00
|
|
|
if (!this._dialog) {
|
2012-09-04 13:28:19 -04:00
|
|
|
let constructor = Main.sessionMode.unlockDialog;
|
2012-11-06 17:41:51 -05:00
|
|
|
if (!constructor) {
|
2012-05-26 11:04:25 -04:00
|
|
|
// This session mode has no locking capabilities
|
2013-01-27 09:45:04 -05:00
|
|
|
this.deactivate(true);
|
2013-06-08 10:03:14 -04:00
|
|
|
return false;
|
2012-05-26 11:04:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-06 17:41:51 -05:00
|
|
|
this._dialog = new constructor(this._lockDialogGroup);
|
|
|
|
|
|
|
|
|
2012-10-14 12:34:22 -04:00
|
|
|
let time = global.get_current_time();
|
2013-03-05 01:51:28 -05: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 10:03:14 -04:00
|
|
|
return false;
|
2013-03-05 01:51:28 -05:00
|
|
|
}
|
2012-05-26 11:04:25 -04:00
|
|
|
|
|
|
|
this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed));
|
|
|
|
}
|
2012-10-24 11:53:19 -04:00
|
|
|
|
|
|
|
this._dialog.allowCancel = allowCancel;
|
2013-06-08 10:03:14 -04:00
|
|
|
return true;
|
2012-02-06 17:28:48 -05:00
|
|
|
},
|
|
|
|
|
2012-05-20 12:30:14 -04:00
|
|
|
_onUnlockFailed: function() {
|
2013-05-12 11:32:02 -04:00
|
|
|
this._resetLockScreen({ animateLockScreen: true,
|
2013-08-17 13:40:09 -04:00
|
|
|
fadeToBlack: false });
|
2012-05-20 12:30:14 -04:00
|
|
|
},
|
|
|
|
|
2013-05-12 11:32:02 -04:00
|
|
|
_resetLockScreen: function(params) {
|
2013-01-27 09:45:04 -05: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 09:25:03 -05:00
|
|
|
return;
|
|
|
|
|
2012-08-26 10:53:08 -04:00
|
|
|
this._ensureLockScreen();
|
2012-09-01 15:59:53 -04:00
|
|
|
this._lockDialogGroup.scale_x = 1;
|
|
|
|
this._lockDialogGroup.scale_y = 1;
|
|
|
|
|
2012-08-03 13:42:43 -04:00
|
|
|
this._lockScreenGroup.show();
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenState = MessageTray.State.SHOWING;
|
2012-08-03 13:42:43 -04:00
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
let fadeToBlack = params.fadeToBlack;
|
|
|
|
|
2013-05-12 11:32:02 -04:00
|
|
|
if (params.animateLockScreen) {
|
2012-08-03 13:42:43 -04:00
|
|
|
this._lockScreenGroup.y = -global.screen_height;
|
|
|
|
Tweener.removeTweens(this._lockScreenGroup);
|
|
|
|
Tweener.addTween(this._lockScreenGroup,
|
|
|
|
{ y: 0,
|
2013-01-29 10:04:19 -05:00
|
|
|
time: MANUAL_FADE_TIME,
|
2012-10-23 20:26:20 -04:00
|
|
|
transition: 'easeOutQuad',
|
2012-06-02 18:10:23 -04:00
|
|
|
onComplete: function() {
|
2013-08-17 13:40:09 -04:00
|
|
|
this._lockScreenShown({ fadeToBlack: fadeToBlack,
|
|
|
|
animateFade: true });
|
2012-06-02 18:10:23 -04:00
|
|
|
},
|
|
|
|
onCompleteScope: this
|
|
|
|
});
|
2012-08-13 19:43:59 -04:00
|
|
|
} else {
|
|
|
|
this._lockScreenGroup.fixed_position_set = false;
|
2013-08-17 13:40:09 -04:00
|
|
|
this._lockScreenShown({ fadeToBlack: fadeToBlack,
|
|
|
|
animateFade: false });
|
2012-08-13 19:43:59 -04:00
|
|
|
}
|
2012-08-03 13:42:43 -04:00
|
|
|
|
2012-05-24 16:47:48 -04:00
|
|
|
this._lockScreenGroup.grab_key_focus();
|
2012-08-26 10:53:08 -04:00
|
|
|
|
|
|
|
if (Main.sessionMode.currentMode != 'lock-screen')
|
|
|
|
Main.sessionMode.pushMode('lock-screen');
|
2012-02-06 17:28:48 -05:00
|
|
|
},
|
2012-05-21 12:42:45 -04:00
|
|
|
|
2012-12-29 09:24:03 -05:00
|
|
|
_startArrowAnimation: function() {
|
|
|
|
this._arrowActiveWatchId = 0;
|
|
|
|
|
|
|
|
if (!this._arrowAnimationId) {
|
|
|
|
this._arrowAnimationId = Mainloop.timeout_add(6000, Lang.bind(this, this._animateArrows));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(this._arrowAnimationId, '[gnome-shell] this._animateArrows');
|
2012-12-29 09:24:03 -05:00
|
|
|
this._animateArrows();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this._arrowWatchId)
|
|
|
|
this._arrowWatchId = this.idleMonitor.add_idle_watch(ARROW_IDLE_TIME,
|
|
|
|
Lang.bind(this, this._pauseArrowAnimation));
|
|
|
|
},
|
|
|
|
|
|
|
|
_pauseArrowAnimation: function() {
|
|
|
|
if (this._arrowAnimationId) {
|
|
|
|
Mainloop.source_remove(this._arrowAnimationId);
|
|
|
|
this._arrowAnimationId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!this._arrowActiveWatchId)
|
|
|
|
this._arrowActiveWatchId = this.idleMonitor.add_user_active_watch(Lang.bind(this, this._startArrowAnimation));
|
|
|
|
},
|
|
|
|
|
|
|
|
_stopArrowAnimation: function() {
|
|
|
|
if (this._arrowAnimationId) {
|
|
|
|
Mainloop.source_remove(this._arrowAnimationId);
|
|
|
|
this._arrowAnimationId = 0;
|
|
|
|
}
|
|
|
|
if (this._arrowActiveWatchId) {
|
|
|
|
this.idleMonitor.remove_watch(this._arrowActiveWatchId);
|
|
|
|
this._arrowActiveWatchId = 0;
|
|
|
|
}
|
|
|
|
if (this._arrowWatchId) {
|
|
|
|
this.idleMonitor.remove_watch(this._arrowWatchId);
|
|
|
|
this._arrowWatchId = 0;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_checkArrowAnimation: function() {
|
|
|
|
let idleTime = this.idleMonitor.get_idletime();
|
|
|
|
|
|
|
|
if (idleTime < ARROW_IDLE_TIME)
|
|
|
|
this._startArrowAnimation();
|
|
|
|
else
|
|
|
|
this._pauseArrowAnimation();
|
|
|
|
},
|
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
_lockScreenShown: function(params) {
|
2012-09-19 07:11:27 -04:00
|
|
|
if (this._dialog && !this._isGreeter) {
|
2012-09-18 22:34:49 -04:00
|
|
|
this._dialog.destroy();
|
2012-09-19 07:11:27 -04:00
|
|
|
this._dialog = null;
|
|
|
|
}
|
2012-09-18 22:34:49 -04:00
|
|
|
|
2012-12-29 09:24:03 -05:00
|
|
|
this._checkArrowAnimation();
|
2012-08-20 13:56:08 -04:00
|
|
|
|
2013-09-12 07:04:47 -04:00
|
|
|
let motionId = global.stage.connect('captured-event', Lang.bind(this, function(stage, event) {
|
2012-08-31 11:51:32 -04:00
|
|
|
if (event.type() == Clutter.EventType.MOTION) {
|
2013-09-12 07:04:47 -04:00
|
|
|
this._cursorTracker.set_pointer_visible(true);
|
2012-08-31 11:51:32 -04:00
|
|
|
global.stage.disconnect(motionId);
|
|
|
|
}
|
|
|
|
|
2013-11-29 13:17:34 -05:00
|
|
|
return Clutter.EVENT_PROPAGATE;
|
2013-09-12 07:04:47 -04:00
|
|
|
}));
|
|
|
|
this._cursorTracker.set_pointer_visible(false);
|
2012-08-31 11:51:32 -04:00
|
|
|
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenState = MessageTray.State.SHOWN;
|
|
|
|
this._lockScreenGroup.fixed_position_set = false;
|
2012-09-02 08:48:08 -04:00
|
|
|
this._lockScreenScrollCounter = 0;
|
2012-08-26 17:15:59 -04:00
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
if (params.fadeToBlack && params.animateFade) {
|
|
|
|
// Take a beat
|
|
|
|
|
2014-04-10 13:26:52 -04:00
|
|
|
let id = Mainloop.timeout_add(1000 * MANUAL_FADE_TIME, Lang.bind(this, function() {
|
2013-08-17 13:40:09 -04:00
|
|
|
this._activateFade(this._shortLightbox, MANUAL_FADE_TIME);
|
2013-11-28 19:45:39 -05:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2013-08-17 13:40:09 -04:00
|
|
|
}));
|
2014-04-10 13:26:52 -04:00
|
|
|
GLib.Source.set_name_by_id(id, '[gnome-shell] this._activateFade');
|
2013-08-17 13:40:09 -04:00
|
|
|
} else {
|
|
|
|
if (params.fadeToBlack)
|
|
|
|
this._activateFade(this._shortLightbox, 0);
|
|
|
|
|
|
|
|
this._completeLockScreenShown();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_completeLockScreenShown: function() {
|
2013-01-29 09:49:18 -05:00
|
|
|
let prevIsActive = this._isActive;
|
|
|
|
this._isActive = true;
|
|
|
|
|
|
|
|
if (prevIsActive != this._isActive)
|
2013-02-02 11:10:45 -05:00
|
|
|
this.emit('active-changed');
|
2013-01-29 09:49:18 -05:00
|
|
|
|
2013-03-14 11:37:40 -04:00
|
|
|
if (this._aboutToSuspend)
|
|
|
|
this._uninhibitSuspend();
|
2012-10-23 09:48:49 -04:00
|
|
|
|
2012-08-26 17:15:59 -04:00
|
|
|
this.emit('lock-screen-shown');
|
|
|
|
},
|
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
// Some of the actors in the lock screen are heavy in
|
|
|
|
// resources, so we only create them when needed
|
2012-08-26 10:53:08 -04:00
|
|
|
_ensureLockScreen: function() {
|
|
|
|
if (this._hasLockScreen)
|
|
|
|
return;
|
|
|
|
|
2012-05-27 18:50:56 -04: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 17:17:38 -04:00
|
|
|
vertical: true,
|
|
|
|
style_class: 'screen-shield-contents-box' });
|
2012-05-27 18:50:56 -04:00
|
|
|
this._clock = new Clock();
|
|
|
|
this._lockScreenContentsBox.add(this._clock.actor, { x_fill: true,
|
|
|
|
y_fill: true });
|
|
|
|
|
2012-08-14 09:39:17 -04:00
|
|
|
this._lockScreenContents.add_actor(this._lockScreenContentsBox);
|
2012-05-27 18:50:56 -04:00
|
|
|
|
2012-10-16 11:08:54 -04:00
|
|
|
this._notificationsBox = new NotificationsBox();
|
2014-03-10 14:16:03 -04:00
|
|
|
this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', Lang.bind(this, this._wakeUpScreen));
|
2012-10-16 11:08:54 -04:00
|
|
|
this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true,
|
|
|
|
y_fill: true,
|
|
|
|
expand: true });
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
this._hasLockScreen = true;
|
|
|
|
},
|
|
|
|
|
2014-03-10 14:16:03 -04:00
|
|
|
_wakeUpScreen: function() {
|
|
|
|
this._onUserBecameActive();
|
|
|
|
this.emit('wake-up-screen');
|
|
|
|
},
|
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
_clearLockScreen: function() {
|
|
|
|
this._clock.destroy();
|
|
|
|
this._clock = null;
|
|
|
|
|
2012-05-22 18:02:00 -04:00
|
|
|
if (this._notificationsBox) {
|
2014-03-10 14:16:03 -04:00
|
|
|
this._notificationsBox.disconnect(this._wakeUpScreenId);
|
2012-05-22 18:02:00 -04:00
|
|
|
this._notificationsBox.destroy();
|
|
|
|
this._notificationsBox = null;
|
|
|
|
}
|
|
|
|
|
2012-12-29 09:24:03 -05:00
|
|
|
this._stopArrowAnimation();
|
2012-05-27 18:50:56 -04:00
|
|
|
|
2012-12-29 09:24:03 -05:00
|
|
|
this._lockScreenContentsBox.destroy();
|
2012-08-20 13:56:08 -04:00
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
this._hasLockScreen = false;
|
|
|
|
},
|
|
|
|
|
2012-05-21 12:42:45 -04:00
|
|
|
get locked() {
|
2013-01-27 09:45:04 -05:00
|
|
|
return this._isLocked;
|
|
|
|
},
|
|
|
|
|
|
|
|
get active() {
|
2012-08-26 10:53:08 -04:00
|
|
|
return this._isActive;
|
2012-05-21 12:42:45 -04:00
|
|
|
},
|
|
|
|
|
2012-10-16 10:38:32 -04:00
|
|
|
get activationTime() {
|
|
|
|
return this._activationTime;
|
|
|
|
},
|
|
|
|
|
2013-01-27 09:45:04 -05:00
|
|
|
deactivate: function(animate) {
|
2013-08-06 09:22:48 -04:00
|
|
|
if (this._dialog)
|
|
|
|
this._dialog.finish(Lang.bind(this, function() {
|
2013-08-06 09:49:00 -04:00
|
|
|
this._continueDeactivate(animate);
|
2013-08-06 09:22:48 -04:00
|
|
|
}));
|
|
|
|
else
|
2013-08-06 09:49:00 -04:00
|
|
|
this._continueDeactivate(animate);
|
2013-07-18 08:58:58 -04:00
|
|
|
},
|
|
|
|
|
2013-08-06 09:49:00 -04:00
|
|
|
_continueDeactivate: function(animate) {
|
2013-01-27 09:45:04 -05:00
|
|
|
this._hideLockScreen(animate, 0);
|
|
|
|
|
2013-05-12 13:41:21 -04:00
|
|
|
if (this._hasLockScreen)
|
|
|
|
this._clearLockScreen();
|
|
|
|
|
2013-02-01 05:36:21 -05: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 16:09:28 -04: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;
|
|
|
|
this._isActive = false;
|
|
|
|
this.emit('active-changed');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-22 12:06:11 -04:00
|
|
|
if (this._dialog && !this._isGreeter)
|
|
|
|
this._dialog.popModal();
|
|
|
|
|
|
|
|
if (this._isModal) {
|
|
|
|
Main.popModal(this.actor);
|
|
|
|
this._isModal = false;
|
|
|
|
}
|
|
|
|
|
2012-09-01 15:59:53 -04:00
|
|
|
Tweener.addTween(this._lockDialogGroup, {
|
|
|
|
scale_x: 0,
|
|
|
|
scale_y: 0,
|
2013-01-27 09:45:04 -05:00
|
|
|
time: animate ? Overview.ANIMATION_TIME : 0,
|
2012-09-01 15:59:53 -04:00
|
|
|
transition: 'easeOutQuad',
|
2013-01-27 09:45:04 -05:00
|
|
|
onComplete: Lang.bind(this, this._completeDeactivate),
|
2012-09-01 15:59:53 -04:00
|
|
|
onCompleteScope: this
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2013-01-27 09:45:04 -05:00
|
|
|
_completeDeactivate: function() {
|
2013-06-06 16:09:28 -04:00
|
|
|
if (this._dialog) {
|
2012-09-04 13:28:19 -04:00
|
|
|
this._dialog.destroy();
|
|
|
|
this._dialog = null;
|
2012-05-26 11:04:25 -04:00
|
|
|
}
|
|
|
|
|
2013-08-17 13:40:09 -04:00
|
|
|
this._longLightbox.hide();
|
|
|
|
this._shortLightbox.hide();
|
2013-01-27 09:45:04 -05:00
|
|
|
this.actor.hide();
|
2012-08-26 10:53:08 -04:00
|
|
|
|
2013-01-17 17:55:17 -05:00
|
|
|
if (this._becameActiveId != 0) {
|
2013-01-18 00:24:32 -05:00
|
|
|
this.idleMonitor.remove_watch(this._becameActiveId);
|
2013-01-17 17:55:17 -05:00
|
|
|
this._becameActiveId = 0;
|
|
|
|
}
|
|
|
|
|
2013-01-27 09:45:04 -05:00
|
|
|
if (this._lockTimeoutId != 0) {
|
|
|
|
Mainloop.source_remove(this._lockTimeoutId);
|
|
|
|
this._lockTimeoutId = 0;
|
|
|
|
}
|
|
|
|
|
2012-10-16 10:38:32 -04:00
|
|
|
this._activationTime = 0;
|
2012-08-26 10:53:08 -04:00
|
|
|
this._isActive = false;
|
2012-10-28 07:26:21 -04:00
|
|
|
this._isLocked = false;
|
2013-02-02 11:10:45 -05:00
|
|
|
this.emit('active-changed');
|
|
|
|
this.emit('locked-changed');
|
2013-01-17 14:39:54 -05:00
|
|
|
global.set_runtime_state(LOCKED_STATE_STR, null);
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
|
|
|
|
2013-01-27 09:45:04 -05:00
|
|
|
activate: function(animate) {
|
2012-10-16 10:38:32 -04:00
|
|
|
if (this._activationTime == 0)
|
|
|
|
this._activationTime = GLib.get_monotonic_time();
|
|
|
|
|
2012-05-21 12:42:45 -04:00
|
|
|
this.actor.show();
|
2012-08-26 10:53:08 -04: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 11:32:02 -04:00
|
|
|
this._resetLockScreen({ animateLockScreen: animate,
|
2013-08-17 13:40:09 -04:00
|
|
|
fadeToBlack: true });
|
2013-01-17 14:39:54 -05:00
|
|
|
global.set_runtime_state(LOCKED_STATE_STR, GLib.Variant.new('b', true));
|
2012-05-21 12:42:45 -04:00
|
|
|
|
2013-02-02 11:10:45 -05:00
|
|
|
// We used to set isActive and emit active-changed here,
|
2013-01-29 09:49:18 -05: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.
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
2013-01-27 09:45:04 -05:00
|
|
|
|
|
|
|
lock: function(animate) {
|
2012-11-26 14:18:57 -05: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 09:45:04 -05:00
|
|
|
}
|
|
|
|
|
2013-05-16 11:51:31 -04: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 11:22:43 -04: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 09:45:04 -05:00
|
|
|
this.activate(animate);
|
2013-02-02 11:10:45 -05:00
|
|
|
|
|
|
|
this.emit('locked-changed');
|
2013-01-27 09:45:04 -05:00
|
|
|
},
|
2013-01-17 14:39:54 -05:00
|
|
|
|
|
|
|
// If the previous shell crashed, and gnome-session restarted us, then re-lock
|
|
|
|
lockIfWasLocked: function() {
|
|
|
|
let wasLocked = global.get_runtime_state('b', LOCKED_STATE_STR);
|
|
|
|
if (wasLocked === null)
|
|
|
|
return;
|
|
|
|
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
|
|
|
|
this.lock(false);
|
|
|
|
}));
|
|
|
|
}
|
2012-02-06 17:28:48 -05:00
|
|
|
});
|
2012-05-21 12:42:45 -04:00
|
|
|
Signals.addSignalMethods(ScreenShield.prototype);
|