Open vadz opened 1 year ago
I have code which works but it's somewhat annoying is that we need to subscribe to a DBUS signal in any case, whether we need to do it or not, as we don't know if anybody going to be interested in these notifications or not.
I wonder if we should add some way to opt-in into the generation of these events under Linux. We could use OnDynamicBind()
to do it by default when using Bind()
to connect the handlers, but it would need to be called manually when using event tables.
Or am I overthinking this and it's not a big deal to call g_dbus_connection_signal_subscribe()
on startup of all wx programs?
Hmm, seeing that we now call g_dbus_proxy_new_for_bus_sync()
unconditionally in 9b9ec141fbcd604aa8bfc83da6f16fc9bf5c32e0 it looks like @paulcor doesn't consider it to be a problem to do this unconditionally. The code there uses G_BUS_TYPE_SESSION
while I need G_BUS_TYPE_SYSTEM
, but I guess it should be fine to connect to the latter as well.
I measured the time for the g_dbus_proxy_new_for_bus_sync()
plus g_dbus_proxy_call_sync()
, it was around 0.015s. Kind of a lot of processor time, but not detectable in human time. I judged it acceptable.
Thanks for measuring it! I admit I didn't bother doing it because I thought my results wouldn't be really representative: I have a fast and mostly idle machine, while I'd be worried about it taking more time on slower and busier ones. And I also worry that adding small delays on startup may be imperceptible for each individual one but become noticeable as they add up. But, again, I'm probably worrying too much...
As mentioned in a comment on another PR, I've measured time-to-first-paint for wxGTK on my system as 60ms, so 15ms spent on these calls is 25% of the total.
So I don't think I'm worrying too much, finally, and I think it would be worth delaying these calls until they're really needed.
I just re-checked the time for the g_dbus_proxy
calls, and I apparently missed a zero, it's more like 0.0015s for X11 and 0.0007s for Wayland.
Oh, good, thanks. I shouldn't have worried, finally.
It would be nice to have
wxEVT_POWER_XXX
events under Linux and it looks like D-Bus provides the signals we need to do it.Some links for future reference: