dbusmenu-list team mailing list archive
-
dbusmenu-list team
-
Mailing list archive
-
Message #00001
Re: Proposal for aboutToShow() implementation
On Monday 04 January 2010, Aurélien Gâteau wrote:
> 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?
the latter way is perhaps less pretty (using a signal for aboutToshow() would
make a nice 1-1 correspondence) but it should significantly reduce round-trips
and that's the main thing we should look about in DBus interfaces.
it should be an async call anyways, so the "wait 10 msec and then go ahead
anyways" rule should be applied in this case too, i wonder what shouls happen
in this scenario:
the menu visualization calls aboutToshow, waits 10 msec nothing back shows the
menu
but the app was just really busy and cpuldn't answer, but it has a new menu
anyways
the host shows the old menu, maybe with entries not valid anymore
the user clicks an invalid entry...
perhaps the host should change on the fly the menu when the answer arrives
even if there was a timeout and the menu is already displayed...
Cheers,
Marco Martin
Follow ups
References