2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2019-01-31 09:07:06 -05:00
|
|
|
/* exported GnomeShell, ScreenSaverDBus */
|
2009-09-23 14:30:05 -04:00
|
|
|
|
2019-02-08 22:21:36 -05:00
|
|
|
const { Gio, GLib, Meta, Shell } = imports.gi;
|
2009-09-23 14:30:05 -04:00
|
|
|
|
2011-06-29 20:09:00 -04:00
|
|
|
const Config = imports.misc.config;
|
2012-05-25 19:07:31 -04:00
|
|
|
const ExtensionDownloader = imports.ui.extensionDownloader;
|
2012-01-30 20:58:29 -05:00
|
|
|
const ExtensionUtils = imports.misc.extensionUtils;
|
2009-09-23 14:30:05 -04:00
|
|
|
const Main = imports.ui.main;
|
2012-12-10 10:26:31 -05:00
|
|
|
const Screenshot = imports.ui.screenshot;
|
2009-09-23 14:30:05 -04:00
|
|
|
|
2018-09-05 20:55:20 -04:00
|
|
|
const { loadInterfaceXML } = imports.misc.fileUtils;
|
|
|
|
|
|
|
|
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell');
|
|
|
|
const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
|
2012-06-02 19:20:31 -04:00
|
|
|
|
2017-10-30 21:19:44 -04:00
|
|
|
var GnomeShell = class {
|
|
|
|
constructor() {
|
2011-08-16 08:19:59 -04:00
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
2012-06-27 11:47:51 -04:00
|
|
|
|
2013-02-25 08:27:31 -05:00
|
|
|
this._extensionsService = new GnomeShellExtensions();
|
2012-12-10 10:26:31 -05:00
|
|
|
this._screenshotService = new Screenshot.ScreenshotService();
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2014-01-14 17:49:47 -05:00
|
|
|
this._grabbedAccelerators = new Map();
|
|
|
|
this._grabbers = new Map();
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2017-10-30 20:38:18 -04:00
|
|
|
global.display.connect('accelerator-activated',
|
2019-07-08 05:44:12 -04:00
|
|
|
(display, action, device, timestamp) => {
|
|
|
|
this._emitAcceleratorActivated(action, device, timestamp);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2013-07-13 14:58:36 -04:00
|
|
|
|
|
|
|
this._cachedOverviewVisible = false;
|
|
|
|
Main.overview.connect('showing',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._checkOverviewVisibleChanged.bind(this));
|
2013-07-13 14:58:36 -04:00
|
|
|
Main.overview.connect('hidden',
|
2017-12-01 19:27:35 -05:00
|
|
|
this._checkOverviewVisibleChanged.bind(this));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2009-09-23 14:30:05 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Eval:
|
|
|
|
* @code: A string containing JavaScript code
|
|
|
|
*
|
|
|
|
* This function executes arbitrary code in the main
|
|
|
|
* loop, and returns a boolean success and
|
|
|
|
* JSON representation of the object as a string.
|
|
|
|
*
|
|
|
|
* If evaluation completes without throwing an exception,
|
|
|
|
* then the return value will be [true, JSON.stringify(result)].
|
|
|
|
* If evaluation fails, then the return value will be
|
|
|
|
* [false, JSON.stringify(exception)];
|
|
|
|
*
|
|
|
|
*/
|
2017-10-30 20:03:21 -04:00
|
|
|
Eval(code) {
|
2011-10-27 17:41:06 -04:00
|
|
|
if (!global.settings.get_boolean('development-tools'))
|
2013-04-26 09:17:11 -04:00
|
|
|
return [false, ''];
|
2011-10-27 17:41:06 -04:00
|
|
|
|
2009-09-23 14:30:05 -04:00
|
|
|
let returnValue;
|
|
|
|
let success;
|
|
|
|
try {
|
|
|
|
returnValue = JSON.stringify(eval(code));
|
2009-11-12 18:17:58 -05:00
|
|
|
// A hack; DBus doesn't have null/undefined
|
|
|
|
if (returnValue == undefined)
|
2010-05-13 15:46:04 -04:00
|
|
|
returnValue = '';
|
2009-09-23 14:30:05 -04:00
|
|
|
success = true;
|
|
|
|
} catch (e) {
|
2019-01-29 18:01:21 -05:00
|
|
|
returnValue = `${e}`;
|
2009-09-23 14:30:05 -04:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
return [success, returnValue];
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2009-09-23 14:30:05 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
FocusSearch() {
|
2013-05-17 11:31:27 -04:00
|
|
|
Main.overview.focusSearch();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-05-17 11:31:27 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
ShowOSD(params) {
|
2013-03-02 10:22:49 -05:00
|
|
|
for (let param in params)
|
|
|
|
params[param] = params[param].deep_unpack();
|
|
|
|
|
2019-04-11 05:43:03 -04:00
|
|
|
let { connector,
|
2018-08-01 07:27:07 -04:00
|
|
|
label,
|
|
|
|
level,
|
|
|
|
max_level: maxLevel,
|
|
|
|
icon: serializedIcon } = params;
|
|
|
|
|
2019-04-11 05:43:03 -04:00
|
|
|
let monitorIndex = -1;
|
|
|
|
if (connector) {
|
|
|
|
let monitorManager = Meta.MonitorManager.get();
|
|
|
|
monitorIndex = monitorManager.get_monitor_for_connector(connector);
|
|
|
|
}
|
2013-11-18 07:48:19 -05:00
|
|
|
|
2013-03-02 10:22:49 -05:00
|
|
|
let icon = null;
|
2018-08-01 07:27:07 -04:00
|
|
|
if (serializedIcon)
|
|
|
|
icon = Gio.Icon.new_for_string(serializedIcon);
|
2013-03-02 10:22:49 -05:00
|
|
|
|
2018-07-31 10:47:05 -04:00
|
|
|
Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2013-03-02 10:22:49 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
FocusApp(id) {
|
2013-04-24 13:32:41 -04:00
|
|
|
this.ShowApplications();
|
|
|
|
Main.overview.viewSelector.appDisplay.selectApp(id);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-07-09 09:30:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
ShowApplications() {
|
2013-04-24 13:32:41 -04:00
|
|
|
Main.overview.viewSelector.showApps();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-07-09 09:30:42 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
GrabAcceleratorAsync(params, invocation) {
|
2018-07-18 14:26:44 -04:00
|
|
|
let [accel, modeFlags, grabFlags] = params;
|
2012-08-11 17:11:37 -04:00
|
|
|
let sender = invocation.get_sender();
|
2018-07-18 14:26:44 -04:00
|
|
|
let bindingAction = this._grabAcceleratorForSender(accel, modeFlags, grabFlags, sender);
|
2012-08-11 17:11:37 -04:00
|
|
|
return invocation.return_value(GLib.Variant.new('(u)', [bindingAction]));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
GrabAcceleratorsAsync(params, invocation) {
|
2012-08-11 17:11:37 -04:00
|
|
|
let [accels] = params;
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let bindingActions = [];
|
|
|
|
for (let i = 0; i < accels.length; i++) {
|
2018-07-18 14:26:44 -04:00
|
|
|
let [accel, modeFlags, grabFlags] = accels[i];
|
|
|
|
bindingActions.push(this._grabAcceleratorForSender(accel, modeFlags, grabFlags, sender));
|
2012-08-11 17:11:37 -04:00
|
|
|
}
|
|
|
|
return invocation.return_value(GLib.Variant.new('(au)', [bindingActions]));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
UngrabAcceleratorAsync(params, invocation) {
|
2012-08-11 17:11:37 -04:00
|
|
|
let [action] = params;
|
2019-03-02 10:49:55 -05:00
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let ungrabSucceeded = this._ungrabAcceleratorForSender(action, sender);
|
|
|
|
|
|
|
|
return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
|
|
|
|
}
|
|
|
|
|
|
|
|
UngrabAcceleratorsAsync(params, invocation) {
|
|
|
|
let [actions] = params;
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let ungrabSucceeded = true;
|
|
|
|
|
|
|
|
for (let i = 0; i < actions.length; i++)
|
|
|
|
ungrabSucceeded &= this._ungrabAcceleratorForSender(actions[i], sender);
|
2012-08-11 17:11:37 -04:00
|
|
|
|
|
|
|
return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2019-07-08 05:44:12 -04:00
|
|
|
_emitAcceleratorActivated(action, device, timestamp) {
|
2012-08-11 17:11:37 -04:00
|
|
|
let destination = this._grabbedAccelerators.get(action);
|
|
|
|
if (!destination)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let connection = this._dbusImpl.get_connection();
|
|
|
|
let info = this._dbusImpl.get_info();
|
2019-07-08 05:44:12 -04:00
|
|
|
let params = { 'device-id': GLib.Variant.new('u', device.get_device_id()),
|
2014-11-12 14:49:24 -05:00
|
|
|
'timestamp': GLib.Variant.new('u', timestamp),
|
|
|
|
'action-mode': GLib.Variant.new('u', Main.actionMode) };
|
2019-09-20 15:08:45 -04:00
|
|
|
|
|
|
|
let deviceNode = device.get_device_node();
|
|
|
|
if (deviceNode)
|
|
|
|
params['device-node'] = GLib.Variant.new('s', deviceNode);
|
|
|
|
|
2012-08-11 17:11:37 -04:00
|
|
|
connection.emit_signal(destination,
|
|
|
|
this._dbusImpl.get_object_path(),
|
|
|
|
info ? info.name : null,
|
|
|
|
'AcceleratorActivated',
|
2014-11-12 15:21:44 -05:00
|
|
|
GLib.Variant.new('(ua{sv})', [action, params]));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2018-07-18 14:26:44 -04:00
|
|
|
_grabAcceleratorForSender(accelerator, modeFlags, grabFlags, sender) {
|
|
|
|
let bindingAction = global.display.grab_accelerator(accelerator, grabFlags);
|
2012-08-11 17:11:37 -04:00
|
|
|
if (bindingAction == Meta.KeyBindingAction.NONE)
|
|
|
|
return Meta.KeyBindingAction.NONE;
|
|
|
|
|
|
|
|
let bindingName = Meta.external_binding_name_for_action(bindingAction);
|
2018-07-18 14:26:44 -04:00
|
|
|
Main.wm.allowKeybinding(bindingName, modeFlags);
|
2012-08-11 17:11:37 -04:00
|
|
|
|
|
|
|
this._grabbedAccelerators.set(bindingAction, sender);
|
|
|
|
|
|
|
|
if (!this._grabbers.has(sender)) {
|
|
|
|
let id = Gio.bus_watch_name(Gio.BusType.SESSION, sender, 0, null,
|
2017-12-01 19:27:35 -05:00
|
|
|
this._onGrabberBusNameVanished.bind(this));
|
2012-08-11 17:11:37 -04:00
|
|
|
this._grabbers.set(sender, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bindingAction;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_ungrabAccelerator(action) {
|
2012-08-11 17:11:37 -04:00
|
|
|
let ungrabSucceeded = global.display.ungrab_accelerator(action);
|
|
|
|
if (ungrabSucceeded)
|
|
|
|
this._grabbedAccelerators.delete(action);
|
2019-03-02 10:49:55 -05:00
|
|
|
|
|
|
|
return ungrabSucceeded;
|
|
|
|
}
|
|
|
|
|
|
|
|
_ungrabAcceleratorForSender(action, sender) {
|
|
|
|
let grabbedBy = this._grabbedAccelerators.get(action);
|
|
|
|
if (sender != grabbedBy)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return this._ungrabAccelerator(action);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_onGrabberBusNameVanished(connection, name) {
|
2014-01-14 17:49:47 -05:00
|
|
|
let grabs = this._grabbedAccelerators.entries();
|
|
|
|
for (let [action, sender] of grabs) {
|
2012-08-11 17:11:37 -04:00
|
|
|
if (sender == name)
|
|
|
|
this._ungrabAccelerator(action);
|
|
|
|
}
|
|
|
|
Gio.bus_unwatch_name(this._grabbers.get(name));
|
|
|
|
this._grabbers.delete(name);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-08-11 17:11:37 -04:00
|
|
|
|
2019-04-11 13:43:35 -04:00
|
|
|
ShowMonitorLabelsAsync(params, invocation) {
|
2017-04-06 01:18:39 -04:00
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let [dict] = params;
|
2019-04-11 13:37:15 -04:00
|
|
|
Main.osdMonitorLabeler.show(sender, dict);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2017-04-06 01:18:39 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
HideMonitorLabelsAsync(params, invocation) {
|
2015-01-26 09:52:10 -05:00
|
|
|
let sender = invocation.get_sender();
|
|
|
|
Main.osdMonitorLabeler.hide(sender);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-11-29 13:17:51 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_checkOverviewVisibleChanged() {
|
2013-07-13 14:58:36 -04:00
|
|
|
if (Main.overview.visible !== this._cachedOverviewVisible) {
|
|
|
|
this._cachedOverviewVisible = Main.overview.visible;
|
|
|
|
this._dbusImpl.emit_property_changed('OverviewActive', new GLib.Variant('b', this._cachedOverviewVisible));
|
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
get Mode() {
|
|
|
|
return global.session_mode;
|
|
|
|
}
|
2013-07-13 14:58:36 -04:00
|
|
|
|
2012-06-27 11:47:51 -04:00
|
|
|
get OverviewActive() {
|
2013-07-13 14:58:36 -04:00
|
|
|
return this._cachedOverviewVisible;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-27 11:47:51 -04:00
|
|
|
|
|
|
|
set OverviewActive(visible) {
|
|
|
|
if (visible)
|
|
|
|
Main.overview.show();
|
|
|
|
else
|
|
|
|
Main.overview.hide();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-27 11:47:51 -04:00
|
|
|
|
2017-10-30 21:19:44 -04:00
|
|
|
get ShellVersion() {
|
|
|
|
return Config.PACKAGE_VERSION;
|
|
|
|
}
|
|
|
|
};
|
2012-06-27 11:47:51 -04:00
|
|
|
|
2018-09-05 20:55:20 -04:00
|
|
|
const GnomeShellExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
2012-06-27 11:47:51 -04:00
|
|
|
|
2017-10-30 21:19:44 -04:00
|
|
|
var GnomeShellExtensions = class {
|
|
|
|
constructor() {
|
2012-06-27 11:47:51 -04:00
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
2019-03-06 19:45:45 -05:00
|
|
|
Main.extensionManager.connect('extension-state-changed',
|
|
|
|
this._extensionStateChanged.bind(this));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-27 11:47:51 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
ListExtensions() {
|
2011-11-15 16:37:57 -05:00
|
|
|
let out = {};
|
2019-07-07 18:01:11 -04:00
|
|
|
Main.extensionManager.getUuids().forEach(uuid => {
|
2011-08-16 08:19:59 -04:00
|
|
|
let dbusObj = this.GetExtensionInfo(uuid);
|
|
|
|
out[uuid] = dbusObj;
|
2019-07-07 18:01:11 -04:00
|
|
|
});
|
2011-08-16 08:19:59 -04:00
|
|
|
return out;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-06-22 22:03:04 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
GetExtensionInfo(uuid) {
|
2019-07-07 18:01:11 -04:00
|
|
|
let extension = Main.extensionManager.lookup(uuid) || {};
|
2018-11-01 08:55:17 -04:00
|
|
|
return ExtensionUtils.serializeExtension(extension);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-06-22 22:03:04 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
GetExtensionErrors(uuid) {
|
2019-07-07 18:01:11 -04:00
|
|
|
let extension = Main.extensionManager.lookup(uuid);
|
2012-01-30 20:58:29 -05:00
|
|
|
if (!extension)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
if (!extension.errors)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
return extension.errors;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-06-22 21:41:30 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
InstallRemoteExtensionAsync([uuid], invocation) {
|
2012-06-26 20:46:37 -04:00
|
|
|
return ExtensionDownloader.installExtension(uuid, invocation);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-08-24 13:08:34 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
UninstallExtension(uuid) {
|
2012-06-26 20:46:37 -04:00
|
|
|
return ExtensionDownloader.uninstallExtension(uuid);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2011-09-10 17:10:50 -04:00
|
|
|
|
2018-01-17 07:43:11 -05:00
|
|
|
EnableExtension(uuid) {
|
|
|
|
return Main.extensionManager.enableExtension(uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
DisableExtension(uuid) {
|
|
|
|
return Main.extensionManager.disableExtension(uuid);
|
|
|
|
}
|
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
LaunchExtensionPrefs(uuid) {
|
2012-01-18 21:30:06 -05:00
|
|
|
let appSys = Shell.AppSystem.get_default();
|
|
|
|
let app = appSys.lookup_app('gnome-shell-extension-prefs.desktop');
|
2014-02-20 14:14:21 -05:00
|
|
|
let info = app.get_app_info();
|
|
|
|
let timestamp = global.display.get_current_time_roundtrip();
|
|
|
|
info.launch_uris(['extension:///' + uuid],
|
|
|
|
global.create_app_launch_context(timestamp, -1));
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-01-18 21:30:06 -05:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
ReloadExtension(uuid) {
|
2019-07-07 18:01:11 -04:00
|
|
|
let extension = Main.extensionManager.lookup(uuid);
|
2012-08-23 21:37:50 -04:00
|
|
|
if (!extension)
|
|
|
|
return;
|
|
|
|
|
2019-03-06 19:45:45 -05:00
|
|
|
Main.extensionManager.reloadExtension(extension);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-05 13:06:40 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
CheckForUpdates() {
|
2012-06-26 20:47:44 -04:00
|
|
|
ExtensionDownloader.checkForUpdates();
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-26 20:47:44 -04:00
|
|
|
|
2017-10-30 21:19:44 -04:00
|
|
|
get ShellVersion() {
|
|
|
|
return Config.PACKAGE_VERSION;
|
|
|
|
}
|
2011-06-27 22:21:02 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
_extensionStateChanged(_, newState) {
|
2019-07-08 06:21:10 -04:00
|
|
|
let state = ExtensionUtils.serializeExtension(newState);
|
|
|
|
this._dbusImpl.emit_signal('ExtensionStateChanged',
|
|
|
|
new GLib.Variant('(sa{sv})', [newState.uuid, state]));
|
|
|
|
|
2011-11-11 21:45:44 -05:00
|
|
|
this._dbusImpl.emit_signal('ExtensionStatusChanged',
|
|
|
|
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
|
2011-06-27 22:21:02 -04:00
|
|
|
}
|
2017-10-30 21:19:44 -04:00
|
|
|
};
|
2012-06-02 19:20:31 -04:00
|
|
|
|
2017-10-30 21:19:44 -04:00
|
|
|
var ScreenSaverDBus = class {
|
|
|
|
constructor(screenShield) {
|
2012-07-08 11:42:15 -04:00
|
|
|
this._screenShield = screenShield;
|
2017-10-30 20:38:18 -04:00
|
|
|
screenShield.connect('active-changed', shield => {
|
2013-01-31 12:05:46 -05:00
|
|
|
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active]));
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2019-02-04 06:30:53 -05:00
|
|
|
screenShield.connect('wake-up-screen', () => {
|
2014-03-10 14:16:03 -04:00
|
|
|
this._dbusImpl.emit_signal('WakeUpScreen', null);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-06-02 19:20:31 -04:00
|
|
|
|
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
|
2012-07-08 11:42:15 -04:00
|
|
|
|
|
|
|
Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-02 19:20:31 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
LockAsync(parameters, invocation) {
|
2017-10-30 20:38:18 -04:00
|
|
|
let tmpId = this._screenShield.connect('lock-screen-shown', () => {
|
2012-07-08 11:42:15 -04:00
|
|
|
this._screenShield.disconnect(tmpId);
|
2012-09-05 16:19:45 -04:00
|
|
|
|
|
|
|
invocation.return_value(null);
|
2017-10-30 20:38:18 -04:00
|
|
|
});
|
2012-09-05 16:19:45 -04:00
|
|
|
|
2012-07-08 11:42:15 -04:00
|
|
|
this._screenShield.lock(true);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-02 19:20:31 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
SetActive(active) {
|
2012-06-02 19:20:31 -04:00
|
|
|
if (active)
|
2013-01-27 09:45:04 -05:00
|
|
|
this._screenShield.activate(true);
|
2012-06-02 19:20:31 -04:00
|
|
|
else
|
2013-03-25 16:32:15 -04:00
|
|
|
this._screenShield.deactivate(false);
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-06-02 19:20:31 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
GetActive() {
|
2013-01-27 09:45:04 -05:00
|
|
|
return this._screenShield.active;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
2012-10-16 10:38:32 -04:00
|
|
|
|
2017-10-30 20:03:21 -04:00
|
|
|
GetActiveTime() {
|
2012-10-16 10:38:32 -04:00
|
|
|
let started = this._screenShield.activationTime;
|
|
|
|
if (started > 0)
|
|
|
|
return Math.floor((GLib.get_monotonic_time() - started) / 1000000);
|
|
|
|
else
|
|
|
|
return 0;
|
2017-10-30 21:19:44 -04:00
|
|
|
}
|
|
|
|
};
|