Wouldn't it be better to go through a cbEvent, anyway?
So yes - that's the way to go. If you want to, to can try to design/implement a SDK event accordingly and provide a patch. It shouldn't be too hard. This would mean a change of the SDK API... just for the record.
Here is the patch against trunk... it provides two events:
- cbEVT_APP_ACTIVATED: triggered when the C::B window gets the focus
- cbEVT_APP_DEACTIVATED: triggered when the C::B window looses the focus
I've tested them here with my "Save all editors when loosing focus" plugin (still a work in progress, but as soon as it becomes stable, I'll also post-it here) and everything works fine.
I'd really appreciate if you could consider this to go into the "official" C::B. ;-)