[core] implement set im by name if there is no focused window.

if the focus comes back to the original ic, the im will be set
eventually. this can be useful if GUI switcher grab the focus.