From 305b9bf6b80d26a722326d96776b3553d4fdf58f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 18 Apr 2024 21:05:31 +0200 Subject: [PATCH] appIndicator: Try to introspect the application for Activate method support Since its presence may lead to a delay to handle the double click, let's try to check early if the application supports it or not. --- appIndicator.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/appIndicator.js b/appIndicator.js index bbcaac6..5db4e66 100644 --- a/appIndicator.js +++ b/appIndicator.js @@ -37,6 +37,7 @@ Gio._promisify(GdkPixbuf.Pixbuf, 'get_file_info_async'); Gio._promisify(GdkPixbuf.Pixbuf, 'new_from_stream_at_scale_async', 'new_from_stream_finish'); Gio._promisify(St.IconInfo.prototype, 'load_symbolic_async'); +Gio._promisify(Gio.DBusConnection.prototype, 'call'); const MAX_UPDATE_FREQUENCY = 30; // In ms const FALLBACK_ICON_NAME = 'image-loading-symbolic'; @@ -435,6 +436,23 @@ export class AppIndicator extends Signals.EventEmitter { } } + // We try to lookup the activate method to see if the app supports it + try { + const introspectionVariant = await this._proxy.gConnection.call( + this._proxy.gNameOwner, this._proxy.gObjectPath, + 'org.freedesktop.DBus.Introspectable', 'Introspect', null, null, + Gio.DBusCallFlags.NONE, -1, cancellable); + const [introspectionXml] = introspectionVariant.deep_unpack(); + const nodeInfo = Gio.DBusNodeInfo.new_for_xml(introspectionXml); + const interfaceInfo = nodeInfo.lookup_interface(this._proxy.gInterfaceName); + this.supportsActivation = !!interfaceInfo.lookup_method('Activate'); + } catch (e) { + if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) { + Util.Logger.debug( + `${this.uniqueId}, check for Activation support: ${e.message}`); + } + } + try { this._commandLine = await Util.getProcessName(this.busName, cancellable, GLib.PRIORITY_LOW);