Skip to content

Commit

Permalink
Work around the candidate popup position issue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mathieu Bridon committed Mar 29, 2015
1 parent 1f53166 commit eaed58e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions tests/run_tests.in
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit eaed58e

Please sign in to comment.