invoke #im-focus-out-handler when switching #im or #state

When switching #im or #state, the current pre-edit window still works,
and that will break some applications (Skype). See theslinux bugs#138.
The crash can be reproduced as below

* Switch to a non-direct im, like #m17n-telex
* Type something and be in a pre-edit phase
* Press ^-Alt-Space to toggle the state of #im
* Press Backspace twice
* Press End (to simulate a Commit event)
* Enjoy the crash

We can avoid this, by force #im to invoke #im-focus-out-handler, to
commit or cancel everything in the pre-edit window before switching.
Depends on the #im, a #commit or a #cancel event is generated. For
example, when toggling, #xtelex commits, but #m17n-telex cancels.

This is only work-around, but I think this is naturally enough.

Please note that the global Cancel (Super Escape) is similar.
However, Super-Escape is generated, both #m17n-telex and #xtelex
will commit the keys. As far as I understand, Super-Escape will
invoke a method from #generic-proc-off-mode (generic.scm). However,
this method can not be invoked within #im.scm. So, KISS.