Finish the surrounding text implementation

This is just a request for comment as there is a memory management issue in the code which I don't understand (see the inline comment in `qtim/ibus-input-context.cpp`).