diff --git a/src/engine.py b/src/engine.py index 799b44f..df05d25 100644 --- a/src/engine.py +++ b/src/engine.py @@ -434,6 +434,20 @@ def update_auxiliary_text(self): text = IBus.Text.new_from_string(self.current_radicals) super(Engine, self).update_auxiliary_text(text, len(self.current_radicals)>0) + # We don't use pre-edit at all for Cangjie or Quick + # + # However, some applications (most notably Firefox) fail to correctly + # position the candidate popup, as if they got confused by the absence + # of a pre-edit text. :( + # + # This is a horrible hack, but it fixes the immediate problem. + if self.current_radicals: + super(Engine, self).update_preedit_text(IBus.Text.new_from_string('\u200B'), 0, True) + + else: + super(Engine, self).update_preedit_text(IBus.Text.new_from_string(''), 0, False) + # End of the horrible workaround + def update_lookup_table(self): """Update the lookup table.""" if not self.current_input: diff --git a/tests/run_tests.in b/tests/run_tests.in index 61e42ba..76adf34 100644 --- a/tests/run_tests.in +++ b/tests/run_tests.in @@ -47,6 +47,12 @@ class MockEngine: # We don't need anything here for the unit tests pass + def update_preedit_text(self, text, cursor_pos, visible): + # We don't need anything here for the unit tests + # + # We only have this for an ugly workaround. + pass + class MockLookupTable: def __init__(self):