Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new
IBUS_PREFILTER_MASK
flag which the engine can set on the state. This allows engines to prefilter events and use that to control the order of the output even if some syntethic key events get interspersed between the input.A scenario where this is necessary is in ibus-engine-keyman for applications that don't support surrounding text like Chrome/Chromium and gnome-terminal. For example with the IPA (SIL) keyboard, the users presses the 'n' key which produces 'n' output. Then the user presses ';'. The expected result is that the 'n' gets replaced by 'ŋ'. For applications that don't support surrounding text the engine has to forward a Backspace key event, followed by committing the new text 'ŋ'. However, since the key event gets processed asynchronously, it can happen that the new text gets committed before the Backspace key is processed, leading to the deletion of 'ŋ' instead of 'n'.
The
IBUS_PREFILTER_MASK
flag allows to solve this problem: when the engine receives a key press, it callsibus_engine_forward_key_event()
for the same key with theIBUS_PREFILTER_MASK
flag set. Only whenit receives a key press with the
IBUS_PREFILTER_MASK
already set it will process the key. When it generates the Backspace key event it will forward it to ibus with theIBUS_PREFILTER_MASK
flag already set. When it comes back to the engine it will be in the correct order.Since
IBUS_PREFILTER_MASK
is a flag that will only ever get set by the engine it shouldn't break any existing engines.This PR also adds
IBUS_CAP_PREFILTER
toIBusCapabilite
. This allows engines to detect whether they are dealing with an ibusversion that was compiled with prefilter support.