Skip to content

Commit

Permalink
appIndicator: Try to introspect the application for Activate method s…
Browse files Browse the repository at this point in the history
…upport

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.
  • Loading branch information
3v1n0 committed Apr 18, 2024
1 parent b5b9331 commit 305b9bf
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions appIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 305b9bf

Please sign in to comment.