2012-02-06 17:28:48 -05:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
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;
|
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-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
|
|
|
|
|
|
|
const GnomeSession = imports.misc.gnomeSession;
|
2012-08-14 09:39:17 -04:00
|
|
|
const Layout = imports.ui.layout;
|
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;
|
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-10-23 20:26:20 -04:00
|
|
|
const CURTAIN_SLIDE_TIME = 0.3;
|
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-08-03 17:31:02 -04:00
|
|
|
// The distance in px that the lock screen will move to when pressing
|
|
|
|
// a key that has no effect in the lock screen (bumping it)
|
|
|
|
const BUMP_SIZE = 25;
|
|
|
|
const BUMP_TIME = 0.3;
|
|
|
|
|
2012-05-22 18:02:00 -04:00
|
|
|
const SUMMARY_ICON_SIZE = 48;
|
|
|
|
|
2012-06-02 18:10:23 -04:00
|
|
|
// Lightbox fading times
|
|
|
|
// STANDARD_FADE_TIME is used when the session goes idle, while
|
|
|
|
// SHORT_FADE_TIME is used when requesting lock explicitly from the user menu
|
|
|
|
const STANDARD_FADE_TIME = 10;
|
2012-10-23 20:26:20 -04:00
|
|
|
const SHORT_FADE_TIME = 0.3;
|
2012-06-02 18:10:23 -04:00
|
|
|
|
2012-08-03 12:40:11 -04:00
|
|
|
function sample(offx, offy) {
|
|
|
|
return 'texel += texture2D (sampler, tex_coord.st + pixel_step * ' +
|
2012-11-07 13:04:12 -05:00
|
|
|
'vec2 (' + offx + ',' + offy + '));\n'
|
2012-08-03 12:40:11 -04:00
|
|
|
}
|
|
|
|
const GLSL_BLUR_EFFECT_DECLARATIONS = ' \
|
|
|
|
uniform vec2 pixel_step;\n \
|
2012-11-07 13:04:12 -05:00
|
|
|
uniform float desaturation;\n \
|
2012-08-03 12:40:11 -04:00
|
|
|
vec4 apply_blur(in sampler2D sampler, in vec2 tex_coord) {\n \
|
|
|
|
vec4 texel;\n \
|
|
|
|
texel = texture2D (sampler, tex_coord.st);\n'
|
|
|
|
+ sample(-1.0, -1.0)
|
|
|
|
+ sample( 0.0, -1.0)
|
|
|
|
+ sample(+1.0, -1.0)
|
|
|
|
+ sample(-1.0, 0.0)
|
|
|
|
+ sample(+1.0, 0.0)
|
|
|
|
+ sample(-1.0, +1.0)
|
|
|
|
+ sample( 0.0, +1.0)
|
|
|
|
+ sample(+1.0, +1.0) + ' \
|
|
|
|
texel /= 9.0;\n \
|
|
|
|
return texel;\n \
|
|
|
|
}\n \
|
2012-11-07 13:04:12 -05:00
|
|
|
vec3 desaturate (const vec3 color)\n \
|
2012-08-03 12:40:11 -04:00
|
|
|
{\n \
|
|
|
|
const vec3 gray_conv = vec3 (0.299, 0.587, 0.114);\n \
|
|
|
|
vec3 gray = vec3 (dot (gray_conv, color));\n \
|
|
|
|
return vec3 (mix (color.rgb, gray, desaturation));\n \
|
|
|
|
}';
|
|
|
|
const GLSL_BLUR_EFFECT_CODE = ' \
|
|
|
|
cogl_texel = apply_blur(cogl_sampler, cogl_tex_coord.st);\n \
|
2012-11-07 13:04:12 -05:00
|
|
|
cogl_texel.rgb = desaturate(cogl_texel.rgb);\n';
|
2012-08-03 12:40:11 -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
|
|
|
|
|
|
|
this._residentNotificationBox = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'screen-shield-notifications-box' });
|
2012-10-10 17:07:39 -04:00
|
|
|
let scrollView = new St.ScrollView({ x_fill: false, x_align: St.Align.START });
|
2012-05-22 18:02:00 -04:00
|
|
|
this._persistentNotificationBox = new St.BoxLayout({ vertical: true,
|
|
|
|
style_class: 'screen-shield-notifications-box' });
|
2012-08-06 13:02:12 -04:00
|
|
|
scrollView.add_actor(this._persistentNotificationBox);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
|
|
|
this.actor.add(this._residentNotificationBox, { x_fill: true });
|
2012-10-10 17:07:39 -04:00
|
|
|
this.actor.add(scrollView, { x_fill: true, x_align: St.Align.START });
|
2012-05-22 18:02:00 -04:00
|
|
|
|
|
|
|
this._items = [];
|
|
|
|
Main.messageTray.getSummaryItems().forEach(Lang.bind(this, function(item) {
|
2012-08-16 16:38:22 -04:00
|
|
|
this._summaryItemAdded(Main.messageTray, item, 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
|
|
|
|
|
|
|
this._summaryAddedId = Main.messageTray.connect('summary-item-added', Lang.bind(this, this._summaryItemAdded));
|
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function() {
|
|
|
|
if (this._summaryAddedId) {
|
|
|
|
Main.messageTray.disconnect(this._summaryAddedId);
|
|
|
|
this._summaryAddedId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let i = 0; i < this._items.length; i++)
|
|
|
|
this._removeItem(this._items[i]);
|
|
|
|
this._items = [];
|
|
|
|
|
|
|
|
this.actor.destroy();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateVisibility: function() {
|
2012-10-10 17:20:16 -04:00
|
|
|
this._residentNotificationBox.visible = this._residentNotificationBox.get_n_children() > 0;
|
|
|
|
this._persistentNotificationBox.visible = this._persistentNotificationBox.get_children().some(function(a) {
|
|
|
|
return a.visible;
|
|
|
|
});
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2012-10-10 17:20:16 -04:00
|
|
|
this.actor.visible = this._residentNotificationBox.visible || this._persistentNotificationBox.visible;
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_sourceIsResident: function(source) {
|
|
|
|
return source.hasResidentNotification() && !source.isChat;
|
|
|
|
},
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
|
|
_makeNotificationSource: function(source) {
|
|
|
|
let box = new St.BoxLayout({ style_class: 'screen-shield-notification-source' });
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
let label = new St.Label({ text: source.title,
|
|
|
|
style_class: 'screen-shield-notification-label' });
|
|
|
|
textBox.add(label);
|
|
|
|
|
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;
|
2012-05-22 18:02:00 -04:00
|
|
|
return [box, countLabel];
|
|
|
|
},
|
|
|
|
|
2012-08-16 16:38:22 -04:00
|
|
|
_summaryItemAdded: function(tray, item, dontUpdateVisibility) {
|
2012-08-16 16:30:32 -04:00
|
|
|
// Ignore transient sources, or sources explicitly marked not to show
|
|
|
|
// in the lock screen
|
|
|
|
if (item.source.isTransient || !item.source.showInLockScreen)
|
2012-05-22 18:02:00 -04:00
|
|
|
return;
|
|
|
|
|
|
|
|
let obj = {
|
|
|
|
item: item,
|
|
|
|
source: item.source,
|
|
|
|
resident: this._sourceIsResident(item.source),
|
|
|
|
contentUpdatedId: 0,
|
|
|
|
sourceDestroyId: 0,
|
|
|
|
sourceBox: null,
|
|
|
|
countLabel: null,
|
|
|
|
};
|
|
|
|
|
|
|
|
if (obj.resident) {
|
2012-08-25 15:01:57 -04:00
|
|
|
this._residentNotificationBox.add(item.notificationStackWidget);
|
2012-09-18 23:36:05 -04:00
|
|
|
item.closeButton.hide();
|
2012-05-22 18:02:00 -04:00
|
|
|
item.prepareNotificationStackForShowing();
|
|
|
|
} else {
|
|
|
|
[obj.sourceBox, obj.countLabel] = this._makeNotificationSource(item.source);
|
2012-10-10 17:07:39 -04:00
|
|
|
this._persistentNotificationBox.add(obj.sourceBox, { x_fill: false, x_align: St.Align.START });
|
2012-05-22 18:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
obj.contentUpdatedId = item.connect('content-updated', Lang.bind(this, this._onItemContentUpdated));
|
2012-08-06 11:28:55 -04:00
|
|
|
obj.sourceCountChangedId = item.source.connect('count-updated', Lang.bind(this, this._onSourceChanged));
|
2012-08-03 19:16:07 -04:00
|
|
|
obj.sourceTitleChangedId = item.source.connect('title-changed', Lang.bind(this, this._onSourceChanged));
|
2012-05-22 18:02:00 -04:00
|
|
|
obj.sourceDestroyId = item.source.connect('destroy', Lang.bind(this, this._onSourceDestroy));
|
|
|
|
this._items.push(obj);
|
|
|
|
|
2012-08-16 16:38:22 -04:00
|
|
|
if (!dontUpdateVisibility)
|
|
|
|
this._updateVisibility();
|
2012-05-22 18:02:00 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_findSource: function(source) {
|
|
|
|
for (let i = 0; i < this._items.length; i++) {
|
|
|
|
if (this._items[i].source == source)
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onItemContentUpdated: function(item) {
|
|
|
|
let obj = this._items[this._findSource(item.source)];
|
|
|
|
this._updateItem(obj);
|
|
|
|
},
|
|
|
|
|
2012-08-03 19:16:07 -04:00
|
|
|
_onSourceChanged: function(source) {
|
2012-05-22 18:02:00 -04:00
|
|
|
let obj = this._items[this._findSource(source)];
|
|
|
|
this._updateItem(obj);
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateItem: function(obj) {
|
|
|
|
let itemShouldBeResident = this._sourceIsResident(obj.source);
|
|
|
|
|
|
|
|
if (itemShouldBeResident && obj.resident) {
|
|
|
|
// Nothing to do here, the actor is already updated
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (obj.resident && !itemShouldBeResident) {
|
|
|
|
// make into a regular item
|
2012-08-25 15:01:57 -04:00
|
|
|
obj.item.doneShowingNotificationStack();
|
|
|
|
this._residentNotificationBox.remove_actor(obj.item.notificationStackWidget);
|
2012-05-22 18:02:00 -04:00
|
|
|
|
|
|
|
[obj.sourceBox, obj.countLabel] = this._makeNotificationSource(obj.source);
|
2012-10-10 17:07:39 -04:00
|
|
|
this._persistentNotificationBox.add(obj.sourceBox, { x_fill: false, x_align: St.Align.START });
|
2012-05-22 18:02:00 -04:00
|
|
|
} else if (itemShouldBeResident && !obj.resident) {
|
|
|
|
// make into a resident item
|
|
|
|
obj.sourceBox.destroy();
|
|
|
|
obj.sourceBox = obj.countLabel = null;
|
2012-08-03 19:16:07 -04:00
|
|
|
obj.resident = true;
|
2012-05-22 18:02:00 -04:00
|
|
|
|
2012-08-25 15:01:57 -04:00
|
|
|
this._residentNotificationBox.add(obj.item.notificationStackWidget);
|
2012-09-18 23:36:05 -04:00
|
|
|
obj.item.closeButton.hide();
|
2012-05-22 18:02:00 -04:00
|
|
|
obj.item.prepareNotificationStackForShowing();
|
|
|
|
} else {
|
|
|
|
// just update the counter
|
2012-08-06 11:28:55 -04:00
|
|
|
let count = obj.source.unseenCount;
|
|
|
|
obj.countLabel.text = this._makeNotificationCountText(count, obj.source.isChat);
|
|
|
|
obj.sourceBox.visible = count != 0;
|
2012-05-22 18:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onSourceDestroy: function(source) {
|
|
|
|
let idx = this._findSource(source);
|
|
|
|
|
|
|
|
this._removeItem(this._items[idx]);
|
|
|
|
this._items.splice(idx, 1);
|
|
|
|
|
|
|
|
this._updateVisibility();
|
|
|
|
},
|
|
|
|
|
|
|
|
_removeItem: function(obj) {
|
|
|
|
if (obj.resident) {
|
|
|
|
obj.item.doneShowingNotificationStack();
|
2012-08-25 15:01:57 -04:00
|
|
|
this._residentNotificationBox.remove_actor(obj.item.notificationStackWidget);
|
2012-05-22 18:02:00 -04:00
|
|
|
} else {
|
|
|
|
obj.sourceBox.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
obj.item.disconnect(obj.contentUpdatedId);
|
|
|
|
obj.source.disconnect(obj.sourceDestroyId);
|
|
|
|
obj.source.disconnect(obj.sourceCountChangedId);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
},
|
|
|
|
|
|
|
|
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',
|
2012-05-24 16:47:48 -04:00
|
|
|
});
|
|
|
|
this._lockScreenGroup.connect('key-release-event',
|
|
|
|
Lang.bind(this, this._onLockScreenKeyRelease));
|
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 }));
|
|
|
|
|
2012-08-03 12:40:11 -04:00
|
|
|
let backgroundActor = Meta.BackgroundActor.new_for_screen(global.screen);
|
|
|
|
backgroundActor.add_glsl_snippet(Meta.SnippetHook.TEXTURE_LOOKUP,
|
|
|
|
GLSL_BLUR_EFFECT_DECLARATIONS,
|
|
|
|
GLSL_BLUR_EFFECT_CODE,
|
|
|
|
true);
|
2012-11-07 13:04:12 -05:00
|
|
|
backgroundActor.set_uniform_float('desaturation',
|
|
|
|
1, 1, [0.6]);
|
|
|
|
backgroundActor.connect('notify::size', function(actor) {
|
|
|
|
actor.set_uniform_float('pixel_step', 2, 1, [1/actor.width, 1/actor.height]);
|
|
|
|
});
|
|
|
|
|
2012-09-13 12:45:55 -04:00
|
|
|
this._background = new St.Bin({ style_class: 'screen-shield-background',
|
2012-11-06 17:44:11 -05:00
|
|
|
child: backgroundActor });
|
2012-05-24 16:47:48 -04:00
|
|
|
this._lockScreenGroup.add_actor(this._background);
|
2012-08-14 09:39:17 -04:00
|
|
|
this._lockScreenGroup.add_actor(this._lockScreenContents);
|
2012-05-24 16:47:48 -04:00
|
|
|
|
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,
|
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);
|
|
|
|
|
2012-08-18 08:05:52 -04:00
|
|
|
this._loginManager = LoginManager.getLoginManager();
|
|
|
|
this._loginSession = this._loginManager.getCurrentSessionProxy();
|
|
|
|
this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
|
|
|
|
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.unlock(); }));
|
2012-08-17 08:24:17 -04:00
|
|
|
|
2012-02-06 17:28:48 -05:00
|
|
|
this._settings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });
|
|
|
|
|
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;
|
2012-09-21 18:06:26 -04:00
|
|
|
this._inUnlockAnimation = false;
|
2012-10-16 10:38:32 -04:00
|
|
|
this._activationTime = 0;
|
2012-05-22 17:22:38 -04:00
|
|
|
|
|
|
|
this._lightbox = new Lightbox.Lightbox(Main.uiGroup,
|
2012-06-02 18:10:23 -04:00
|
|
|
{ inhibitEvents: true,
|
|
|
|
fadeInTime: STANDARD_FADE_TIME,
|
|
|
|
fadeFactor: 1 });
|
2012-10-28 07:26:21 -04:00
|
|
|
|
|
|
|
this.idleMonitor = new GnomeDesktop.IdleMonitor();
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
2012-05-22 17:22:38 -04:00
|
|
|
|
2012-05-24 16:47:48 -04:00
|
|
|
_onLockScreenKeyRelease: function(actor, event) {
|
2012-09-12 15:52:59 -04:00
|
|
|
let symbol = event.get_key_symbol();
|
|
|
|
|
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.
|
|
|
|
// Similarly, don't bump if the lock screen is not showing or is
|
|
|
|
// animating, as the bump overrides the animation and would
|
|
|
|
// remove any onComplete handler.
|
|
|
|
|
|
|
|
if (this._lockScreenState != MessageTray.State.SHOWN)
|
|
|
|
return false;
|
|
|
|
|
2012-09-12 15:52:59 -04:00
|
|
|
if (symbol == Clutter.KEY_Escape ||
|
|
|
|
symbol == Clutter.KEY_Return ||
|
|
|
|
symbol == Clutter.KEY_KP_Enter) {
|
2012-10-24 11:53:19 -04:00
|
|
|
this._ensureUnlockDialog(true, true);
|
2012-08-31 10:36:40 -04:00
|
|
|
this._hideLockScreen(true, 0);
|
2012-05-24 16:47:48 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-10-03 17:13:25 -04:00
|
|
|
this._bumpLockScreen();
|
2012-08-03 17:31:02 -04:00
|
|
|
return true;
|
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)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
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) {
|
2012-10-24 11:53:19 -04:00
|
|
|
this._ensureUnlockDialog(false, true);
|
2012-08-31 10:36:40 -04:00
|
|
|
this._hideLockScreen(true, 0);
|
2012-09-02 08:48:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
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;
|
2012-10-24 11:53:19 -04:00
|
|
|
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) {
|
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);
|
|
|
|
this._hideLockScreen(true, -velocityY);
|
2012-10-24 11:53:19 -04:00
|
|
|
this._ensureUnlockDialog(false, true);
|
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;
|
|
|
|
let time = CURTAIN_SLIDE_TIME * (-this._lockScreenGroup.y) / h;
|
|
|
|
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
|
|
|
|
|
|
|
// If we have a unlock dialog, cancel it
|
|
|
|
if (this._dialog) {
|
|
|
|
this._dialog.cancel();
|
2012-08-26 10:53:08 -04:00
|
|
|
if (!this._isGreeter) {
|
2012-08-07 12:07:07 -04:00
|
|
|
this._dialog = null;
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
2012-10-28 07:26:21 -04:00
|
|
|
if (this._dialog) {
|
|
|
|
this._dialog.cancel();
|
|
|
|
if (!this._isGreeter) {
|
|
|
|
this._dialog = null;
|
2012-05-21 12:42:45 -04:00
|
|
|
}
|
2012-10-28 07:26:21 -04:00
|
|
|
}
|
2012-05-21 12:42:45 -04:00
|
|
|
|
2012-10-28 07:26:21 -04:00
|
|
|
if (!this._isModal) {
|
2012-08-10 14:35:59 -04:00
|
|
|
Main.pushModal(this.actor, { keybindingMode: Main.KeybindingMode.LOCK_SCREEN });
|
2012-10-28 07:26:21 -04:00
|
|
|
this._isModal = true;
|
|
|
|
}
|
2012-10-16 10:38:32 -04:00
|
|
|
|
2012-10-28 07:26:21 -04:00
|
|
|
if (!this._isActive) {
|
|
|
|
this._lightbox.show();
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2012-10-28 07:26:21 -04:00
|
|
|
if (this._activationTime == 0)
|
|
|
|
this._activationTime = GLib.get_monotonic_time();
|
|
|
|
|
|
|
|
this._becameActiveId = this.idleMonitor.connect('became-active', Lang.bind(this, function() {
|
|
|
|
this.idleMonitor.disconnect(this._becameActiveId);
|
|
|
|
|
|
|
|
let lightboxWasShown = this._lightbox.shown;
|
|
|
|
this._lightbox.hide();
|
|
|
|
|
|
|
|
let shouldLock = lightboxWasShown && this._settings.get_boolean(LOCK_ENABLED_KEY);
|
|
|
|
if (shouldLock || this._isLocked) {
|
|
|
|
this.lock(false);
|
|
|
|
} else if (this._isActive) {
|
|
|
|
this.unlock();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._isActive = true;
|
|
|
|
this.emit('lock-status-changed');
|
2012-02-06 17:28:48 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
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-09-04 14:47:20 -04:00
|
|
|
if (!this._isModal) {
|
|
|
|
Main.pushModal(this.actor);
|
|
|
|
this._isModal = true;
|
|
|
|
}
|
|
|
|
|
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;
|
2012-10-24 11:53:19 -04:00
|
|
|
this._ensureUnlockDialog(true, true);
|
2012-08-31 10:36:40 -04:00
|
|
|
this._hideLockScreen(false, 0);
|
2012-05-26 11:04:25 -04:00
|
|
|
},
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2012-08-03 17:31:02 -04:00
|
|
|
_bumpLockScreen: function() {
|
|
|
|
Tweener.removeTweens(this._lockScreenGroup);
|
|
|
|
Tweener.addTween(this._lockScreenGroup,
|
|
|
|
{ y: -BUMP_SIZE,
|
|
|
|
time: BUMP_TIME / 2,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: function() {
|
|
|
|
Tweener.addTween(this,
|
|
|
|
{ y: 0,
|
|
|
|
time: BUMP_TIME / 2,
|
|
|
|
transition: 'easeInQuad' });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-08-31 10:36:40 -04:00
|
|
|
_hideLockScreen: function(animate, velocity) {
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenState = MessageTray.State.HIDING;
|
|
|
|
|
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.removeTweens(this._lockScreenGroup);
|
|
|
|
Tweener.addTween(this._lockScreenGroup,
|
|
|
|
{ y: -h,
|
|
|
|
time: time,
|
2012-10-23 20:26:20 -04:00
|
|
|
transition: 'easeInQuad',
|
2012-08-26 17:15:59 -04:00
|
|
|
onComplete: function() {
|
2012-08-26 10:53:08 -04:00
|
|
|
this._lockScreenState = MessageTray.State.HIDDEN;
|
|
|
|
this._lockScreenGroup.hide();
|
2012-08-26 17:15:59 -04:00
|
|
|
},
|
|
|
|
onCompleteScope: this,
|
2012-05-26 11:04:25 -04:00
|
|
|
});
|
|
|
|
} else {
|
2012-08-26 10:53:08 -04:00
|
|
|
this._lockScreenState = MessageTray.State.HIDDEN;
|
|
|
|
this._lockScreenGroup.hide();
|
2012-05-26 11:04:25 -04:00
|
|
|
}
|
|
|
|
|
2012-08-31 11:51:32 -04:00
|
|
|
global.stage.show_cursor();
|
|
|
|
|
2012-08-26 10:53:08 -04:00
|
|
|
if (Main.sessionMode.currentMode == 'lock-screen')
|
|
|
|
Main.sessionMode.popMode('lock-screen');
|
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
|
|
|
|
this.unlock();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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();
|
2012-05-26 11:04:25 -04:00
|
|
|
this._dialog.connect('loaded', Lang.bind(this, function() {
|
2012-10-14 12:34:22 -04:00
|
|
|
if (!this._dialog.open(time, onPrimary)) {
|
2012-05-26 11:04:25 -04:00
|
|
|
log('Could not open login dialog: failed to acquire grab');
|
|
|
|
this.unlock();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed));
|
|
|
|
this._dialog.connect('unlocked', Lang.bind(this, this._onUnlockSucceded));
|
|
|
|
}
|
2012-10-24 11:53:19 -04:00
|
|
|
|
|
|
|
this._dialog.allowCancel = allowCancel;
|
2012-02-06 17:28:48 -05:00
|
|
|
},
|
|
|
|
|
2012-05-20 12:30:14 -04:00
|
|
|
_onUnlockFailed: function() {
|
2012-08-13 19:43:59 -04:00
|
|
|
this._resetLockScreen(true, false);
|
2012-05-20 12:30:14 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
_onUnlockSucceded: function() {
|
2012-09-01 15:59:53 -04:00
|
|
|
this._tweenUnlocked();
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
2012-05-20 12:30:14 -04:00
|
|
|
|
2012-08-13 19:43:59 -04:00
|
|
|
_resetLockScreen: function(animateLockScreen, animateLockDialog) {
|
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
|
|
|
|
2012-08-13 19:43:59 -04:00
|
|
|
if (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,
|
2012-06-02 18:10:23 -04:00
|
|
|
time: SHORT_FADE_TIME,
|
2012-10-23 20:26:20 -04:00
|
|
|
transition: 'easeOutQuad',
|
2012-06-02 18:10:23 -04:00
|
|
|
onComplete: function() {
|
2012-08-26 17:15:59 -04:00
|
|
|
this._lockScreenShown();
|
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;
|
|
|
|
this._lockScreenShown();
|
|
|
|
}
|
2012-08-03 13:42:43 -04:00
|
|
|
|
2012-08-13 19:43:59 -04:00
|
|
|
if (animateLockDialog) {
|
2012-08-03 13:42:43 -04:00
|
|
|
this._lockDialogGroup.opacity = 0;
|
|
|
|
Tweener.removeTweens(this._lockDialogGroup);
|
|
|
|
Tweener.addTween(this._lockDialogGroup,
|
|
|
|
{ opacity: 255,
|
|
|
|
time: SHORT_FADE_TIME,
|
|
|
|
transition: 'easeOutQuad' });
|
2012-06-02 18:10:23 -04:00
|
|
|
} else {
|
2012-08-03 13:42:43 -04:00
|
|
|
this._lockDialogGroup.opacity = 255;
|
2012-06-02 18:10:23 -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-08-26 17:15:59 -04:00
|
|
|
_lockScreenShown: function() {
|
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-08-20 13:56:08 -04:00
|
|
|
if (this._arrowAnimationId)
|
|
|
|
Mainloop.source_remove(this._arrowAnimationId);
|
|
|
|
this._arrowAnimationId = Mainloop.timeout_add(6000, Lang.bind(this, this._animateArrows));
|
|
|
|
this._animateArrows();
|
|
|
|
|
2012-08-31 11:51:32 -04:00
|
|
|
let motionId = global.stage.connect('captured-event', function(stage, event) {
|
|
|
|
if (event.type() == Clutter.EventType.MOTION) {
|
|
|
|
global.stage.show_cursor();
|
|
|
|
global.stage.disconnect(motionId);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
global.stage.hide_cursor();
|
|
|
|
|
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
|
|
|
|
|
|
|
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-05-22 18:02:00 -04:00
|
|
|
if (this._settings.get_boolean('show-notifications')) {
|
|
|
|
this._notificationsBox = new NotificationsBox();
|
|
|
|
this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true,
|
|
|
|
y_fill: true,
|
|
|
|
expand: true });
|
|
|
|
}
|
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
this._hasLockScreen = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
_clearLockScreen: function() {
|
|
|
|
this._clock.destroy();
|
|
|
|
this._clock = null;
|
|
|
|
|
2012-05-22 18:02:00 -04:00
|
|
|
if (this._notificationsBox) {
|
|
|
|
this._notificationsBox.destroy();
|
|
|
|
this._notificationsBox = null;
|
|
|
|
}
|
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
this._lockScreenContentsBox.destroy();
|
|
|
|
|
2012-08-20 13:56:08 -04:00
|
|
|
if (this._arrowAnimationId) {
|
|
|
|
Mainloop.source_remove(this._arrowAnimationId);
|
|
|
|
this._arrowAnimationId = 0;
|
|
|
|
}
|
|
|
|
|
2012-05-27 18:50:56 -04:00
|
|
|
this._hasLockScreen = false;
|
|
|
|
},
|
|
|
|
|
2012-05-21 12:42:45 -04:00
|
|
|
get locked() {
|
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;
|
|
|
|
},
|
|
|
|
|
2012-09-01 15:59:53 -04:00
|
|
|
_tweenUnlocked: function() {
|
2012-09-21 18:06:26 -04:00
|
|
|
this._inUnlockAnimation = true;
|
2012-09-01 15:59:53 -04:00
|
|
|
this.unlock();
|
|
|
|
Tweener.addTween(this._lockDialogGroup, {
|
|
|
|
scale_x: 0,
|
|
|
|
scale_y: 0,
|
|
|
|
time: Overview.ANIMATION_TIME,
|
|
|
|
transition: 'easeOutQuad',
|
|
|
|
onComplete: function() {
|
|
|
|
if (this._dialog) {
|
|
|
|
this._dialog.destroy();
|
|
|
|
this._dialog = null;
|
|
|
|
}
|
|
|
|
this.actor.hide();
|
2012-09-21 18:06:26 -04:00
|
|
|
this._inUnlockAnimation = false;
|
2012-09-01 15:59:53 -04:00
|
|
|
},
|
|
|
|
onCompleteScope: this
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2012-05-24 16:47:48 -04:00
|
|
|
unlock: function() {
|
2012-05-27 18:50:56 -04:00
|
|
|
if (this._hasLockScreen)
|
|
|
|
this._clearLockScreen();
|
|
|
|
|
2012-08-26 10:53:08 -04:00
|
|
|
if (this._dialog && !this._isGreeter) {
|
2012-09-04 13:28:19 -04:00
|
|
|
this._dialog.destroy();
|
|
|
|
this._dialog = null;
|
2012-05-26 11:04:25 -04:00
|
|
|
}
|
|
|
|
|
2012-05-24 16:47:48 -04:00
|
|
|
this._lightbox.hide();
|
|
|
|
|
2012-08-17 13:08:17 -04:00
|
|
|
if (this._isModal) {
|
|
|
|
Main.popModal(this.actor);
|
|
|
|
this._isModal = false;
|
|
|
|
}
|
2012-05-24 16:47:48 -04:00
|
|
|
|
2012-09-21 18:06:26 -04:00
|
|
|
if (!this._inUnlockAnimation)
|
|
|
|
this.actor.hide();
|
2012-08-26 10:53:08 -04:00
|
|
|
|
|
|
|
if (Main.sessionMode.currentMode == 'lock-screen')
|
|
|
|
Main.sessionMode.popMode('lock-screen');
|
|
|
|
if (Main.sessionMode.currentMode == 'unlock-dialog')
|
|
|
|
Main.sessionMode.popMode('unlock-dialog');
|
2012-05-24 16:47:48 -04:00
|
|
|
|
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;
|
2012-08-26 10:53:08 -04:00
|
|
|
this.emit('lock-status-changed');
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
|
|
|
|
2012-06-02 18:10:23 -04:00
|
|
|
lock: function(animate) {
|
2012-05-21 12:42:45 -04:00
|
|
|
if (!this._isModal) {
|
2012-08-10 14:35:59 -04:00
|
|
|
Main.pushModal(this.actor, { keybindingMode: Main.KeybindingMode.LOCK_SCREEN });
|
2012-05-21 12:42:45 -04:00
|
|
|
this._isModal = true;
|
|
|
|
}
|
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
|
2012-08-13 19:43:59 -04:00
|
|
|
this._resetLockScreen(animate, animate);
|
2012-05-21 12:42:45 -04:00
|
|
|
|
2012-08-26 10:53:08 -04:00
|
|
|
this._isActive = true;
|
2012-10-28 07:26:21 -04:00
|
|
|
this._isLocked = true;
|
2012-08-26 10:53:08 -04:00
|
|
|
this.emit('lock-status-changed');
|
2012-05-24 16:47:48 -04:00
|
|
|
},
|
2012-02-06 17:28:48 -05:00
|
|
|
});
|
2012-05-21 12:42:45 -04:00
|
|
|
Signals.addSignalMethods(ScreenShield.prototype);
|
2012-07-08 11:42:15 -04:00
|
|
|
|
|
|
|
/* Fallback code to handle session locking using gnome-screensaver,
|
|
|
|
in case the required GDM dependency is not there
|
|
|
|
*/
|
|
|
|
const ScreenShieldFallback = new Lang.Class({
|
|
|
|
Name: 'ScreenShieldFallback',
|
|
|
|
|
|
|
|
_init: function() {
|
2012-10-18 19:44:28 -04:00
|
|
|
Util.spawn(['gnome-screensaver']);
|
|
|
|
|
2012-07-08 11:42:15 -04:00
|
|
|
this._proxy = new Gio.DBusProxy({ g_connection: Gio.DBus.session,
|
|
|
|
g_name: 'org.gnome.ScreenSaver',
|
|
|
|
g_object_path: '/org/gnome/ScreenSaver',
|
|
|
|
g_interface_name: 'org.gnome.ScreenSaver',
|
|
|
|
g_flags: (Gio.DBusProxyFlags.DO_NOT_AUTO_START |
|
|
|
|
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES),
|
|
|
|
});
|
|
|
|
this._proxy.init(null);
|
|
|
|
|
|
|
|
this._proxy.connect('g-signal', Lang.bind(this, this._onSignal));
|
|
|
|
this._proxy.connect('notify::g-name-owner', Lang.bind(this, this._onNameOwnerChanged));
|
|
|
|
},
|
|
|
|
|
|
|
|
_onNameOwnerChanged: function(object, pspec) {
|
|
|
|
if (this._proxy.g_name_owner)
|
|
|
|
[this._locked] = this._proxy.call_sync('GetActive', null,
|
|
|
|
Gio.DBusCallFlags.NONE, -1, null).deep_unpack();
|
|
|
|
else
|
|
|
|
this._locked = false;
|
|
|
|
|
|
|
|
this.emit('lock-status-changed', this._locked);
|
|
|
|
},
|
|
|
|
|
|
|
|
_onSignal: function(proxy, senderName, signalName, params) {
|
|
|
|
if (signalName == 'ActiveChanged') {
|
|
|
|
[this._locked] = params.deep_unpack();
|
|
|
|
this.emit('lock-status-changed', this._locked);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
get locked() {
|
|
|
|
return this._locked;
|
|
|
|
},
|
|
|
|
|
|
|
|
lock: function() {
|
|
|
|
this._proxy.call('Lock', null, Gio.DBusCallFlags.NONE, -1, null,
|
|
|
|
Lang.bind(this, function(proxy, result) {
|
|
|
|
proxy.call_finish(result);
|
|
|
|
|
|
|
|
this.emit('lock-screen-shown');
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
|
|
|
unlock: function() {
|
|
|
|
this._proxy.call('SetActive', GLib.Variant.new('(b)', false),
|
|
|
|
Gio.DBusCallFlags.NONE, -1, null, null);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
Signals.addSignalMethods(ScreenShieldFallback.prototype);
|