2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
import Meta from 'gi://Meta';
|
|
|
|
import Shell from 'gi://Shell';
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2011-06-30 00:09:00 +00:00
|
|
|
const Config = imports.misc.config;
|
2023-07-10 09:53:00 +00:00
|
|
|
import * as ExtensionDownloader from './extensionDownloader.js';
|
|
|
|
import * as ExtensionUtils from '../misc/extensionUtils.js';
|
|
|
|
import * as Main from './main.js';
|
|
|
|
import * as Screenshot from './screenshot.js';
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
import {loadInterfaceXML} from '../misc/fileUtils.js';
|
|
|
|
import {DBusSenderChecker} from '../misc/util.js';
|
|
|
|
import {ControlsState} from './overviewControls.js';
|
2018-09-06 00:55:20 +00:00
|
|
|
|
|
|
|
const GnomeShellIface = loadInterfaceXML('org.gnome.Shell');
|
|
|
|
const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
|
2012-06-02 23:20:31 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export class GnomeShell {
|
2017-10-31 01:19:44 +00:00
|
|
|
constructor() {
|
2011-08-16 12:19:59 +00:00
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
2012-06-27 15:47:51 +00:00
|
|
|
|
2021-06-17 13:29:42 +00:00
|
|
|
this._senderChecker = new DBusSenderChecker([
|
2022-02-11 16:13:50 +00:00
|
|
|
'org.gnome.Settings',
|
2021-06-17 13:29:42 +00:00
|
|
|
'org.gnome.SettingsDaemon.MediaKeys',
|
|
|
|
]);
|
|
|
|
|
2013-02-25 13:27:31 +00:00
|
|
|
this._extensionsService = new GnomeShellExtensions();
|
2012-12-10 15:26:31 +00:00
|
|
|
this._screenshotService = new Screenshot.ScreenshotService();
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2014-01-14 22:49:47 +00:00
|
|
|
this._grabbedAccelerators = new Map();
|
|
|
|
this._grabbers = new Map();
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
global.display.connect('accelerator-activated',
|
2019-07-08 09:44:12 +00:00
|
|
|
(display, action, device, timestamp) => {
|
|
|
|
this._emitAcceleratorActivated(action, device, timestamp);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2013-07-13 18:58:36 +00:00
|
|
|
|
|
|
|
this._cachedOverviewVisible = false;
|
|
|
|
Main.overview.connect('showing',
|
2023-08-06 23:45:22 +00:00
|
|
|
this._checkOverviewVisibleChanged.bind(this));
|
2013-07-13 18:58:36 +00:00
|
|
|
Main.overview.connect('hidden',
|
2023-08-06 23:45:22 +00:00
|
|
|
this._checkOverviewVisibleChanged.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2009-09-23 18:30:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Eval:
|
2023-07-30 12:56:59 +00:00
|
|
|
* @param {string} code A string containing JavaScript code
|
2019-10-17 16:41:52 +00:00
|
|
|
* @returns {Array}
|
2009-09-23 18:30:05 +00:00
|
|
|
*
|
|
|
|
* 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-31 00:03:21 +00:00
|
|
|
Eval(code) {
|
2021-06-16 23:50:50 +00:00
|
|
|
if (!global.context.unsafe_mode)
|
2013-04-26 13:17:11 +00:00
|
|
|
return [false, ''];
|
2011-10-27 21:41:06 +00:00
|
|
|
|
2009-09-23 18:30:05 +00:00
|
|
|
let returnValue;
|
|
|
|
let success;
|
|
|
|
try {
|
|
|
|
returnValue = JSON.stringify(eval(code));
|
2009-11-12 23:17:58 +00:00
|
|
|
// A hack; DBus doesn't have null/undefined
|
2023-08-07 00:51:19 +00:00
|
|
|
if (returnValue === undefined)
|
2010-05-13 19:46:04 +00:00
|
|
|
returnValue = '';
|
2009-09-23 18:30:05 +00:00
|
|
|
success = true;
|
|
|
|
} catch (e) {
|
2019-01-29 23:01:21 +00:00
|
|
|
returnValue = `${e}`;
|
2009-09-23 18:30:05 +00:00
|
|
|
success = false;
|
|
|
|
}
|
|
|
|
return [success, returnValue];
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2009-09-23 18:30:05 +00:00
|
|
|
|
2021-06-17 13:29:42 +00:00
|
|
|
/**
|
|
|
|
* Focus the overview's search entry
|
|
|
|
*
|
2021-11-23 01:48:04 +00:00
|
|
|
* @async
|
2021-06-17 13:29:42 +00:00
|
|
|
* @param {...any} params - method parameters
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation - the invocation
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-11-23 01:48:04 +00:00
|
|
|
async FocusSearchAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-17 15:31:27 +00:00
|
|
|
Main.overview.focusSearch();
|
2021-06-17 13:29:42 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-05-17 15:31:27 +00:00
|
|
|
|
2021-06-17 13:29:42 +00:00
|
|
|
/**
|
|
|
|
* Show OSD with the specified parameters
|
|
|
|
*
|
2021-11-23 01:48:04 +00:00
|
|
|
* @async
|
2021-06-17 13:29:42 +00:00
|
|
|
* @param {...any} params - method parameters
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation - the invocation
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-11-23 01:48:04 +00:00
|
|
|
async ShowOSDAsync([params], invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-02 15:22:49 +00:00
|
|
|
for (let param in params)
|
2022-08-10 09:56:14 +00:00
|
|
|
params[param] = params[param].deepUnpack();
|
2013-03-02 15:22:49 +00:00
|
|
|
|
2020-03-29 21:51:13 +00:00
|
|
|
const {
|
|
|
|
connector,
|
|
|
|
label,
|
|
|
|
level,
|
|
|
|
max_level: maxLevel,
|
|
|
|
icon: serializedIcon,
|
|
|
|
} = params;
|
2018-08-01 11:27:07 +00:00
|
|
|
|
2019-04-11 09:43:03 +00:00
|
|
|
let monitorIndex = -1;
|
|
|
|
if (connector) {
|
2022-09-07 18:24:44 +00:00
|
|
|
const monitorManager = global.backend.get_monitor_manager();
|
2019-04-11 09:43:03 +00:00
|
|
|
monitorIndex = monitorManager.get_monitor_for_connector(connector);
|
|
|
|
}
|
2013-11-18 12:48:19 +00:00
|
|
|
|
2013-03-02 15:22:49 +00:00
|
|
|
let icon = null;
|
2018-08-01 11:27:07 +00:00
|
|
|
if (serializedIcon)
|
|
|
|
icon = Gio.Icon.new_for_string(serializedIcon);
|
2013-03-02 15:22:49 +00:00
|
|
|
|
2018-07-31 14:47:05 +00:00
|
|
|
Main.osdWindowManager.show(monitorIndex, icon, label, level, maxLevel);
|
2021-06-17 13:29:42 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2013-03-02 15:22:49 +00:00
|
|
|
|
2021-06-17 13:29:42 +00:00
|
|
|
/**
|
|
|
|
* Focus specified app in the overview's app grid
|
|
|
|
*
|
2021-11-23 01:48:04 +00:00
|
|
|
* @async
|
2021-06-17 13:29:42 +00:00
|
|
|
* @param {string} id - an application ID
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation - the invocation
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-11-23 01:48:04 +00:00
|
|
|
async FocusAppAsync([id], invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-01-08 21:03:13 +00:00
|
|
|
const appSys = Shell.AppSystem.get_default();
|
|
|
|
if (appSys.lookup_app(id) === null) {
|
|
|
|
invocation.return_error_literal(
|
|
|
|
Gio.DBusError,
|
|
|
|
Gio.DBusError.FILE_NOT_FOUND,
|
2022-12-16 21:33:10 +00:00
|
|
|
`No app with ID ${id}`);
|
2019-01-08 21:03:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-06-17 20:09:14 +00:00
|
|
|
Main.overview.selectApp(id);
|
2021-06-17 13:29:42 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-07-09 13:30:42 +00:00
|
|
|
|
2021-06-17 13:29:42 +00:00
|
|
|
/**
|
|
|
|
* Show the overview's app grid
|
|
|
|
*
|
2021-11-23 01:48:04 +00:00
|
|
|
* @async
|
2021-06-17 13:29:42 +00:00
|
|
|
* @param {...any} params - method parameters
|
|
|
|
* @param {Gio.DBusMethodInvocation} invocation - the invocation
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2021-11-23 01:48:04 +00:00
|
|
|
async ShowApplicationsAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-01-02 20:28:44 +00:00
|
|
|
Main.overview.show(ControlsState.APP_GRID);
|
2021-06-17 13:29:42 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-07-09 13:30:42 +00:00
|
|
|
|
2021-11-23 01:48:04 +00:00
|
|
|
async GrabAcceleratorAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-18 18:26:44 +00:00
|
|
|
let [accel, modeFlags, grabFlags] = params;
|
2012-08-11 21:11:37 +00:00
|
|
|
let sender = invocation.get_sender();
|
2018-07-18 18:26:44 +00:00
|
|
|
let bindingAction = this._grabAcceleratorForSender(accel, modeFlags, grabFlags, sender);
|
2021-06-17 13:41:20 +00:00
|
|
|
invocation.return_value(GLib.Variant.new('(u)', [bindingAction]));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2021-11-23 01:48:04 +00:00
|
|
|
async GrabAcceleratorsAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-11 21:11:37 +00:00
|
|
|
let [accels] = params;
|
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let bindingActions = [];
|
|
|
|
for (let i = 0; i < accels.length; i++) {
|
2018-07-18 18:26:44 +00:00
|
|
|
let [accel, modeFlags, grabFlags] = accels[i];
|
|
|
|
bindingActions.push(this._grabAcceleratorForSender(accel, modeFlags, grabFlags, sender));
|
2012-08-11 21:11:37 +00:00
|
|
|
}
|
2021-06-17 13:41:20 +00:00
|
|
|
invocation.return_value(GLib.Variant.new('(au)', [bindingActions]));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2021-11-23 01:48:04 +00:00
|
|
|
async UngrabAcceleratorAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-11 21:11:37 +00:00
|
|
|
let [action] = params;
|
2019-03-02 15:49:55 +00:00
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let ungrabSucceeded = this._ungrabAcceleratorForSender(action, sender);
|
|
|
|
|
2021-06-17 13:41:20 +00:00
|
|
|
invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
|
2019-03-02 15:49:55 +00:00
|
|
|
}
|
|
|
|
|
2021-11-23 01:48:04 +00:00
|
|
|
async UngrabAcceleratorsAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-02 15:49:55 +00:00
|
|
|
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 21:11:37 +00:00
|
|
|
|
2021-06-17 13:41:20 +00:00
|
|
|
invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2022-03-28 13:25:41 +00:00
|
|
|
async ScreenTransitionAsync(params, invocation) {
|
2021-09-23 07:45:14 +00:00
|
|
|
try {
|
2022-03-28 13:25:41 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-09-23 07:45:14 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Main.layoutManager.screenTransition.run();
|
|
|
|
|
|
|
|
invocation.return_value(null);
|
|
|
|
}
|
|
|
|
|
2019-07-08 09:44:12 +00:00
|
|
|
_emitAcceleratorActivated(action, device, timestamp) {
|
2012-08-11 21:11:37 +00:00
|
|
|
let destination = this._grabbedAccelerators.get(action);
|
|
|
|
if (!destination)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let connection = this._dbusImpl.get_connection();
|
|
|
|
let info = this._dbusImpl.get_info();
|
2020-11-17 14:35:15 +00:00
|
|
|
let params = {
|
|
|
|
'timestamp': GLib.Variant.new('u', timestamp),
|
|
|
|
'action-mode': GLib.Variant.new('u', Main.actionMode),
|
|
|
|
};
|
2019-09-20 19:08:45 +00:00
|
|
|
|
|
|
|
let deviceNode = device.get_device_node();
|
|
|
|
if (deviceNode)
|
|
|
|
params['device-node'] = GLib.Variant.new('s', deviceNode);
|
|
|
|
|
2020-08-12 18:59:01 +00:00
|
|
|
connection.emit_signal(
|
|
|
|
destination,
|
|
|
|
this._dbusImpl.get_object_path(),
|
|
|
|
info?.name ?? null,
|
|
|
|
'AcceleratorActivated',
|
|
|
|
GLib.Variant.new('(ua{sv})', [action, params]));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2018-07-18 18:26:44 +00:00
|
|
|
_grabAcceleratorForSender(accelerator, modeFlags, grabFlags, sender) {
|
|
|
|
let bindingAction = global.display.grab_accelerator(accelerator, grabFlags);
|
2023-08-07 00:51:19 +00:00
|
|
|
if (bindingAction === Meta.KeyBindingAction.NONE)
|
2012-08-11 21:11:37 +00:00
|
|
|
return Meta.KeyBindingAction.NONE;
|
|
|
|
|
|
|
|
let bindingName = Meta.external_binding_name_for_action(bindingAction);
|
2018-07-18 18:26:44 +00:00
|
|
|
Main.wm.allowKeybinding(bindingName, modeFlags);
|
2012-08-11 21:11:37 +00:00
|
|
|
|
|
|
|
this._grabbedAccelerators.set(bindingAction, sender);
|
|
|
|
|
|
|
|
if (!this._grabbers.has(sender)) {
|
2023-08-06 23:45:22 +00:00
|
|
|
let id = Gio.bus_watch_name(Gio.BusType.SESSION,
|
|
|
|
sender, 0, null, this._onGrabberBusNameVanished.bind(this));
|
2012-08-11 21:11:37 +00:00
|
|
|
this._grabbers.set(sender, id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return bindingAction;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_ungrabAccelerator(action) {
|
2012-08-11 21:11:37 +00:00
|
|
|
let ungrabSucceeded = global.display.ungrab_accelerator(action);
|
|
|
|
if (ungrabSucceeded)
|
|
|
|
this._grabbedAccelerators.delete(action);
|
2019-03-02 15:49:55 +00:00
|
|
|
|
|
|
|
return ungrabSucceeded;
|
|
|
|
}
|
|
|
|
|
|
|
|
_ungrabAcceleratorForSender(action, sender) {
|
|
|
|
let grabbedBy = this._grabbedAccelerators.get(action);
|
2023-08-07 00:51:19 +00:00
|
|
|
if (sender !== grabbedBy)
|
2019-03-02 15:49:55 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return this._ungrabAccelerator(action);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_onGrabberBusNameVanished(connection, name) {
|
2014-01-14 22:49:47 +00:00
|
|
|
let grabs = this._grabbedAccelerators.entries();
|
|
|
|
for (let [action, sender] of grabs) {
|
2023-08-07 00:51:19 +00:00
|
|
|
if (sender === name)
|
2012-08-11 21:11:37 +00:00
|
|
|
this._ungrabAccelerator(action);
|
|
|
|
}
|
|
|
|
Gio.bus_unwatch_name(this._grabbers.get(name));
|
|
|
|
this._grabbers.delete(name);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-08-11 21:11:37 +00:00
|
|
|
|
2021-11-23 01:48:04 +00:00
|
|
|
async ShowMonitorLabelsAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-06 05:18:39 +00:00
|
|
|
let sender = invocation.get_sender();
|
|
|
|
let [dict] = params;
|
2019-04-11 17:37:15 +00:00
|
|
|
Main.osdMonitorLabeler.show(sender, dict);
|
2021-06-17 13:42:14 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2017-04-06 05:18:39 +00:00
|
|
|
|
2021-11-23 01:48:04 +00:00
|
|
|
async HideMonitorLabelsAsync(params, invocation) {
|
2021-06-17 13:29:42 +00:00
|
|
|
try {
|
2021-11-23 01:48:04 +00:00
|
|
|
await this._senderChecker.checkInvocation(invocation);
|
2021-06-17 13:29:42 +00:00
|
|
|
} catch (e) {
|
|
|
|
invocation.return_gerror(e);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-26 14:52:10 +00:00
|
|
|
let sender = invocation.get_sender();
|
|
|
|
Main.osdMonitorLabeler.hide(sender);
|
2021-06-17 13:42:14 +00:00
|
|
|
invocation.return_value(null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-11-29 18:17:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_checkOverviewVisibleChanged() {
|
2013-07-13 18:58:36 +00: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-31 01:19:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get Mode() {
|
|
|
|
return global.session_mode;
|
|
|
|
}
|
2013-07-13 18:58:36 +00:00
|
|
|
|
2012-06-27 15:47:51 +00:00
|
|
|
get OverviewActive() {
|
2013-07-13 18:58:36 +00:00
|
|
|
return this._cachedOverviewVisible;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-27 15:47:51 +00:00
|
|
|
|
|
|
|
set OverviewActive(visible) {
|
|
|
|
if (visible)
|
|
|
|
Main.overview.show();
|
|
|
|
else
|
|
|
|
Main.overview.hide();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-27 15:47:51 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
get ShellVersion() {
|
|
|
|
return Config.PACKAGE_VERSION;
|
|
|
|
}
|
2023-07-10 09:53:00 +00:00
|
|
|
}
|
2012-06-27 15:47:51 +00:00
|
|
|
|
2018-09-06 00:55:20 +00:00
|
|
|
const GnomeShellExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions');
|
2012-06-27 15:47:51 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
class GnomeShellExtensions {
|
2017-10-31 01:19:44 +00:00
|
|
|
constructor() {
|
2012-06-27 15:47:51 +00:00
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
2020-03-05 17:15:37 +00:00
|
|
|
|
|
|
|
this._userExtensionsEnabled = this.UserExtensionsEnabled;
|
|
|
|
global.settings.connect('changed::disable-user-extensions', () => {
|
|
|
|
if (this._userExtensionsEnabled === this.UserExtensionsEnabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._userExtensionsEnabled = this.UserExtensionsEnabled;
|
|
|
|
this._dbusImpl.emit_property_changed('UserExtensionsEnabled',
|
|
|
|
new GLib.Variant('b', this._userExtensionsEnabled));
|
|
|
|
});
|
|
|
|
|
2019-03-07 00:45:45 +00:00
|
|
|
Main.extensionManager.connect('extension-state-changed',
|
2023-08-06 23:45:22 +00:00
|
|
|
this._extensionStateChanged.bind(this));
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-27 15:47:51 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
ListExtensions() {
|
2011-11-15 21:37:57 +00:00
|
|
|
let out = {};
|
2019-07-07 22:01:11 +00:00
|
|
|
Main.extensionManager.getUuids().forEach(uuid => {
|
2011-08-16 12:19:59 +00:00
|
|
|
let dbusObj = this.GetExtensionInfo(uuid);
|
|
|
|
out[uuid] = dbusObj;
|
2019-07-07 22:01:11 +00:00
|
|
|
});
|
2011-08-16 12:19:59 +00:00
|
|
|
return out;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-06-23 02:03:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
GetExtensionInfo(uuid) {
|
2019-07-07 22:01:11 +00:00
|
|
|
let extension = Main.extensionManager.lookup(uuid) || {};
|
2018-11-01 12:55:17 +00:00
|
|
|
return ExtensionUtils.serializeExtension(extension);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-06-23 02:03:04 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
GetExtensionErrors(uuid) {
|
2019-07-07 22:01:11 +00:00
|
|
|
let extension = Main.extensionManager.lookup(uuid);
|
2012-01-31 01:58:29 +00:00
|
|
|
if (!extension)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
if (!extension.errors)
|
|
|
|
return [];
|
|
|
|
|
|
|
|
return extension.errors;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-06-23 01:41:30 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
InstallRemoteExtensionAsync([uuid], invocation) {
|
2012-06-27 00:46:37 +00:00
|
|
|
return ExtensionDownloader.installExtension(uuid, invocation);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-08-24 17:08:34 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
UninstallExtension(uuid) {
|
2012-06-27 00:46:37 +00:00
|
|
|
return ExtensionDownloader.uninstallExtension(uuid);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2011-09-10 21:10:50 +00:00
|
|
|
|
2018-01-17 12:43:11 +00:00
|
|
|
EnableExtension(uuid) {
|
|
|
|
return Main.extensionManager.enableExtension(uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
DisableExtension(uuid) {
|
|
|
|
return Main.extensionManager.disableExtension(uuid);
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
LaunchExtensionPrefs(uuid) {
|
2020-03-05 01:00:57 +00:00
|
|
|
this.OpenExtensionPrefs(uuid, '', {});
|
|
|
|
}
|
|
|
|
|
2020-03-04 04:05:08 +00:00
|
|
|
OpenExtensionPrefs(uuid, parentWindow, options) {
|
2020-04-01 19:04:03 +00:00
|
|
|
Main.extensionManager.openExtensionPrefs(uuid, parentWindow, options);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-01-19 02:30:06 +00:00
|
|
|
|
2020-03-28 17:55:17 +00:00
|
|
|
ReloadExtensionAsync(params, invocation) {
|
|
|
|
invocation.return_error_literal(
|
|
|
|
Gio.DBusError,
|
|
|
|
Gio.DBusError.NOT_SUPPORTED,
|
|
|
|
'ReloadExtension is deprecated and does not work');
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-05 17:06:40 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
CheckForUpdates() {
|
2012-06-27 00:47:44 +00:00
|
|
|
ExtensionDownloader.checkForUpdates();
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-27 00:47:44 +00:00
|
|
|
|
2017-10-31 01:19:44 +00:00
|
|
|
get ShellVersion() {
|
|
|
|
return Config.PACKAGE_VERSION;
|
|
|
|
}
|
2011-06-28 02:21:02 +00:00
|
|
|
|
2020-03-05 17:15:37 +00:00
|
|
|
get UserExtensionsEnabled() {
|
|
|
|
return !global.settings.get_boolean('disable-user-extensions');
|
|
|
|
}
|
|
|
|
|
|
|
|
set UserExtensionsEnabled(enable) {
|
|
|
|
global.settings.set_boolean('disable-user-extensions', !enable);
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
_extensionStateChanged(_, newState) {
|
2019-07-08 10:21:10 +00:00
|
|
|
let state = ExtensionUtils.serializeExtension(newState);
|
|
|
|
this._dbusImpl.emit_signal('ExtensionStateChanged',
|
|
|
|
new GLib.Variant('(sa{sv})', [newState.uuid, state]));
|
|
|
|
|
2011-11-12 02:45:44 +00:00
|
|
|
this._dbusImpl.emit_signal('ExtensionStatusChanged',
|
2023-08-06 23:45:22 +00:00
|
|
|
new GLib.Variant('(sis)', [newState.uuid, newState.state, newState.error]));
|
2011-06-28 02:21:02 +00:00
|
|
|
}
|
2023-07-10 09:53:00 +00:00
|
|
|
}
|
2012-06-02 23:20:31 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export class ScreenSaverDBus {
|
2017-10-31 01:19:44 +00:00
|
|
|
constructor(screenShield) {
|
2012-07-08 15:42:15 +00:00
|
|
|
this._screenShield = screenShield;
|
2017-10-31 00:38:18 +00:00
|
|
|
screenShield.connect('active-changed', shield => {
|
2013-01-31 17:05:46 +00:00
|
|
|
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active]));
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2019-02-04 11:30:53 +00:00
|
|
|
screenShield.connect('wake-up-screen', () => {
|
2014-03-10 18:16:03 +00:00
|
|
|
this._dbusImpl.emit_signal('WakeUpScreen', null);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-06-02 23:20:31 +00:00
|
|
|
|
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
|
2012-07-08 15:42:15 +00:00
|
|
|
|
2020-12-04 19:40:13 +00:00
|
|
|
Gio.DBus.session.own_name('org.gnome.Shell.ScreenShield',
|
|
|
|
Gio.BusNameOwnerFlags.NONE, null, null);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-02 23:20:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
LockAsync(parameters, invocation) {
|
2017-10-31 00:38:18 +00:00
|
|
|
let tmpId = this._screenShield.connect('lock-screen-shown', () => {
|
2012-07-08 15:42:15 +00:00
|
|
|
this._screenShield.disconnect(tmpId);
|
2012-09-05 20:19:45 +00:00
|
|
|
|
|
|
|
invocation.return_value(null);
|
2017-10-31 00:38:18 +00:00
|
|
|
});
|
2012-09-05 20:19:45 +00:00
|
|
|
|
2012-07-08 15:42:15 +00:00
|
|
|
this._screenShield.lock(true);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-02 23:20:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
SetActive(active) {
|
2012-06-02 23:20:31 +00:00
|
|
|
if (active)
|
2013-01-27 14:45:04 +00:00
|
|
|
this._screenShield.activate(true);
|
2012-06-02 23:20:31 +00:00
|
|
|
else
|
2013-03-25 20:32:15 +00:00
|
|
|
this._screenShield.deactivate(false);
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-06-02 23:20:31 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
GetActive() {
|
2013-01-27 14:45:04 +00:00
|
|
|
return this._screenShield.active;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2012-10-16 14:38:32 +00:00
|
|
|
|
2017-10-31 00:03:21 +00:00
|
|
|
GetActiveTime() {
|
2012-10-16 14:38:32 +00:00
|
|
|
let started = this._screenShield.activationTime;
|
|
|
|
if (started > 0)
|
|
|
|
return Math.floor((GLib.get_monotonic_time() - started) / 1000000);
|
|
|
|
else
|
|
|
|
return 0;
|
2017-10-31 01:19:44 +00:00
|
|
|
}
|
2023-07-10 09:53:00 +00:00
|
|
|
}
|