Skip to content

Commit

Permalink
dbusMenu: Provide XDG Activation token on menu items activation
Browse files Browse the repository at this point in the history
Applications may want to perform actions on menu activations, so let's
provide them a token proactively.
  • Loading branch information
3v1n0 committed Sep 26, 2022
1 parent dd787fe commit d0c39f8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions dbusMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,12 @@ const MenuItemFactory = {
},

_onActivate(_item, event) {
const timestamp = event.get_time();
if (timestamp && this._dbusClient.indicator)
this._dbusClient.indicator.provideActivationToken(timestamp);

this._dbusItem.handleEvent('clicked', GLib.Variant.new('i', 0),
event.get_time());
timestamp);
},

_onPropertyChanged(dbusItem, prop, _value) {
Expand Down Expand Up @@ -728,12 +732,13 @@ const MenuUtils = {
*/
var Client = class AppIndicatorsClient {

constructor(busName, path) {
constructor(busName, path, indicator) {
this._busName = busName;
this._busPath = path;
this._client = new DBusClient(busName, path);
this._rootMenu = null; // the shell menu
this._rootItem = null; // the DbusMenuItem for the root
this.indicator = indicator;
}

get isReady() {
Expand Down Expand Up @@ -825,6 +830,7 @@ var Client = class AppIndicatorsClient {
this._client = null;
this._rootItem = null;
this._rootMenu = null;
this.indicator = null;
}
};
Signals.addSignalMethods(Client.prototype);
2 changes: 1 addition & 1 deletion indicatorStatusIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ class AppIndicatorsIndicatorStatusIcon extends BaseStatusIcon {

if (this._indicator.menuPath) {
this._menuClient = new DBusMenu.Client(this._indicator.busName,
this._indicator.menuPath);
this._indicator.menuPath, this._indicator);
this._menuClient.attachToMenu(this.menu);
}
}
Expand Down

0 comments on commit d0c39f8

Please sign in to comment.