From 772df9176291e9fcc3497d053bb739b02483e4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 21 Apr 2020 18:04:56 +0200 Subject: [PATCH] shell/global: Add 'backend' property Replace all Meta.get_backend() with global.backend. Maybe sooner or later we can further decrease the amount of singletons handled by libmutter. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1210 --- js/misc/keyboardManager.js | 6 +++--- js/ui/keyboard.js | 2 +- js/ui/main.js | 2 +- js/ui/status/remoteAccess.js | 3 +-- js/ui/xdndHandler.js | 4 ++-- src/shell-global.c | 13 +++++++++++++ 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/js/misc/keyboardManager.js b/js/misc/keyboardManager.js index 0b56bee3d..29fc3b761 100644 --- a/js/misc/keyboardManager.js +++ b/js/misc/keyboardManager.js @@ -1,7 +1,7 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- /* exported getKeyboardManager, holdKeyboard, releaseKeyboard */ -const { GLib, GnomeDesktop, Meta } = imports.gi; +const { GLib, GnomeDesktop } = imports.gi; const Main = imports.ui.main; @@ -62,11 +62,11 @@ var KeyboardManager = class { return; this._currentKeymap = { layouts, variants, options }; - Meta.get_backend().set_keymap(layouts, variants, options); + global.backend.set_keymap(layouts, variants, options); } _applyLayoutGroupIndex(idx) { - Meta.get_backend().lock_layout_group(idx); + global.backend.lock_layout_group(idx); } apply(id) { diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index 149bafd42..56479a1b7 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -1119,7 +1119,7 @@ var KeyboardManager = class KeyBoardManager { this._seat.connect('notify::touch-mode', this._syncEnabled.bind(this)); this._lastDevice = null; - Meta.get_backend().connect('last-device-changed', (backend, device) => { + global.backend.connect('last-device-changed', (backend, device) => { if (device.device_type === Clutter.InputDeviceType.KEYBOARD_DEVICE) return; diff --git a/js/ui/main.js b/js/ui/main.js index f1f069af4..bdd93ae1b 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -802,7 +802,7 @@ function showRestartMessage(message) { var AnimationsSettings = class { constructor() { - let backend = Meta.get_backend(); + let backend = global.backend; if (!backend.is_rendering_hardware_accelerated()) { St.Settings.get().inhibit_animations(); return; diff --git a/js/ui/status/remoteAccess.js b/js/ui/status/remoteAccess.js index 0bacb73db..09b8fd8c9 100644 --- a/js/ui/status/remoteAccess.js +++ b/js/ui/status/remoteAccess.js @@ -11,8 +11,7 @@ class RemoteAccessApplet extends PanelMenu.SystemIndicator { _init() { super._init(); - let backend = Meta.get_backend(); - let controller = backend.get_remote_access_controller(); + let controller = global.backend.get_remote_access_controller(); if (!controller) return; diff --git a/js/ui/xdndHandler.js b/js/ui/xdndHandler.js index 5b95fa8f6..13d012dec 100644 --- a/js/ui/xdndHandler.js +++ b/js/ui/xdndHandler.js @@ -1,6 +1,6 @@ // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- -const { Clutter, Meta } = imports.gi; +const { Clutter } = imports.gi; const Signals = imports.signals; const DND = imports.ui.dnd; @@ -17,7 +17,7 @@ var XdndHandler = class { Main.uiGroup.add_actor(this._dummy); this._dummy.hide(); - var dnd = Meta.get_backend().get_dnd(); + var dnd = global.backend.get_dnd(); dnd.connect('dnd-enter', this._onEnter.bind(this)); dnd.connect('dnd-position-change', this._onPositionChanged.bind(this)); dnd.connect('dnd-leave', this._onLeave.bind(this)); diff --git a/src/shell-global.c b/src/shell-global.c index e70677775..6ad7a6673 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -57,6 +57,7 @@ struct _ShellGlobal { ClutterStage *stage; + MetaBackend *backend; MetaDisplay *meta_display; MetaWorkspaceManager *workspace_manager; Display *xdisplay; @@ -95,6 +96,7 @@ enum { PROP_0, PROP_SESSION_MODE, + PROP_BACKEND, PROP_DISPLAY, PROP_WORKSPACE_MANAGER, PROP_SCREEN_WIDTH, @@ -230,6 +232,9 @@ shell_global_get_property(GObject *object, case PROP_SESSION_MODE: g_value_set_string (value, shell_global_get_session_mode (global)); break; + case PROP_BACKEND: + g_value_set_object (value, global->backend); + break; case PROP_DISPLAY: g_value_set_object (value, global->meta_display); break; @@ -472,6 +477,13 @@ shell_global_class_init (ShellGlobalClass *klass) "Screen height, in pixels", 0, G_MAXINT, 1, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, + PROP_BACKEND, + g_param_spec_object ("backend", + "Backend", + "MetaBackend object", + META_TYPE_BACKEND, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_DISPLAY, g_param_spec_object ("display", @@ -947,6 +959,7 @@ _shell_global_set_plugin (ShellGlobal *global, g_return_if_fail (SHELL_IS_GLOBAL (global)); g_return_if_fail (global->plugin == NULL); + global->backend = meta_get_backend (); global->plugin = plugin; global->wm = shell_wm_new (plugin);