← Back to team overview

dbusmenu-list team mailing list archive

Proposal for aboutToShow() implementation

 

Hi,

As you (probably) know, Qt provides a way for menus to be populated on
the fly: when a menu is about to be displayed, QMenu emits the
aboutToShow() signal. Any slot connected to this signal can manipulate
the menu content before it actually gets shown.

We need a way to implement this in dbusmenu without introducing latency.
Here is my proposal for this:

Add a "bool aboutToShow(id)" method to the DBus interface. This method
would be called when the menu is about to show and should return true if
the menu needs to be refreshed, false otherwise.

The calling sequence would be as described in attached diagram.

In the most common case (no update), this solution only introduces at
worst a 10 msecs delay (in case the DBus answer to aboutToShow() does
not come back before the timeout).

I am just wondering whether it would make sense to receive the updated
items as an out argument in aboutToShow(). Ie, aboutToShow() could have
this signature:

bool
aboutToShow(/* in */  uint id,
            /* in */  array<string> propertyNames,
            /* out */ DBusMenuItemList* menuItems)

(The menuItems argument would only be used if aboutToShow returns true)
This would avoid a separate DBus call in the Refresh state.

What do you think about this?

Aurélien

PNG image


Follow ups