visibility: Stop calling GTK functions from the visibility manager
The viibility manager state is changed from various handlers, which are not guaranteed to be reentrant, most notably the Wayland handler for preedit done. As the state is changed, relevant requests to synchronize user-visible UI are fired from the same handler.
In case of imservice_handle_done, GTK widget show function was being called, which triggered another round of handling Wayland, leading to the done handler being called again, and flaking out.
To solve this, the phase of issuing commands needs to be separate from adjusting desired state. It seems that the easiest solution is to delay the show() and hide() calls into the next GTK main loop spin.
A better solution would probably inject itself directly after the change of desired state, so that all the side effects are delayed.