Since we're typically interrested in *where* (on the progress-bar) the
user clicked, we need a way to pass the clicked position to the
handler.
Normally, the on-click handler is expanded when a particle
instantiates its exposable. At this point, we (obviously) don't have
the click position.
This is solved by expanding the handler a second time, when the bar is
clicked.
Thus, the user can use the "{where}" tag in the click handler. "where"
will be expanded to a percentage value (0-100).
If a particle has an on-click handler, execute it when we receive an
ON_MOUSE_CLICK event.
This is done by first tokenizing the command string. We currently
handle one level of quotes, but no escape characters.
Then, fork(). Main process waits for child to finish. Child daemonizes
and then execvp() the tokenized argument vector.
If we have our own on_click handler, call the default
implementation. Otherwise, check which sub-particle the mouse is over,
and delegate the on_mouse() call.
This is intended to be a format-like string, with the possibility to
use tag formatters.
The expanded string will later be passed to the system() call.
For this to be doable, the bar no longer destroys the module's
exposables after rendering them. Instead, we keep them around, letting
them represent the "current" content of the bar.
Then, when we receive a mouse motion event, we can iterate the
exposables and calculate which one of them the mouse is over, and call
its on_mouse() function.
Instead, abort and join previous thread (if any), just before creating
a new one.
Abort/join the last one when destroying the module.
Note: we may end up with a dangling (non-joined) thread for a
while (for example, when state goes from playing -> paused/stopped).
It will however be joined eventually; either when state goes to
'playing' again, or when the module is destroyed.
This allows us to update the elapsed field without having to talk to
MPD.
In particular, it fixes a bug where we reported the same elapsed value
when we we're updated due to *other* modules calling bar->refresh().