notificationDaemon: Try harder to find a matching app

Unlike the desktop-entry hint, the app name is not optional. That
doesn't mean that we'll be able to match it to a .desktop file,
but we can at least try if we fail to match on PID or desktop-entry.

https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1291
This commit is contained in:
Florian Müllner 2020-05-29 21:51:14 +02:00 committed by Georges Basile Stavracas Neto
parent 7bbce1d5ad
commit b487846c0a

View File

@ -373,12 +373,11 @@ var FdoNotificationDaemonSource = GObject.registerClass(
class FdoNotificationDaemonSource extends MessageTray.Source { class FdoNotificationDaemonSource extends MessageTray.Source {
_init(title, pid, sender, appId) { _init(title, pid, sender, appId) {
this.pid = pid; this.pid = pid;
this.initialTitle = title;
this.app = this._getApp(appId); this.app = this._getApp(appId);
super._init(title); super._init(title);
this.initialTitle = title;
if (this.app) if (this.app)
this.title = this.app.get_name(); this.title = this.app.get_name();
else else
@ -426,19 +425,20 @@ class FdoNotificationDaemonSource extends MessageTray.Source {
} }
_getApp(appId) { _getApp(appId) {
const appSys = Shell.AppSystem.get_default();
let app; let app;
app = Shell.WindowTracker.get_default().get_app_from_pid(this.pid); app = Shell.WindowTracker.get_default().get_app_from_pid(this.pid);
if (app != null) if (app != null)
return app; return app;
if (appId) { if (appId)
app = Shell.AppSystem.get_default().lookup_app('%s.desktop'.format(appId)); app = appSys.lookup_app('%s.desktop'.format(appId));
if (app != null)
return app;
}
return null; if (!app)
app = appSys.lookup_app('%s.desktop'.format(this.initialTitle));
return app;
} }
setTitle(title) { setTitle(title) {