From 22254e2c0b3bbcc81d5e271623d9c8da39a358d5 Mon Sep 17 00:00:00 2001 From: Michael Webster Date: Sun, 12 Nov 2023 10:18:37 -0500 Subject: [PATCH] lookingGlass.js: Initialize melange interface at startup. - Prevent this initialization from launching cinnamon-looking-glass. The interface will be ready but won't actually launch the melange process until necessary. - Set up asynchronously to prevent startup delays. --- js/ui/lookingGlass.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index a4bf96d9d6..6ada0095d8 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -443,7 +443,7 @@ class Inspector { Signals.addSignalMethods(Inspector.prototype); -const dbusIFace = +const melangeIFace = ' \ \ \ @@ -451,7 +451,6 @@ const dbusIFace = \ \ \ - \ \ '; @@ -506,8 +505,6 @@ const lgIFace = \ '; -const proxy = Gio.DBusProxy.makeProxyWrapper(dbusIFace); - var Melange = class { constructor() { this.proxy = null; @@ -527,6 +524,7 @@ var Melange = class { this._dbusImpl.export(Gio.DBus.session, '/org/Cinnamon/LookingGlass'); Gio.DBus.session.own_name('org.Cinnamon.LookingGlass', Gio.BusNameOwnerFlags.REPLACE, null, null); + this.ensureProxy(); } _update_keybinding() { @@ -535,18 +533,35 @@ var Melange = class { } ensureProxy() { - if (!this.proxy) - this.proxy = new proxy(Gio.DBus.session, 'org.Cinnamon.Melange', '/org/Cinnamon/Melange'); + let nodeInfo = Gio.DBusNodeInfo.new_for_xml(melangeIFace); + + Gio.DBusProxy.new( + Gio.DBus.session, + Gio.DBusProxyFlags.DO_NOT_AUTO_START_AT_CONSTRUCTION, + nodeInfo.lookup_interface("org.Cinnamon.Melange"), + "org.Cinnamon.Melange", + "/org/Cinnamon/Melange", + "org.Cinnamon.Melange", + null, + this._onProxyReady.bind(this) + ); + } + + _onProxyReady(object, res) { + try { + this.proxy = Gio.DBusProxy.new_finish(res); + } catch (e) { + log('error creating org.Cinnamon.Melange proxy: %s'.format(e.message)); + return; + } } open() { - this.ensureProxy() this.proxy.showRemote(); this.updateVisible(); } close() { - this.ensureProxy() this.proxy.hideRemote(); this.updateVisible(); }