wayland: Restore IM state flushing before handling key events
The code that maybe flushed IM state before processing a key event became ineffective at commit 7716b62f, since the handle_event() method on MetaWaylandTextInput won't handle key events, only IM events and touch/button press events causing IM state to be committed. Basically, the events that directly change the IM state.
Move this ineffective to the the filter_event() method handling the key presses in order to let the IM maybe filter them, and handle them so that any key event that is let through (both key events previously injected by the IM, and key events that the IM chooses to ignore) will ensure that the pending IM state is flushed before the key event is handled and emitted to the client.
This brings back lost guarantees of orderly event emission when IMs alternate key events and IM actions.
Fixes: 7716b62f ("clutter: Separate ClutterInputFocus event processing and filtering") Closes: #3090 (closed)