I don't remember a discussion when the new event type MX_REPLY was
added, so I will tell my observations now.
At the very first I thought, why do we need this event type when we
already have M_STRING. But of course the answer is clear. When a module
requests SendToModule back, then the event is sent to 0 upto N modules,
and when it requests Send_Reply instead then it is sent exactly to one
module, to itself.
So a module should usually avoid the SendToModule technique in favor of
Send_Reply. Of course, anywhere outside the module, SendToModule is
still currently the only way to communicate.
There are several interesting use cases for Send_Reply:
1) To ask fvwm to expand internal fvwm variables or translations:
Send_Reply $[version.num]; $[schedule.last]; $[gt.Refresh Screen]
2) To ask fvwm to select a window for a module to operate on:
Pick Send_Reply set_window
or:
WindowList SortByResource, NoGeometry, NoDeskSort, NoHotkeys, \
NoCurrentDeskTitle, Function 'Send_Reply set_window'
Of course both Pick and WindowList may be canceled by pressing Escape
or by a mouse and then the function is not called. So for this to work,
a module should also send: "Send_Reply end" to receive it for sure.
Both of these select-window techniques are used in FvwmGtkDebug, this
actually works well.
However, there is still one case when the module can't avoid
SendToModule, when it asks fvwm to alarm itself in 10 seconds:
Schedule 10000 898989 SendToModule ModuleNameOrAlias alarm
Unfortunately this does not currently work:
Schedule 10000 898989 Send_Reply alarm
I think this is quite useful and may be considered as a bug. I'll see
how to fix this use case in Schedule.
Maybe later we should have a module context just like a window context,
anywhere, not only in Schedule. So even if there are several modules of
the same name running, it would be still possible to target the correct
one. Think ModuleId (WindowId), $[module.id] ($[w.id]), NextModule
(Next), AllModules (All) and so on. Then "SendToModule ModuleName"
would be just another way to say "AllModules (ModuleName) Send_Reply".
This is not a complete proposal, just a material to think. After 2.6.
Regards,
Mikhael.