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
This commit is contained in:
Jonas Ådahl 2020-04-21 18:04:56 +02:00
parent c90910731f
commit 772df91762
6 changed files with 21 additions and 9 deletions

View File

@ -1,7 +1,7 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported getKeyboardManager, holdKeyboard, releaseKeyboard */ /* exported getKeyboardManager, holdKeyboard, releaseKeyboard */
const { GLib, GnomeDesktop, Meta } = imports.gi; const { GLib, GnomeDesktop } = imports.gi;
const Main = imports.ui.main; const Main = imports.ui.main;
@ -62,11 +62,11 @@ var KeyboardManager = class {
return; return;
this._currentKeymap = { layouts, variants, options }; this._currentKeymap = { layouts, variants, options };
Meta.get_backend().set_keymap(layouts, variants, options); global.backend.set_keymap(layouts, variants, options);
} }
_applyLayoutGroupIndex(idx) { _applyLayoutGroupIndex(idx) {
Meta.get_backend().lock_layout_group(idx); global.backend.lock_layout_group(idx);
} }
apply(id) { apply(id) {

View File

@ -1119,7 +1119,7 @@ var KeyboardManager = class KeyBoardManager {
this._seat.connect('notify::touch-mode', this._syncEnabled.bind(this)); this._seat.connect('notify::touch-mode', this._syncEnabled.bind(this));
this._lastDevice = null; 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) if (device.device_type === Clutter.InputDeviceType.KEYBOARD_DEVICE)
return; return;

View File

@ -802,7 +802,7 @@ function showRestartMessage(message) {
var AnimationsSettings = class { var AnimationsSettings = class {
constructor() { constructor() {
let backend = Meta.get_backend(); let backend = global.backend;
if (!backend.is_rendering_hardware_accelerated()) { if (!backend.is_rendering_hardware_accelerated()) {
St.Settings.get().inhibit_animations(); St.Settings.get().inhibit_animations();
return; return;

View File

@ -11,8 +11,7 @@ class RemoteAccessApplet extends PanelMenu.SystemIndicator {
_init() { _init() {
super._init(); super._init();
let backend = Meta.get_backend(); let controller = global.backend.get_remote_access_controller();
let controller = backend.get_remote_access_controller();
if (!controller) if (!controller)
return; return;

View File

@ -1,6 +1,6 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*- // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const { Clutter, Meta } = imports.gi; const { Clutter } = imports.gi;
const Signals = imports.signals; const Signals = imports.signals;
const DND = imports.ui.dnd; const DND = imports.ui.dnd;
@ -17,7 +17,7 @@ var XdndHandler = class {
Main.uiGroup.add_actor(this._dummy); Main.uiGroup.add_actor(this._dummy);
this._dummy.hide(); 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-enter', this._onEnter.bind(this));
dnd.connect('dnd-position-change', this._onPositionChanged.bind(this)); dnd.connect('dnd-position-change', this._onPositionChanged.bind(this));
dnd.connect('dnd-leave', this._onLeave.bind(this)); dnd.connect('dnd-leave', this._onLeave.bind(this));

View File

@ -57,6 +57,7 @@ struct _ShellGlobal {
ClutterStage *stage; ClutterStage *stage;
MetaBackend *backend;
MetaDisplay *meta_display; MetaDisplay *meta_display;
MetaWorkspaceManager *workspace_manager; MetaWorkspaceManager *workspace_manager;
Display *xdisplay; Display *xdisplay;
@ -95,6 +96,7 @@ enum {
PROP_0, PROP_0,
PROP_SESSION_MODE, PROP_SESSION_MODE,
PROP_BACKEND,
PROP_DISPLAY, PROP_DISPLAY,
PROP_WORKSPACE_MANAGER, PROP_WORKSPACE_MANAGER,
PROP_SCREEN_WIDTH, PROP_SCREEN_WIDTH,
@ -230,6 +232,9 @@ shell_global_get_property(GObject *object,
case PROP_SESSION_MODE: case PROP_SESSION_MODE:
g_value_set_string (value, shell_global_get_session_mode (global)); g_value_set_string (value, shell_global_get_session_mode (global));
break; break;
case PROP_BACKEND:
g_value_set_object (value, global->backend);
break;
case PROP_DISPLAY: case PROP_DISPLAY:
g_value_set_object (value, global->meta_display); g_value_set_object (value, global->meta_display);
break; break;
@ -472,6 +477,13 @@ shell_global_class_init (ShellGlobalClass *klass)
"Screen height, in pixels", "Screen height, in pixels",
0, G_MAXINT, 1, 0, G_MAXINT, 1,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); 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, g_object_class_install_property (gobject_class,
PROP_DISPLAY, PROP_DISPLAY,
g_param_spec_object ("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 (SHELL_IS_GLOBAL (global));
g_return_if_fail (global->plugin == NULL); g_return_if_fail (global->plugin == NULL);
global->backend = meta_get_backend ();
global->plugin = plugin; global->plugin = plugin;
global->wm = shell_wm_new (plugin); global->wm = shell_wm_new (plugin);