2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2023-07-10 09:53:00 +00:00
|
|
|
|
|
|
|
import Clutter from 'gi://Clutter';
|
|
|
|
import Gio from 'gi://Gio';
|
|
|
|
import GLib from 'gi://GLib';
|
|
|
|
import GObject from 'gi://GObject';
|
|
|
|
import Meta from 'gi://Meta';
|
|
|
|
import Shell from 'gi://Shell';
|
|
|
|
import St from 'gi://St';
|
|
|
|
|
|
|
|
import * as AccessDialog from './accessDialog.js';
|
|
|
|
import * as AudioDeviceSelection from './audioDeviceSelection.js';
|
2023-08-07 15:30:22 +00:00
|
|
|
import * as Config from '../misc/config.js';
|
2023-07-10 09:53:00 +00:00
|
|
|
import * as Components from './components.js';
|
|
|
|
import * as CtrlAltTab from './ctrlAltTab.js';
|
|
|
|
import * as EndSessionDialog from './endSessionDialog.js';
|
|
|
|
import * as ExtensionSystem from './extensionSystem.js';
|
|
|
|
import * as ExtensionDownloader from './extensionDownloader.js';
|
|
|
|
import * as InputMethod from '../misc/inputMethod.js';
|
|
|
|
import * as Introspect from '../misc/introspect.js';
|
|
|
|
import * as Keyboard from './keyboard.js';
|
|
|
|
import * as MessageTray from './messageTray.js';
|
|
|
|
import * as ModalDialog from './modalDialog.js';
|
|
|
|
import * as OsdWindow from './osdWindow.js';
|
|
|
|
import * as OsdMonitorLabeler from './osdMonitorLabeler.js';
|
|
|
|
import * as Overview from './overview.js';
|
|
|
|
import * as PadOsd from './padOsd.js';
|
|
|
|
import * as Panel from './panel.js';
|
|
|
|
import * as Params from '../misc/params.js';
|
|
|
|
import * as RunDialog from './runDialog.js';
|
|
|
|
import * as WelcomeDialog from './welcomeDialog.js';
|
|
|
|
import * as Layout from './layout.js';
|
|
|
|
import * as LoginManager from '../misc/loginManager.js';
|
|
|
|
import * as LookingGlass from './lookingGlass.js';
|
|
|
|
import * as NotificationDaemon from './notificationDaemon.js';
|
|
|
|
import * as WindowAttentionHandler from './windowAttentionHandler.js';
|
|
|
|
import * as Screenshot from './screenshot.js';
|
|
|
|
import * as ScreenShield from './screenShield.js';
|
|
|
|
import * as SessionMode from './sessionMode.js';
|
|
|
|
import * as ShellDBus from './shellDBus.js';
|
|
|
|
import * as ShellMountOperation from './shellMountOperation.js';
|
|
|
|
import * as WindowManager from './windowManager.js';
|
|
|
|
import * as Magnifier from './magnifier.js';
|
|
|
|
import * as XdndHandler from './xdndHandler.js';
|
|
|
|
import * as KbdA11yDialog from './kbdA11yDialog.js';
|
|
|
|
import * as LocatePointer from './locatePointer.js';
|
|
|
|
import * as PointerA11yTimeout from './pointerA11yTimeout.js';
|
|
|
|
import * as ParentalControlsManager from '../misc/parentalControlsManager.js';
|
|
|
|
import * as Util from '../misc/util.js';
|
2008-10-31 18:09:20 +00:00
|
|
|
|
2021-02-01 12:31:41 +00:00
|
|
|
const WELCOME_DIALOG_LAST_SHOWN_VERSION = 'welcome-dialog-last-shown-version';
|
|
|
|
// Make sure to mention the point release, otherwise it will show every time
|
|
|
|
// until this version is current
|
|
|
|
const WELCOME_DIALOG_LAST_TOUR_CHANGE = '40.beta';
|
2019-06-15 12:48:58 +00:00
|
|
|
const LOG_DOMAIN = 'GNOME Shell';
|
2014-04-18 14:31:18 +00:00
|
|
|
const GNOMESHELL_STARTED_MESSAGE_ID = 'f3ea493c22934e26811cd62abe8e203a';
|
2013-04-17 23:59:02 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export let componentManager = null;
|
|
|
|
export let extensionManager = null;
|
|
|
|
export let panel = null;
|
|
|
|
export let overview = null;
|
|
|
|
export let runDialog = null;
|
|
|
|
export let lookingGlass = null;
|
|
|
|
export let welcomeDialog = null;
|
|
|
|
export let wm = null;
|
|
|
|
export let messageTray = null;
|
|
|
|
export let screenShield = null;
|
|
|
|
export let notificationDaemon = null;
|
|
|
|
export let windowAttentionHandler = null;
|
|
|
|
export let ctrlAltTabManager = null;
|
|
|
|
export let padOsdService = null;
|
|
|
|
export let osdWindowManager = null;
|
|
|
|
export let osdMonitorLabeler = null;
|
|
|
|
export let sessionMode = null;
|
|
|
|
export let screenshotUI = null;
|
|
|
|
export let shellAccessDialogDBusService = null;
|
|
|
|
export let shellAudioSelectionDBusService = null;
|
|
|
|
export let shellDBusService = null;
|
|
|
|
export let shellMountOpDBusService = null;
|
|
|
|
export let screenSaverDBus = null;
|
|
|
|
export let modalCount = 0;
|
|
|
|
export let actionMode = Shell.ActionMode.NONE;
|
|
|
|
export let modalActorFocusStack = [];
|
|
|
|
export let uiGroup = null;
|
|
|
|
export let magnifier = null;
|
|
|
|
export let xdndHandler = null;
|
|
|
|
export let keyboard = null;
|
|
|
|
export let layoutManager = null;
|
|
|
|
export let kbdA11yDialog = null;
|
|
|
|
export let inputMethod = null;
|
|
|
|
export let introspectService = null;
|
|
|
|
export let locatePointer = null;
|
|
|
|
|
2009-10-24 17:36:52 +00:00
|
|
|
let _startDate;
|
2011-02-01 15:11:00 +00:00
|
|
|
let _defaultCssStylesheet = null;
|
|
|
|
let _cssStylesheet = null;
|
2015-10-21 17:27:19 +00:00
|
|
|
let _themeResource = null;
|
2017-08-10 19:27:25 +00:00
|
|
|
let _oskResource = null;
|
2022-01-31 15:10:58 +00:00
|
|
|
let _iconResource = null;
|
2023-08-10 19:49:19 +00:00
|
|
|
let _workspacesAdjustment = null;
|
2008-10-31 18:09:20 +00:00
|
|
|
|
2022-02-10 23:09:54 +00:00
|
|
|
Gio._promisify(Gio.File.prototype, 'delete_async');
|
|
|
|
Gio._promisify(Gio.File.prototype, 'touch_async');
|
2020-03-20 11:42:04 +00:00
|
|
|
|
2020-04-21 14:13:20 +00:00
|
|
|
let _remoteAccessInhibited = false;
|
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
function _sessionUpdated() {
|
2014-11-29 13:37:19 +00:00
|
|
|
if (sessionMode.isPrimary)
|
|
|
|
_loadDefaultStylesheet();
|
2013-02-18 10:23:08 +00:00
|
|
|
|
2023-08-06 23:45:22 +00:00
|
|
|
wm.allowKeybinding('overlay-key',
|
|
|
|
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW);
|
2012-08-11 04:34:53 +00:00
|
|
|
|
2019-02-20 09:12:36 +00:00
|
|
|
wm.allowKeybinding('locate-pointer-key', Shell.ActionMode.ALL);
|
|
|
|
|
2012-08-11 04:34:53 +00:00
|
|
|
wm.setCustomKeybindingHandler('panel-run-dialog',
|
2023-08-06 23:45:22 +00:00
|
|
|
Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW,
|
|
|
|
sessionMode.hasRunDialog ? openRunDialog : null);
|
2013-03-08 21:59:02 +00:00
|
|
|
|
2013-09-18 17:47:59 +00:00
|
|
|
if (!sessionMode.hasRunDialog) {
|
|
|
|
if (runDialog)
|
|
|
|
runDialog.close();
|
|
|
|
if (lookingGlass)
|
|
|
|
lookingGlass.close();
|
2021-02-01 09:20:48 +00:00
|
|
|
if (welcomeDialog)
|
|
|
|
welcomeDialog.close();
|
2013-09-18 17:47:59 +00:00
|
|
|
}
|
2020-04-21 14:13:20 +00:00
|
|
|
|
|
|
|
let remoteAccessController = global.backend.get_remote_access_controller();
|
2021-12-03 00:14:16 +00:00
|
|
|
if (remoteAccessController && !global.backend.is_headless()) {
|
2020-04-21 14:13:20 +00:00
|
|
|
if (sessionMode.allowScreencast && _remoteAccessInhibited) {
|
|
|
|
remoteAccessController.uninhibit_remote_access();
|
|
|
|
_remoteAccessInhibited = false;
|
|
|
|
} else if (!sessionMode.allowScreencast && !_remoteAccessInhibited) {
|
|
|
|
remoteAccessController.inhibit_remote_access();
|
|
|
|
_remoteAccessInhibited = true;
|
|
|
|
}
|
|
|
|
}
|
2012-09-01 12:42:53 +00:00
|
|
|
}
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
/** @returns {void} */
|
2023-07-10 09:53:00 +00:00
|
|
|
export async function start() {
|
2022-08-01 09:26:59 +00:00
|
|
|
globalThis.log = console.log;
|
2022-07-05 16:11:46 +00:00
|
|
|
|
2011-03-15 22:31:16 +00:00
|
|
|
// Chain up async errors reported from C
|
2017-10-31 00:38:18 +00:00
|
|
|
global.connect('notify-error', (global, msg, detail) => {
|
|
|
|
notifyError(msg, detail);
|
|
|
|
});
|
2011-03-15 22:31:16 +00:00
|
|
|
|
2020-03-31 18:13:46 +00:00
|
|
|
let currentDesktop = GLib.getenv('XDG_CURRENT_DESKTOP');
|
|
|
|
if (!currentDesktop || !currentDesktop.split(':').includes('GNOME'))
|
|
|
|
Gio.DesktopAppInfo.set_desktop_env('GNOME');
|
2009-01-22 21:28:19 +00:00
|
|
|
|
2013-02-18 10:26:25 +00:00
|
|
|
sessionMode = new SessionMode.SessionMode();
|
|
|
|
sessionMode.connect('updated', _sessionUpdated);
|
2018-11-27 13:59:09 +00:00
|
|
|
|
2021-12-19 16:29:51 +00:00
|
|
|
St.Settings.get().connect('notify::high-contrast', _loadDefaultStylesheet);
|
2022-06-03 15:21:08 +00:00
|
|
|
St.Settings.get().connect('notify::color-scheme', _loadDefaultStylesheet);
|
2019-04-24 09:37:10 +00:00
|
|
|
|
|
|
|
// Initialize ParentalControlsManager before the UI
|
|
|
|
ParentalControlsManager.getDefault();
|
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
await _initializeUI();
|
2013-03-08 20:04:15 +00:00
|
|
|
|
2016-07-12 20:47:32 +00:00
|
|
|
shellAccessDialogDBusService = new AccessDialog.AccessDialogDBus();
|
2016-02-09 22:03:26 +00:00
|
|
|
shellAudioSelectionDBusService = new AudioDeviceSelection.AudioDeviceSelectionDBus();
|
2013-03-08 20:04:15 +00:00
|
|
|
shellDBusService = new ShellDBus.GnomeShell();
|
|
|
|
shellMountOpDBusService = new ShellMountOperation.GnomeShellMountOpHandler();
|
|
|
|
|
2020-03-12 22:23:37 +00:00
|
|
|
const watchId = Gio.DBus.session.watch_name('org.gnome.Shell.Notifications',
|
|
|
|
Gio.BusNameWatcherFlags.AUTO_START,
|
|
|
|
bus => bus.unwatch_name(watchId),
|
|
|
|
bus => bus.unwatch_name(watchId));
|
2020-03-04 01:35:21 +00:00
|
|
|
|
2013-02-18 10:26:25 +00:00
|
|
|
_sessionUpdated();
|
|
|
|
}
|
2013-03-06 22:25:28 +00:00
|
|
|
|
2023-06-13 00:13:01 +00:00
|
|
|
/** @private */
|
|
|
|
async function _initializeUI() {
|
2009-10-15 23:28:29 +00:00
|
|
|
// Ensure ShellWindowTracker and ShellAppUsage are initialized; this will
|
2019-06-26 10:54:09 +00:00
|
|
|
// also initialize ShellAppSystem first. ShellAppSystem
|
2009-10-15 23:28:29 +00:00
|
|
|
// needs to load all the .desktop files, and ShellWindowTracker
|
2019-06-26 10:54:09 +00:00
|
|
|
// will use those to associate with windows. Right now
|
2009-08-12 17:32:54 +00:00
|
|
|
// the Monitor doesn't listen for installed app changes
|
|
|
|
// and recalculate application associations, so to avoid
|
2019-06-26 10:54:09 +00:00
|
|
|
// races for now we initialize it here. It's better to
|
2009-08-12 17:32:54 +00:00
|
|
|
// be predictable anyways.
|
2012-12-23 03:10:27 +00:00
|
|
|
Shell.WindowTracker.get_default();
|
2009-10-15 23:28:29 +00:00
|
|
|
Shell.AppUsage.get_default();
|
2009-08-12 17:32:54 +00:00
|
|
|
|
2015-10-21 17:27:19 +00:00
|
|
|
reloadThemeResource();
|
2022-01-31 15:10:58 +00:00
|
|
|
_loadIcons();
|
2017-08-10 19:27:25 +00:00
|
|
|
_loadOskLayouts();
|
2013-02-05 03:13:44 +00:00
|
|
|
_loadDefaultStylesheet();
|
2023-08-10 19:49:19 +00:00
|
|
|
_loadWorkspacesAdjustment();
|
2009-09-10 05:36:41 +00:00
|
|
|
|
2019-10-01 10:02:31 +00:00
|
|
|
new AnimationsSettings();
|
|
|
|
|
2013-01-10 21:02:20 +00:00
|
|
|
// Setup the stage hierarchy early
|
2011-06-13 13:54:05 +00:00
|
|
|
layoutManager = new Layout.LayoutManager();
|
2013-02-14 03:45:43 +00:00
|
|
|
|
2019-06-26 10:54:09 +00:00
|
|
|
// Various parts of the codebase still refer to Main.uiGroup
|
|
|
|
// instead of using the layoutManager. This keeps that code
|
2013-01-10 21:02:20 +00:00
|
|
|
// working until it's updated.
|
|
|
|
uiGroup = layoutManager.uiGroup;
|
|
|
|
|
2016-06-22 17:57:12 +00:00
|
|
|
padOsdService = new PadOsd.PadOsdService();
|
2011-01-05 14:47:27 +00:00
|
|
|
xdndHandler = new XdndHandler.XdndHandler();
|
2011-02-07 16:29:34 +00:00
|
|
|
ctrlAltTabManager = new CtrlAltTab.CtrlAltTabManager();
|
2014-04-17 08:23:30 +00:00
|
|
|
osdWindowManager = new OsdWindow.OsdWindowManager();
|
2015-01-26 14:52:10 +00:00
|
|
|
osdMonitorLabeler = new OsdMonitorLabeler.OsdMonitorLabeler();
|
2012-05-16 22:59:02 +00:00
|
|
|
overview = new Overview.Overview();
|
2017-11-07 14:40:51 +00:00
|
|
|
kbdA11yDialog = new KbdA11yDialog.KbdA11yDialog();
|
2012-11-30 00:27:16 +00:00
|
|
|
wm = new WindowManager.WindowManager();
|
2010-07-21 08:44:59 +00:00
|
|
|
magnifier = new Magnifier.Magnifier();
|
2019-06-29 12:30:23 +00:00
|
|
|
locatePointer = new LocatePointer.LocatePointer();
|
2019-02-20 09:12:36 +00:00
|
|
|
|
2013-03-04 18:20:12 +00:00
|
|
|
if (LoginManager.canLock())
|
2012-07-08 15:42:15 +00:00
|
|
|
screenShield = new ScreenShield.ScreenShield();
|
2013-02-17 04:28:29 +00:00
|
|
|
|
2017-12-05 19:05:00 +00:00
|
|
|
inputMethod = new InputMethod.InputMethod();
|
|
|
|
Clutter.get_default_backend().set_input_method(inputMethod);
|
2023-03-24 10:26:49 +00:00
|
|
|
global.connect('shutdown',
|
|
|
|
() => Clutter.get_default_backend().set_input_method(null));
|
2017-12-05 19:05:00 +00:00
|
|
|
|
2022-02-08 16:13:25 +00:00
|
|
|
screenshotUI = new Screenshot.ScreenshotUI();
|
|
|
|
|
2010-02-02 15:21:47 +00:00
|
|
|
messageTray = new MessageTray.MessageTray();
|
2015-02-11 19:41:56 +00:00
|
|
|
panel = new Panel.Panel();
|
2019-08-28 21:52:52 +00:00
|
|
|
keyboard = new Keyboard.KeyboardManager();
|
2010-01-13 20:05:20 +00:00
|
|
|
notificationDaemon = new NotificationDaemon.NotificationDaemon();
|
2010-02-22 18:53:41 +00:00
|
|
|
windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();
|
2012-09-03 01:23:50 +00:00
|
|
|
componentManager = new Components.ComponentManager();
|
2011-01-31 17:48:18 +00:00
|
|
|
|
2018-09-05 09:15:30 +00:00
|
|
|
introspectService = new Introspect.IntrospectService();
|
|
|
|
|
2011-09-01 17:35:15 +00:00
|
|
|
layoutManager.init();
|
2011-08-24 01:53:02 +00:00
|
|
|
overview.init();
|
2009-03-13 21:14:31 +00:00
|
|
|
|
2019-08-19 19:38:51 +00:00
|
|
|
new PointerA11yTimeout.PointerA11yTimeout();
|
2019-03-20 16:46:12 +00:00
|
|
|
|
2019-02-20 09:12:36 +00:00
|
|
|
global.connect('locate-pointer', () => {
|
|
|
|
locatePointer.show();
|
|
|
|
});
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
global.display.connect('show-restart-message', (display, message) => {
|
2014-05-08 22:56:23 +00:00
|
|
|
showRestartMessage(message);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
global.display.connect('restart', () => {
|
2014-05-08 22:56:23 +00:00
|
|
|
global.reexec_self();
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2016-06-03 13:20:20 +00:00
|
|
|
global.display.connect('gl-video-memory-purged', loadTheme);
|
|
|
|
|
2021-11-23 19:19:14 +00:00
|
|
|
global.context.connect('notify::unsafe-mode', () => {
|
|
|
|
if (!global.context.unsafe_mode)
|
|
|
|
return; // we're safe
|
|
|
|
if (lookingGlass?.isOpen)
|
|
|
|
return; // assume user action
|
|
|
|
|
|
|
|
const source = new MessageTray.SystemNotificationSource();
|
|
|
|
messageTray.add(source);
|
|
|
|
const notification = new MessageTray.Notification(source,
|
|
|
|
_('System was put in unsafe mode'),
|
2022-12-16 21:33:10 +00:00
|
|
|
_('Apps now have unrestricted access'));
|
2021-11-23 19:19:14 +00:00
|
|
|
notification.addAction(_('Undo'),
|
|
|
|
() => (global.context.unsafe_mode = false));
|
|
|
|
notification.setTransient(true);
|
|
|
|
source.showNotification(notification);
|
|
|
|
});
|
|
|
|
|
2011-01-06 15:30:15 +00:00
|
|
|
// Provide the bus object for gnome-session to
|
|
|
|
// initiate logouts.
|
|
|
|
EndSessionDialog.init();
|
|
|
|
|
2013-02-28 15:43:39 +00:00
|
|
|
// We're ready for the session manager to move to the next phase
|
2019-10-04 11:11:06 +00:00
|
|
|
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
|
|
|
|
Shell.util_sd_notify();
|
2021-07-15 17:46:47 +00:00
|
|
|
global.context.notify_ready();
|
2019-10-04 11:11:06 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
|
|
|
});
|
2013-02-28 15:43:39 +00:00
|
|
|
|
2011-08-24 01:53:02 +00:00
|
|
|
_startDate = new Date();
|
2009-08-28 19:11:25 +00:00
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
ExtensionDownloader.init();
|
2019-03-07 00:45:45 +00:00
|
|
|
extensionManager = new ExtensionSystem.ExtensionManager();
|
2019-07-07 21:38:27 +00:00
|
|
|
extensionManager.init();
|
2013-02-14 03:45:43 +00:00
|
|
|
|
2013-03-06 23:01:12 +00:00
|
|
|
if (sessionMode.isGreeter && screenShield) {
|
2017-10-31 00:38:18 +00:00
|
|
|
layoutManager.connect('startup-prepared', () => {
|
2013-03-06 23:01:12 +00:00
|
|
|
screenShield.showDialog();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-07-06 01:08:09 +00:00
|
|
|
let Scripting;
|
2023-02-02 15:01:43 +00:00
|
|
|
let perfModule;
|
2023-06-13 01:53:32 +00:00
|
|
|
const {automationScript} = global;
|
|
|
|
if (automationScript) {
|
2023-07-06 01:08:09 +00:00
|
|
|
Scripting = await import('./scripting.js');
|
2023-06-13 01:53:32 +00:00
|
|
|
perfModule = await import(automationScript.get_uri());
|
2023-02-02 15:01:43 +00:00
|
|
|
if (perfModule.init)
|
|
|
|
perfModule.init();
|
|
|
|
}
|
|
|
|
|
2017-10-31 00:38:18 +00:00
|
|
|
layoutManager.connect('startup-complete', () => {
|
2023-08-07 00:51:19 +00:00
|
|
|
if (actionMode === Shell.ActionMode.NONE)
|
2014-12-11 14:35:40 +00:00
|
|
|
actionMode = Shell.ActionMode.NORMAL;
|
2019-08-20 00:51:42 +00:00
|
|
|
|
|
|
|
if (screenShield)
|
2014-09-05 00:55:05 +00:00
|
|
|
screenShield.lockIfWasLocked();
|
2019-08-20 00:51:42 +00:00
|
|
|
|
2023-08-07 00:51:19 +00:00
|
|
|
if (sessionMode.currentMode !== 'gdm' &&
|
|
|
|
sessionMode.currentMode !== 'initial-setup') {
|
2019-06-15 12:48:58 +00:00
|
|
|
GLib.log_structured(LOG_DOMAIN, GLib.LogLevelFlags.LEVEL_MESSAGE, {
|
2022-02-07 14:14:06 +00:00
|
|
|
'MESSAGE': `GNOME Shell started at ${_startDate}`,
|
2019-08-20 21:43:54 +00:00
|
|
|
'MESSAGE_ID': GNOMESHELL_STARTED_MESSAGE_ID,
|
2019-06-15 12:48:58 +00:00
|
|
|
});
|
2014-09-05 00:55:05 +00:00
|
|
|
}
|
2019-03-05 18:31:01 +00:00
|
|
|
|
2023-02-02 15:01:43 +00:00
|
|
|
if (!perfModule) {
|
2022-11-28 15:44:18 +00:00
|
|
|
let credentials = new Gio.Credentials();
|
|
|
|
if (credentials.get_unix_user() === 0) {
|
|
|
|
notify(
|
|
|
|
_('Logged in as a privileged user'),
|
|
|
|
_('Running a session as a privileged user should be avoided for security reasons. If possible, you should log in as a normal user.'));
|
|
|
|
} else if (sessionMode.showWelcomeDialog) {
|
|
|
|
_handleShowWelcomeScreen();
|
|
|
|
}
|
2013-06-08 17:32:35 +00:00
|
|
|
}
|
|
|
|
|
2013-06-08 17:33:58 +00:00
|
|
|
if (sessionMode.currentMode !== 'gdm' &&
|
2020-03-20 11:42:04 +00:00
|
|
|
sessionMode.currentMode !== 'initial-setup')
|
|
|
|
_handleLockScreenWarning();
|
2013-06-08 17:33:58 +00:00
|
|
|
|
2019-05-02 09:49:12 +00:00
|
|
|
LoginManager.registerSessionWithGDM();
|
|
|
|
|
2023-02-02 15:01:43 +00:00
|
|
|
if (perfModule) {
|
2023-08-06 22:34:20 +00:00
|
|
|
let perfOutput = GLib.getenv('SHELL_PERF_OUTPUT');
|
2023-02-02 15:01:43 +00:00
|
|
|
Scripting.runPerfScript(perfModule, perfOutput);
|
2019-03-05 18:31:01 +00:00
|
|
|
}
|
2014-09-05 00:55:05 +00:00
|
|
|
});
|
2011-01-25 21:29:45 +00:00
|
|
|
}
|
|
|
|
|
2021-02-01 12:31:41 +00:00
|
|
|
function _handleShowWelcomeScreen() {
|
|
|
|
const lastShownVersion = global.settings.get_string(WELCOME_DIALOG_LAST_SHOWN_VERSION);
|
|
|
|
if (Util.GNOMEversionCompare(WELCOME_DIALOG_LAST_TOUR_CHANGE, lastShownVersion) > 0) {
|
|
|
|
openWelcomeDialog();
|
|
|
|
global.settings.set_string(WELCOME_DIALOG_LAST_SHOWN_VERSION, Config.PACKAGE_VERSION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-20 11:42:04 +00:00
|
|
|
async function _handleLockScreenWarning() {
|
2022-02-07 14:14:06 +00:00
|
|
|
const path = `${global.userdatadir}/lock-warning-shown`;
|
2020-03-20 11:42:04 +00:00
|
|
|
const file = Gio.File.new_for_path(path);
|
|
|
|
|
|
|
|
const hasLockScreen = screenShield !== null;
|
|
|
|
if (hasLockScreen) {
|
|
|
|
try {
|
|
|
|
await file.delete_async(0, null);
|
|
|
|
} catch (e) {
|
|
|
|
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.NOT_FOUND))
|
|
|
|
logError(e);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
if (!await file.touch_async())
|
|
|
|
return;
|
|
|
|
} catch (e) {
|
|
|
|
logError(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
notify(
|
|
|
|
_('Screen Lock disabled'),
|
|
|
|
_('Screen Locking requires the GNOME display manager.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-29 13:37:19 +00:00
|
|
|
function _getStylesheet(name) {
|
2014-10-15 05:25:30 +00:00
|
|
|
let stylesheet;
|
|
|
|
|
2022-02-07 14:14:06 +00:00
|
|
|
stylesheet = Gio.File.new_for_uri(`resource:///org/gnome/shell/theme/${name}`);
|
2014-10-15 05:25:30 +00:00
|
|
|
if (stylesheet.query_exists(null))
|
|
|
|
return stylesheet;
|
|
|
|
|
2018-03-30 07:44:14 +00:00
|
|
|
let dataDirs = GLib.get_system_data_dirs();
|
|
|
|
for (let i = 0; i < dataDirs.length; i++) {
|
|
|
|
let path = GLib.build_filenamev([dataDirs[i], 'gnome-shell', 'theme', name]);
|
2019-08-20 00:20:08 +00:00
|
|
|
stylesheet = Gio.file_new_for_path(path);
|
2018-03-30 07:44:14 +00:00
|
|
|
if (stylesheet.query_exists(null))
|
|
|
|
return stylesheet;
|
|
|
|
}
|
|
|
|
|
2022-02-07 14:14:06 +00:00
|
|
|
stylesheet = Gio.File.new_for_path(`${global.datadir}/theme/${name}`);
|
2014-10-15 05:25:30 +00:00
|
|
|
if (stylesheet.query_exists(null))
|
|
|
|
return stylesheet;
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-06-03 15:21:08 +00:00
|
|
|
/** @returns {string} */
|
2023-07-10 09:53:00 +00:00
|
|
|
export function getStyleVariant() {
|
2022-06-03 15:21:08 +00:00
|
|
|
const {colorScheme} = St.Settings.get();
|
|
|
|
switch (sessionMode.colorScheme) {
|
|
|
|
case 'force-dark':
|
|
|
|
return 'dark';
|
|
|
|
case 'force-light':
|
|
|
|
return 'light';
|
|
|
|
case 'prefer-dark':
|
|
|
|
return colorScheme === St.SystemColorScheme.PREFER_LIGHT
|
|
|
|
? 'light' : 'dark';
|
|
|
|
case 'prefer-light':
|
|
|
|
return colorScheme === St.SystemColorScheme.PREFER_DARK
|
|
|
|
? 'dark' : 'light';
|
|
|
|
default:
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-29 13:37:19 +00:00
|
|
|
function _getDefaultStylesheet() {
|
|
|
|
let stylesheet = null;
|
|
|
|
let name = sessionMode.stylesheetName;
|
2013-02-05 03:13:44 +00:00
|
|
|
|
2021-12-19 16:29:51 +00:00
|
|
|
// Look for a high-contrast variant first
|
|
|
|
if (St.Settings.get().high_contrast)
|
2014-11-29 13:37:19 +00:00
|
|
|
stylesheet = _getStylesheet(name.replace('.css', '-high-contrast.css'));
|
|
|
|
|
2022-06-03 15:21:08 +00:00
|
|
|
if (stylesheet === null)
|
|
|
|
stylesheet = _getStylesheet(name.replace('.css', `-${getStyleVariant()}.css`));
|
|
|
|
|
2014-11-29 13:37:19 +00:00
|
|
|
if (stylesheet == null)
|
2022-06-03 15:21:08 +00:00
|
|
|
stylesheet = _getStylesheet(name);
|
2014-11-29 13:37:19 +00:00
|
|
|
|
|
|
|
return stylesheet;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _loadDefaultStylesheet() {
|
2014-10-15 05:25:30 +00:00
|
|
|
let stylesheet = _getDefaultStylesheet();
|
2014-09-19 02:22:02 +00:00
|
|
|
if (_defaultCssStylesheet && _defaultCssStylesheet.equal(stylesheet))
|
2013-02-05 03:13:44 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
_defaultCssStylesheet = stylesheet;
|
|
|
|
loadTheme();
|
|
|
|
}
|
|
|
|
|
2023-08-10 19:49:19 +00:00
|
|
|
function _loadWorkspacesAdjustment() {
|
|
|
|
const {workspaceManager} = global;
|
|
|
|
const activeWorkspaceIndex = workspaceManager.get_active_workspace_index();
|
|
|
|
|
|
|
|
_workspacesAdjustment = new St.Adjustment({
|
|
|
|
value: activeWorkspaceIndex,
|
|
|
|
lower: 0,
|
|
|
|
page_increment: 1,
|
|
|
|
page_size: 1,
|
|
|
|
step_increment: 0,
|
|
|
|
upper: workspaceManager.n_workspaces,
|
|
|
|
});
|
|
|
|
|
|
|
|
workspaceManager.bind_property('n-workspaces',
|
|
|
|
_workspacesAdjustment, 'upper',
|
|
|
|
GObject.BindingFlags.SYNC_CREATE);
|
|
|
|
|
|
|
|
_workspacesAdjustment.connect('notify::upper', () => {
|
|
|
|
const newActiveIndex = workspaceManager.get_active_workspace_index();
|
|
|
|
|
|
|
|
// A workspace might have been inserted or removed before the active
|
|
|
|
// one, causing the adjustment to go out of sync, so update the value
|
|
|
|
_workspacesAdjustment.remove_transition('value');
|
|
|
|
_workspacesAdjustment.value = newActiveIndex;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an adjustment that has its lower, upper, and value
|
|
|
|
* properties set for the number of available workspaces. Consumers
|
|
|
|
* of the returned adjustment must only change the 'value' property,
|
|
|
|
* and only that.
|
|
|
|
*
|
|
|
|
* @param {Clutter.Actor} actor
|
|
|
|
*
|
|
|
|
* @returns {St.Adjustment} - an adjustment representing the
|
|
|
|
* current workspaces layout
|
|
|
|
*/
|
|
|
|
export function createWorkspacesAdjustment(actor) {
|
|
|
|
const adjustment = new St.Adjustment({actor});
|
|
|
|
|
|
|
|
const properties = [
|
|
|
|
['lower', GObject.BindingFlags.SYNC_CREATE],
|
|
|
|
['page-increment', GObject.BindingFlags.SYNC_CREATE],
|
|
|
|
['page-size', GObject.BindingFlags.SYNC_CREATE],
|
|
|
|
['step-increment', GObject.BindingFlags.SYNC_CREATE],
|
|
|
|
['upper', GObject.BindingFlags.SYNC_CREATE],
|
|
|
|
['value', GObject.BindingFlags.SYNC_CREATE | GObject.BindingFlags.BIDIRECTIONAL],
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const [propName, flags] of properties)
|
|
|
|
_workspacesAdjustment.bind_property(propName, adjustment, propName, flags);
|
|
|
|
|
|
|
|
return adjustment;
|
|
|
|
}
|
|
|
|
|
2011-01-11 11:15:26 +00:00
|
|
|
/**
|
2011-02-01 14:44:15 +00:00
|
|
|
* Get the theme CSS file that the shell will load
|
|
|
|
*
|
2019-10-17 16:41:52 +00:00
|
|
|
* @returns {?Gio.File}: A #GFile that contains the theme CSS,
|
2011-02-01 14:44:15 +00:00
|
|
|
* null if using the default
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function getThemeStylesheet() {
|
2011-02-01 15:11:00 +00:00
|
|
|
return _cssStylesheet;
|
2011-02-01 14:44:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-01-11 11:15:26 +00:00
|
|
|
* Set the theme CSS file that the shell will load
|
2023-08-07 01:15:51 +00:00
|
|
|
*
|
|
|
|
* @param {string=} cssStylesheet - A file path that contains the theme CSS,
|
|
|
|
* set it to null to use the default
|
2011-01-11 11:15:26 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function setThemeStylesheet(cssStylesheet) {
|
2014-11-27 14:24:49 +00:00
|
|
|
_cssStylesheet = cssStylesheet ? Gio.File.new_for_path(cssStylesheet) : null;
|
2011-01-11 11:15:26 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export function reloadThemeResource() {
|
2015-10-21 17:27:19 +00:00
|
|
|
if (_themeResource)
|
|
|
|
_themeResource._unregister();
|
|
|
|
|
2022-02-07 14:14:06 +00:00
|
|
|
_themeResource = Gio.Resource.load(
|
|
|
|
`${global.datadir}/${sessionMode.themeResourceName}`);
|
2015-10-21 17:27:19 +00:00
|
|
|
_themeResource._register();
|
|
|
|
}
|
|
|
|
|
2022-01-31 15:10:58 +00:00
|
|
|
/** @private */
|
|
|
|
function _loadIcons() {
|
2022-02-07 14:14:06 +00:00
|
|
|
_iconResource = Gio.Resource.load(`${global.datadir}/gnome-shell-icons.gresource`);
|
2022-01-31 15:10:58 +00:00
|
|
|
_iconResource._register();
|
|
|
|
}
|
|
|
|
|
2017-08-10 19:27:25 +00:00
|
|
|
function _loadOskLayouts() {
|
2022-02-07 14:14:06 +00:00
|
|
|
_oskResource = Gio.Resource.load(`${global.datadir}/gnome-shell-osk-layouts.gresource`);
|
2017-08-10 19:27:25 +00:00
|
|
|
_oskResource._register();
|
|
|
|
}
|
|
|
|
|
2011-01-04 19:30:03 +00:00
|
|
|
/**
|
|
|
|
* loadTheme:
|
|
|
|
*
|
2011-01-11 11:15:26 +00:00
|
|
|
* Reloads the theme CSS file
|
2011-01-04 19:30:03 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function loadTheme() {
|
2019-08-19 17:55:49 +00:00
|
|
|
let themeContext = St.ThemeContext.get_for_stage(global.stage);
|
2011-06-02 15:05:08 +00:00
|
|
|
let previousTheme = themeContext.get_theme();
|
2011-01-11 11:15:26 +00:00
|
|
|
|
2019-08-19 17:55:49 +00:00
|
|
|
let theme = new St.Theme({
|
|
|
|
application_stylesheet: _cssStylesheet,
|
2019-08-20 21:43:54 +00:00
|
|
|
default_stylesheet: _defaultCssStylesheet,
|
2019-08-19 17:55:49 +00:00
|
|
|
});
|
2011-06-02 15:05:08 +00:00
|
|
|
|
2018-08-15 01:33:13 +00:00
|
|
|
if (theme.default_stylesheet == null)
|
2022-02-07 14:14:06 +00:00
|
|
|
throw new Error(`No valid stylesheet found for '${sessionMode.stylesheetName}'`);
|
2018-08-15 01:33:13 +00:00
|
|
|
|
2011-06-02 15:05:08 +00:00
|
|
|
if (previousTheme) {
|
|
|
|
let customStylesheets = previousTheme.get_custom_stylesheets();
|
|
|
|
|
|
|
|
for (let i = 0; i < customStylesheets.length; i++)
|
|
|
|
theme.load_stylesheet(customStylesheets[i]);
|
|
|
|
}
|
|
|
|
|
2019-08-19 17:55:49 +00:00
|
|
|
themeContext.set_theme(theme);
|
2011-01-04 19:30:03 +00:00
|
|
|
}
|
|
|
|
|
2011-07-28 18:06:24 +00:00
|
|
|
/**
|
2023-07-30 12:56:59 +00:00
|
|
|
* @param {string} msg A message
|
|
|
|
* @param {string} details Additional information
|
2011-07-28 18:06:24 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function notify(msg, details) {
|
2011-07-28 18:06:24 +00:00
|
|
|
let source = new MessageTray.SystemNotificationSource();
|
|
|
|
messageTray.add(source);
|
|
|
|
let notification = new MessageTray.Notification(source, msg, details);
|
|
|
|
notification.setTransient(true);
|
2019-05-13 21:32:31 +00:00
|
|
|
source.showNotification(notification);
|
2011-07-28 18:06:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-15 22:31:16 +00:00
|
|
|
/**
|
|
|
|
* See shell_global_notify_problem().
|
2023-08-07 01:15:51 +00:00
|
|
|
*
|
|
|
|
* @param {string} msg - An error message
|
|
|
|
* @param {string} details - Additional information
|
2011-03-15 22:31:16 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function notifyError(msg, details) {
|
2011-03-15 22:31:16 +00:00
|
|
|
// Also print to stderr so it's logged somewhere
|
|
|
|
if (details)
|
2019-09-02 14:44:37 +00:00
|
|
|
console.warn(`error: ${msg}: ${details}`);
|
2011-03-15 22:31:16 +00:00
|
|
|
else
|
2019-09-02 14:44:37 +00:00
|
|
|
console.warn(`error: ${msg}`);
|
2011-03-15 22:31:16 +00:00
|
|
|
|
2011-07-28 18:06:24 +00:00
|
|
|
notify(msg, details);
|
2011-03-15 22:31:16 +00:00
|
|
|
}
|
|
|
|
|
2022-01-29 00:14:56 +00:00
|
|
|
/**
|
2023-08-07 01:15:51 +00:00
|
|
|
* @private
|
2022-01-29 00:14:56 +00:00
|
|
|
* @param {Clutter.Grab} grab - grab
|
|
|
|
*/
|
2021-11-25 09:49:42 +00:00
|
|
|
function _findModal(grab) {
|
2009-09-15 19:53:07 +00:00
|
|
|
for (let i = 0; i < modalActorFocusStack.length; i++) {
|
2021-11-25 09:49:42 +00:00
|
|
|
if (modalActorFocusStack[i].grab === grab)
|
2009-09-15 19:53:07 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure we are in a mode where all keyboard and mouse input goes to
|
2010-11-03 17:30:08 +00:00
|
|
|
* the stage, and focus @actor. Multiple calls to this function act in
|
|
|
|
* a stacking fashion; the effect will be undone when an equal number
|
|
|
|
* of popModal() invocations have been made.
|
2009-09-15 19:53:07 +00:00
|
|
|
*
|
2010-11-03 17:30:08 +00:00
|
|
|
* Next, record the current Clutter keyboard focus on a stack. If the
|
|
|
|
* modal stack returns to this actor, reset the focus to the actor
|
|
|
|
* which was focused at the time pushModal() was invoked.
|
2009-09-16 15:37:51 +00:00
|
|
|
*
|
2023-08-07 01:15:51 +00:00
|
|
|
* `params` may be used to provide the following parameters:
|
2012-08-10 15:54:39 +00:00
|
|
|
* - timestamp: used to associate the call with a specific user initiated
|
2019-06-26 10:54:09 +00:00
|
|
|
* event. If not provided then the value of
|
2012-08-10 15:54:39 +00:00
|
|
|
* global.get_current_time() is assumed.
|
2010-10-20 19:08:14 +00:00
|
|
|
*
|
2012-08-10 15:54:39 +00:00
|
|
|
* - options: Meta.ModalOptions flags to indicate that the pointer is
|
|
|
|
* already grabbed
|
2011-10-21 07:12:17 +00:00
|
|
|
*
|
2014-12-11 14:35:40 +00:00
|
|
|
* - actionMode: used to set the current Shell.ActionMode to filter
|
2019-06-26 10:54:09 +00:00
|
|
|
* global keybindings; the default of NONE will filter
|
|
|
|
* out all keybindings
|
2012-08-10 18:35:59 +00:00
|
|
|
*
|
2023-08-07 01:15:51 +00:00
|
|
|
* @param {Clutter.Actor} actor - actor which will be given keyboard focus
|
|
|
|
* @param {object=} params - optional parameters
|
|
|
|
* @returns {Clutter.Grab} - the grab handle created
|
2009-09-15 19:53:07 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function pushModal(actor, params) {
|
2020-03-29 21:51:13 +00:00
|
|
|
params = Params.parse(params, {
|
|
|
|
timestamp: global.get_current_time(),
|
|
|
|
options: 0,
|
|
|
|
actionMode: Shell.ActionMode.NONE,
|
|
|
|
});
|
2010-10-20 19:08:14 +00:00
|
|
|
|
2021-11-17 23:36:44 +00:00
|
|
|
let grab = global.stage.grab(actor);
|
|
|
|
|
|
|
|
if (modalCount === 0)
|
2018-01-03 07:55:38 +00:00
|
|
|
Meta.disable_unredirect_for_display(global.display);
|
2009-09-16 15:37:51 +00:00
|
|
|
|
2009-09-15 19:53:07 +00:00
|
|
|
modalCount += 1;
|
2017-10-31 00:38:18 +00:00
|
|
|
let actorDestroyId = actor.connect('destroy', () => {
|
2021-11-25 09:49:42 +00:00
|
|
|
let index = _findModal(grab);
|
2009-09-15 19:53:07 +00:00
|
|
|
if (index >= 0)
|
2021-11-25 09:49:42 +00:00
|
|
|
popModal(grab);
|
2009-09-15 19:53:07 +00:00
|
|
|
});
|
2013-01-02 14:13:24 +00:00
|
|
|
|
|
|
|
let prevFocus = global.stage.get_key_focus();
|
|
|
|
let prevFocusDestroyId;
|
|
|
|
if (prevFocus != null) {
|
2017-10-31 00:38:18 +00:00
|
|
|
prevFocusDestroyId = prevFocus.connect('destroy', () => {
|
2020-04-28 21:26:11 +00:00
|
|
|
const index = modalActorFocusStack.findIndex(
|
|
|
|
record => record.prevFocus === prevFocus);
|
|
|
|
|
2009-09-15 19:53:07 +00:00
|
|
|
if (index >= 0)
|
2013-01-02 14:13:24 +00:00
|
|
|
modalActorFocusStack[index].prevFocus = null;
|
2009-09-15 19:53:07 +00:00
|
|
|
});
|
|
|
|
}
|
2020-03-29 21:51:13 +00:00
|
|
|
modalActorFocusStack.push({
|
|
|
|
actor,
|
2021-11-17 23:36:44 +00:00
|
|
|
grab,
|
|
|
|
destroyId: actorDestroyId,
|
|
|
|
prevFocus,
|
|
|
|
prevFocusDestroyId,
|
|
|
|
actionMode,
|
|
|
|
});
|
2008-11-24 19:07:18 +00:00
|
|
|
|
2014-12-11 14:35:40 +00:00
|
|
|
actionMode = params.actionMode;
|
2010-11-03 17:30:08 +00:00
|
|
|
global.stage.set_key_focus(actor);
|
2021-11-25 09:49:42 +00:00
|
|
|
return grab;
|
2008-10-31 23:09:46 +00:00
|
|
|
}
|
|
|
|
|
2009-09-15 19:53:07 +00:00
|
|
|
/**
|
2019-06-26 10:54:09 +00:00
|
|
|
* Reverse the effect of pushModal(). If this invocation is undoing
|
2009-09-15 19:53:07 +00:00
|
|
|
* the topmost invocation, then the focus will be restored to the
|
|
|
|
* previous focus at the time when pushModal() was invoked.
|
2010-10-20 19:08:14 +00:00
|
|
|
*
|
2023-08-07 01:15:51 +00:00
|
|
|
* `timestamp` is optionally used to associate the call with a specific user
|
2019-06-26 10:54:09 +00:00
|
|
|
* initiated event. If not provided then the value of
|
2010-10-20 19:08:14 +00:00
|
|
|
* global.get_current_time() is assumed.
|
2023-08-07 01:15:51 +00:00
|
|
|
*
|
|
|
|
* @param {Clutter.Grab} grab - the grab given by pushModal()
|
|
|
|
* @param {number=} timestamp - optional timestamp
|
2009-09-15 19:53:07 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function popModal(grab, timestamp) {
|
2023-08-07 00:51:19 +00:00
|
|
|
if (timestamp === undefined)
|
2010-10-20 19:08:14 +00:00
|
|
|
timestamp = global.get_current_time();
|
|
|
|
|
2021-11-25 09:49:42 +00:00
|
|
|
let focusIndex = _findModal(grab);
|
2011-02-24 22:29:20 +00:00
|
|
|
if (focusIndex < 0) {
|
|
|
|
global.stage.set_key_focus(null);
|
2014-12-11 14:35:40 +00:00
|
|
|
actionMode = Shell.ActionMode.NORMAL;
|
2011-02-24 22:29:20 +00:00
|
|
|
|
|
|
|
throw new Error('incorrect pop');
|
|
|
|
}
|
|
|
|
|
|
|
|
modalCount -= 1;
|
|
|
|
|
|
|
|
let record = modalActorFocusStack[focusIndex];
|
|
|
|
record.actor.disconnect(record.destroyId);
|
|
|
|
|
2021-11-25 09:49:42 +00:00
|
|
|
record.grab.dismiss();
|
2021-11-17 23:36:44 +00:00
|
|
|
|
2023-08-07 00:51:19 +00:00
|
|
|
if (focusIndex === modalActorFocusStack.length - 1) {
|
2013-01-02 14:13:24 +00:00
|
|
|
if (record.prevFocus)
|
|
|
|
record.prevFocus.disconnect(record.prevFocusDestroyId);
|
2014-12-11 14:35:40 +00:00
|
|
|
actionMode = record.actionMode;
|
2013-01-02 14:13:24 +00:00
|
|
|
global.stage.set_key_focus(record.prevFocus);
|
2011-02-24 22:29:20 +00:00
|
|
|
} else {
|
2013-01-02 14:19:41 +00:00
|
|
|
// If we have:
|
|
|
|
// global.stage.set_focus(a);
|
|
|
|
// Main.pushModal(b);
|
|
|
|
// Main.pushModal(c);
|
|
|
|
// Main.pushModal(d);
|
|
|
|
//
|
|
|
|
// then we have the stack:
|
|
|
|
// [{ prevFocus: a, actor: b },
|
|
|
|
// { prevFocus: b, actor: c },
|
|
|
|
// { prevFocus: c, actor: d }]
|
|
|
|
//
|
|
|
|
// When actor c is destroyed/popped, if we only simply remove the
|
|
|
|
// record, then the focus stack will be [a, c], rather than the correct
|
|
|
|
// [a, b]. Shift the focus stack up before removing the record to ensure
|
|
|
|
// that we get the correct result.
|
2011-02-24 22:29:20 +00:00
|
|
|
let t = modalActorFocusStack[modalActorFocusStack.length - 1];
|
2013-01-02 14:13:24 +00:00
|
|
|
if (t.prevFocus)
|
|
|
|
t.prevFocus.disconnect(t.prevFocusDestroyId);
|
2011-02-24 22:29:20 +00:00
|
|
|
// Remove from the middle, shift the focus chain up
|
|
|
|
for (let i = modalActorFocusStack.length - 1; i > focusIndex; i--) {
|
2013-01-02 14:13:24 +00:00
|
|
|
modalActorFocusStack[i].prevFocus = modalActorFocusStack[i - 1].prevFocus;
|
|
|
|
modalActorFocusStack[i].prevFocusDestroyId = modalActorFocusStack[i - 1].prevFocusDestroyId;
|
2014-12-11 14:35:40 +00:00
|
|
|
modalActorFocusStack[i].actionMode = modalActorFocusStack[i - 1].actionMode;
|
2009-09-15 19:53:07 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-24 22:29:20 +00:00
|
|
|
modalActorFocusStack.splice(focusIndex, 1);
|
|
|
|
|
2009-09-15 19:53:07 +00:00
|
|
|
if (modalCount > 0)
|
|
|
|
return;
|
|
|
|
|
2014-09-20 00:54:31 +00:00
|
|
|
layoutManager.modalEnded();
|
2018-01-03 07:55:38 +00:00
|
|
|
Meta.enable_unredirect_for_display(global.display);
|
2014-12-11 14:35:40 +00:00
|
|
|
actionMode = Shell.ActionMode.NORMAL;
|
2008-10-31 04:22:44 +00:00
|
|
|
}
|
2008-11-24 19:07:18 +00:00
|
|
|
|
2023-07-30 12:56:59 +00:00
|
|
|
/**
|
|
|
|
* Creates the looking glass panel
|
|
|
|
*
|
|
|
|
* @returns {LookingGlass.LookingGlass}
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function createLookingGlass() {
|
2019-08-20 00:51:42 +00:00
|
|
|
if (lookingGlass == null)
|
2009-08-02 07:46:01 +00:00
|
|
|
lookingGlass = new LookingGlass.LookingGlass();
|
2019-08-20 00:51:42 +00:00
|
|
|
|
2009-08-02 07:46:01 +00:00
|
|
|
return lookingGlass;
|
|
|
|
}
|
|
|
|
|
2023-07-30 12:56:59 +00:00
|
|
|
/**
|
|
|
|
* Opens the run dialog
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function openRunDialog() {
|
2019-08-20 00:51:42 +00:00
|
|
|
if (runDialog == null)
|
2009-09-14 19:08:20 +00:00
|
|
|
runDialog = new RunDialog.RunDialog();
|
2019-08-20 00:51:42 +00:00
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
runDialog.open();
|
2009-09-14 19:08:20 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
export function openWelcomeDialog() {
|
2021-02-01 09:20:48 +00:00
|
|
|
if (welcomeDialog === null)
|
|
|
|
welcomeDialog = new WelcomeDialog.WelcomeDialog();
|
|
|
|
|
|
|
|
welcomeDialog.open();
|
|
|
|
}
|
|
|
|
|
2009-09-21 20:29:37 +00:00
|
|
|
/**
|
|
|
|
* activateWindow:
|
2023-07-30 12:56:59 +00:00
|
|
|
*
|
|
|
|
* @param {Meta.Window} window the window to activate
|
|
|
|
* @param {number=} time current event time
|
|
|
|
* @param {number=} workspaceNum window's workspace number
|
2009-09-21 20:29:37 +00:00
|
|
|
*
|
2010-02-17 19:05:06 +00:00
|
|
|
* Activates @window, switching to its workspace first if necessary,
|
|
|
|
* and switching out of the overview if it's currently active
|
2009-09-21 20:29:37 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function activateWindow(window, time, workspaceNum) {
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspaceManager = global.workspace_manager;
|
|
|
|
let activeWorkspaceNum = workspaceManager.get_active_workspace_index();
|
2019-08-19 19:38:51 +00:00
|
|
|
let windowWorkspaceNum = workspaceNum !== undefined ? workspaceNum : window.get_workspace().index();
|
2009-09-21 20:29:37 +00:00
|
|
|
|
|
|
|
if (!time)
|
2009-12-03 20:59:52 +00:00
|
|
|
time = global.get_current_time();
|
2009-09-21 20:29:37 +00:00
|
|
|
|
2023-08-07 00:51:19 +00:00
|
|
|
if (windowWorkspaceNum !== activeWorkspaceNum) {
|
2018-01-03 07:55:38 +00:00
|
|
|
let workspace = workspaceManager.get_workspace_by_index(windowWorkspaceNum);
|
2009-09-21 20:29:37 +00:00
|
|
|
workspace.activate_with_focus(window, time);
|
|
|
|
} else {
|
|
|
|
window.activate(time);
|
|
|
|
}
|
2010-02-17 19:05:06 +00:00
|
|
|
|
|
|
|
overview.hide();
|
2015-02-23 12:02:08 +00:00
|
|
|
panel.closeCalendar();
|
2009-09-21 20:29:37 +00:00
|
|
|
}
|
2009-12-03 17:19:38 +00:00
|
|
|
|
2022-03-31 14:59:49 +00:00
|
|
|
/**
|
|
|
|
* Move @window to the specified monitor and workspace.
|
|
|
|
*
|
|
|
|
* @param {Meta.Window} window - the window to move
|
|
|
|
* @param {number} monitorIndex - the requested monitor
|
|
|
|
* @param {number} workspaceIndex - the requested workspace
|
|
|
|
* @param {bool} append - create workspace if it doesn't exist
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function moveWindowToMonitorAndWorkspace(window, monitorIndex, workspaceIndex, append = false) {
|
2022-03-31 14:59:49 +00:00
|
|
|
// We need to move the window before changing the workspace, because
|
|
|
|
// the move itself could cause a workspace change if the window enters
|
|
|
|
// the primary monitor
|
|
|
|
if (window.get_monitor() !== monitorIndex) {
|
|
|
|
// Wait for the monitor change to take effect
|
|
|
|
const id = global.display.connect('window-entered-monitor',
|
|
|
|
(dsp, num, w) => {
|
|
|
|
if (w !== window)
|
|
|
|
return;
|
|
|
|
window.change_workspace_by_index(workspaceIndex, append);
|
|
|
|
global.display.disconnect(id);
|
|
|
|
});
|
|
|
|
window.move_to_monitor(monitorIndex);
|
|
|
|
} else {
|
|
|
|
window.change_workspace_by_index(workspaceIndex, append);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-03 17:19:38 +00:00
|
|
|
// TODO - replace this timeout with some system to guess when the user might
|
|
|
|
// be e.g. just reading the screen and not likely to interact.
|
2023-07-10 09:53:00 +00:00
|
|
|
const DEFERRED_TIMEOUT_SECONDS = 20;
|
|
|
|
let _deferredWorkData = {};
|
2009-12-03 17:19:38 +00:00
|
|
|
// Work scheduled for some point in the future
|
2023-07-10 09:53:00 +00:00
|
|
|
let _deferredWorkQueue = [];
|
2009-12-03 17:19:38 +00:00
|
|
|
// Work we need to process before the next redraw
|
2023-07-10 09:53:00 +00:00
|
|
|
let _beforeRedrawQueue = [];
|
2009-12-03 17:19:38 +00:00
|
|
|
// Counter to assign work ids
|
2023-07-10 09:53:00 +00:00
|
|
|
let _deferredWorkSequence = 0;
|
|
|
|
let _deferredTimeoutId = 0;
|
2009-12-03 17:19:38 +00:00
|
|
|
|
|
|
|
function _runDeferredWork(workId) {
|
|
|
|
if (!_deferredWorkData[workId])
|
|
|
|
return;
|
|
|
|
let index = _deferredWorkQueue.indexOf(workId);
|
|
|
|
if (index < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_deferredWorkQueue.splice(index, 1);
|
|
|
|
_deferredWorkData[workId].callback();
|
2023-08-07 00:51:19 +00:00
|
|
|
if (_deferredWorkQueue.length === 0 && _deferredTimeoutId > 0) {
|
2019-08-19 18:50:33 +00:00
|
|
|
GLib.source_remove(_deferredTimeoutId);
|
2009-12-03 17:19:38 +00:00
|
|
|
_deferredTimeoutId = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _runAllDeferredWork() {
|
|
|
|
while (_deferredWorkQueue.length > 0)
|
|
|
|
_runDeferredWork(_deferredWorkQueue[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _runBeforeRedrawQueue() {
|
|
|
|
for (let i = 0; i < _beforeRedrawQueue.length; i++) {
|
|
|
|
let workId = _beforeRedrawQueue[i];
|
|
|
|
_runDeferredWork(workId);
|
|
|
|
}
|
|
|
|
_beforeRedrawQueue = [];
|
|
|
|
}
|
|
|
|
|
|
|
|
function _queueBeforeRedraw(workId) {
|
|
|
|
_beforeRedrawQueue.push(workId);
|
2023-08-07 00:51:19 +00:00
|
|
|
if (_beforeRedrawQueue.length === 1) {
|
2022-09-07 18:23:38 +00:00
|
|
|
const laters = global.compositor.get_laters();
|
|
|
|
laters.add(Meta.LaterType.BEFORE_REDRAW, () => {
|
2009-12-03 17:19:38 +00:00
|
|
|
_runBeforeRedrawQueue();
|
|
|
|
return false;
|
2010-04-12 22:05:50 +00:00
|
|
|
});
|
2009-12-03 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function sets up a callback to be invoked when either the
|
|
|
|
* given actor is mapped, or after some period of time when the machine
|
2019-06-26 10:54:09 +00:00
|
|
|
* is idle. This is useful if your actor isn't always visible on the
|
2009-12-03 17:19:38 +00:00
|
|
|
* screen (for example, all actors in the overview), and you don't want
|
|
|
|
* to consume resources updating if the actor isn't actually going to be
|
|
|
|
* displaying to the user.
|
|
|
|
*
|
|
|
|
* Note that queueDeferredWork is called by default immediately on
|
|
|
|
* initialization as well, under the assumption that new actors
|
|
|
|
* will need it.
|
|
|
|
*
|
2023-08-07 01:15:51 +00:00
|
|
|
* @param {Clutter.Actor} actor - an actor
|
|
|
|
* @param {callback} callback - Function to invoke to perform work
|
|
|
|
*
|
|
|
|
* @returns {string} - A string work identifier
|
2009-12-03 17:19:38 +00:00
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function initializeDeferredWork(actor, callback) {
|
2009-12-03 17:19:38 +00:00
|
|
|
// Turn into a string so we can use as an object property
|
2022-02-07 14:14:06 +00:00
|
|
|
let workId = `${++_deferredWorkSequence}`;
|
2020-03-29 21:51:13 +00:00
|
|
|
_deferredWorkData[workId] = {
|
|
|
|
actor,
|
|
|
|
callback,
|
|
|
|
};
|
2017-10-31 00:38:18 +00:00
|
|
|
actor.connect('notify::mapped', () => {
|
2018-07-14 20:56:22 +00:00
|
|
|
if (!(actor.mapped && _deferredWorkQueue.includes(workId)))
|
2009-12-03 17:19:38 +00:00
|
|
|
return;
|
|
|
|
_queueBeforeRedraw(workId);
|
|
|
|
});
|
2017-10-31 00:38:18 +00:00
|
|
|
actor.connect('destroy', () => {
|
2009-12-03 17:19:38 +00:00
|
|
|
let index = _deferredWorkQueue.indexOf(workId);
|
|
|
|
if (index >= 0)
|
|
|
|
_deferredWorkQueue.splice(index, 1);
|
|
|
|
delete _deferredWorkData[workId];
|
|
|
|
});
|
|
|
|
queueDeferredWork(workId);
|
|
|
|
return workId;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* queueDeferredWork:
|
2023-07-30 12:56:59 +00:00
|
|
|
*
|
|
|
|
* @param {string} workId work identifier
|
2009-12-03 17:19:38 +00:00
|
|
|
*
|
|
|
|
* Ensure that the work identified by @workId will be
|
2019-06-26 10:54:09 +00:00
|
|
|
* run on map or timeout. You should call this function
|
2009-12-03 17:19:38 +00:00
|
|
|
* for example when data being displayed by the actor has
|
|
|
|
* changed.
|
|
|
|
*/
|
2023-07-10 09:53:00 +00:00
|
|
|
export function queueDeferredWork(workId) {
|
2009-12-03 17:19:38 +00:00
|
|
|
let data = _deferredWorkData[workId];
|
|
|
|
if (!data) {
|
2022-02-07 14:14:06 +00:00
|
|
|
let message = `Invalid work id ${workId}`;
|
2012-05-10 01:37:42 +00:00
|
|
|
logError(new Error(message), message);
|
2009-12-03 17:19:38 +00:00
|
|
|
return;
|
|
|
|
}
|
2018-07-14 20:56:22 +00:00
|
|
|
if (!_deferredWorkQueue.includes(workId))
|
2009-12-03 17:19:38 +00:00
|
|
|
_deferredWorkQueue.push(workId);
|
|
|
|
if (data.actor.mapped) {
|
|
|
|
_queueBeforeRedraw(workId);
|
2023-08-07 00:51:19 +00:00
|
|
|
} else if (_deferredTimeoutId === 0) {
|
2019-08-19 18:50:33 +00:00
|
|
|
_deferredTimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, DEFERRED_TIMEOUT_SECONDS, () => {
|
2009-12-03 17:19:38 +00:00
|
|
|
_runAllDeferredWork();
|
|
|
|
_deferredTimeoutId = 0;
|
2013-11-29 00:45:39 +00:00
|
|
|
return GLib.SOURCE_REMOVE;
|
2009-12-03 17:19:38 +00:00
|
|
|
});
|
2014-04-10 17:26:52 +00:00
|
|
|
GLib.Source.set_name_by_id(_deferredTimeoutId, '[gnome-shell] _runAllDeferredWork');
|
2009-12-03 17:19:38 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-08 22:56:23 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
const RestartMessage = GObject.registerClass(
|
2019-05-23 20:45:44 +00:00
|
|
|
class RestartMessage extends ModalDialog.ModalDialog {
|
|
|
|
_init(message) {
|
2020-03-29 21:51:13 +00:00
|
|
|
super._init({
|
|
|
|
shellReactive: true,
|
|
|
|
styleClass: 'restart-message headline',
|
|
|
|
shouldFadeIn: false,
|
|
|
|
destroyOnClose: true,
|
|
|
|
});
|
2014-05-08 22:56:23 +00:00
|
|
|
|
2019-10-21 18:44:00 +00:00
|
|
|
let label = new St.Label({
|
|
|
|
text: message,
|
|
|
|
x_align: Clutter.ActorAlign.CENTER,
|
|
|
|
y_align: Clutter.ActorAlign.CENTER,
|
|
|
|
});
|
2014-05-08 22:56:23 +00:00
|
|
|
|
2019-10-21 18:44:00 +00:00
|
|
|
this.contentLayout.add_child(label);
|
2014-05-08 22:56:23 +00:00
|
|
|
this.buttonLayout.hide();
|
|
|
|
}
|
2019-05-23 20:45:44 +00:00
|
|
|
});
|
2014-05-08 22:56:23 +00:00
|
|
|
|
|
|
|
function showRestartMessage(message) {
|
|
|
|
let restartMessage = new RestartMessage(message);
|
|
|
|
restartMessage.open();
|
|
|
|
}
|
2019-10-01 10:02:31 +00:00
|
|
|
|
2023-07-10 09:53:00 +00:00
|
|
|
class AnimationsSettings {
|
2019-10-01 10:02:31 +00:00
|
|
|
constructor() {
|
2022-11-29 15:33:34 +00:00
|
|
|
this._animationsEnabled = true;
|
|
|
|
this._handles = new Set();
|
2019-10-01 10:03:52 +00:00
|
|
|
|
2022-11-29 15:33:34 +00:00
|
|
|
global.connect('notify::force-animations',
|
|
|
|
this._syncAnimationsEnabled.bind(this));
|
|
|
|
this._syncAnimationsEnabled();
|
|
|
|
|
|
|
|
const backend = global.backend;
|
|
|
|
const remoteAccessController = backend.get_remote_access_controller();
|
|
|
|
if (remoteAccessController) {
|
|
|
|
remoteAccessController.connect('new-handle',
|
|
|
|
(_, handle) => this._onNewRemoteAccessHandle(handle));
|
2019-10-01 10:03:52 +00:00
|
|
|
}
|
2022-11-29 15:33:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_shouldEnableAnimations() {
|
|
|
|
if (this._handles.size > 0)
|
|
|
|
return false;
|
2019-10-01 10:04:52 +00:00
|
|
|
|
2022-11-29 15:33:34 +00:00
|
|
|
if (global.force_animations)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
const backend = global.backend;
|
|
|
|
if (!backend.is_rendering_hardware_accelerated())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (Shell.util_has_x11_display_extension(
|
|
|
|
global.display, 'VNC-EXTENSION'))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_syncAnimationsEnabled() {
|
|
|
|
const shouldEnableAnimations = this._shouldEnableAnimations();
|
|
|
|
if (this._animationsEnabled === shouldEnableAnimations)
|
2019-10-01 10:04:52 +00:00
|
|
|
return;
|
2023-03-17 00:05:48 +00:00
|
|
|
this._animationsEnabled = shouldEnableAnimations;
|
2019-10-01 10:04:52 +00:00
|
|
|
|
2022-11-29 15:33:34 +00:00
|
|
|
const settings = St.Settings.get();
|
|
|
|
if (shouldEnableAnimations)
|
|
|
|
settings.uninhibit_animations();
|
|
|
|
else
|
|
|
|
settings.inhibit_animations();
|
2019-10-01 10:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onRemoteAccessHandleStopped(handle) {
|
|
|
|
this._handles.delete(handle);
|
2022-11-29 15:33:34 +00:00
|
|
|
this._syncAnimationsEnabled();
|
2019-10-01 10:04:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_onNewRemoteAccessHandle(handle) {
|
|
|
|
if (!handle.get_disable_animations())
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._handles.add(handle);
|
2022-11-29 15:33:34 +00:00
|
|
|
this._syncAnimationsEnabled();
|
2019-10-01 10:04:52 +00:00
|
|
|
handle.connect('stopped', this._onRemoteAccessHandleStopped.bind(this));
|
2019-10-01 10:02:31 +00:00
|
|
|
}
|
2023-07-10 09:53:00 +00:00
|
|
|
}
|