From eaed58e93fbc2d59c618bcab98259ea9f1866983 Mon Sep 17 00:00:00 2001 From: Mathieu Bridon Date: Sun, 29 Mar 2015 17:03:59 +0200 Subject: [PATCH] Work around the candidate popup position issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some applications (most notably Firefox) fail to correctly position the candidate popup. This is because we don't use a pre-edit text at all, and it seems those applications (or maybe the toolkits?) get confused by the absence of a pre-edit text. :( This is a gross hack. The real issue needs to be fixed in the apps/toolkits, but we need to do something in the meantime, as this is just too much of a bad UX issue for us. The idea comes from FrÃdÃric Péter. Fixes #60 --- src/engine.py | 14 ++++++++++++++ tests/run_tests.in | 6 ++++++ 2 files changed, 20 insertions(+) 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):