diff --git a/ibus-anthy-HEAD.patch b/ibus-anthy-HEAD.patch index d701cd7..e9e2d58 100644 --- a/ibus-anthy-HEAD.patch +++ b/ibus-anthy-HEAD.patch @@ -535,3 +535,231 @@ index 1a2e6fd..8665ae0 100644 -- 2.38.1 +From 7f5807eaf37d0a809807c23add3964478bfbdcbe Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Thu, 13 Jul 2023 15:06:38 +0900 +Subject: [PATCH] engine: Enable OSK mode + +Currently gnome-shell sends IBUS_CAP_OSK when OSK(On-Screen Keyboard) +is enabled in GNOME Wayland only. +However users still can type characters using the physical keyboard +while OSK is enabled so the current status is not perfect. + +But ibus-anthy now commit the preedit when a candidate is clicked +on IBus lookup table instead of the selection in the OSK mode. + +BUG=https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2415 +BUG=https://gitlab.gnome.org/GNOME/mutter/-/issues/2441 +BUG=rhbz#2015149 +--- + engine/python2/engine.py | 34 ++++++++++++++++++++++++++++------ + engine/python3/engine.py | 34 ++++++++++++++++++++++++++++------ + 2 files changed, 56 insertions(+), 12 deletions(-) + +diff --git a/engine/python2/engine.py b/engine/python2/engine.py +index 56c0cd5..4266d09 100644 +--- a/engine/python2/engine.py ++++ b/engine/python2/engine.py +@@ -150,6 +150,10 @@ class Engine(IBus.EngineSimple): + self.__prop_dict = {} + self.__input_purpose = 0 + self.__has_input_purpose = False ++ # OSK mode is designed for OSK on gnome-shell, which always shows ++ # IBus lookup window prior to the preedit and selecting a candidate ++ # causes the commmit instead of the selection. ++ self.__osk_mode = False + if hasattr(IBus, 'InputPurpose'): + self.__has_input_purpose = True + try: +@@ -805,7 +809,10 @@ class Engine(IBus.EngineSimple): + keyval = IBus.KEY_0 + else: + keyval = IBus.KEY_1 + index ++ prev_cursor_pos = self.__cursor_pos + self.__on_key_number(keyval) ++ if self.__osk_mode and prev_cursor_pos == self.__cursor_pos: ++ self.__on_key_return() + + def __commit_string(self, text): + self.__reset() +@@ -1094,6 +1101,9 @@ class Engine(IBus.EngineSimple): + self.__reset() + self.__invalidate() + ++ def do_set_capabilities(self, caps): ++ self.__osk_mode = True if caps & IBus.Capabilite.OSK else False ++ + def __destroy(self, obj): + if self.__idle_id != 0: + GLib.source_remove(self.__idle_id) +@@ -1148,7 +1158,10 @@ class Engine(IBus.EngineSimple): + else: + self.__cursor_pos = 0 + self.__fill_lookup_table() +- self.__lookup_table_visible = False ++ if self.__osk_mode: ++ self.__lookup_table_visible = True ++ else: ++ self.__lookup_table_visible = False + + def __end_anthy_convert(self): + if self.__convert_mode == CONV_MODE_OFF: +@@ -1353,7 +1366,8 @@ class Engine(IBus.EngineSimple): + self.__lookup_table.set_cursor_pos(0) + candidate = UN(self.__lookup_table.get_candidate(0).get_text()) + self.__segments[self.__cursor_pos] = 0, candidate +- self.__lookup_table_visible = False ++ if not self.__osk_mode: ++ self.__lookup_table_visible = False + elif self.__segments[self.__cursor_pos][0] != \ + NTH_UNCONVERTED_CANDIDATE: + buf = self.__context.get_segment(self.__cursor_pos, +@@ -1582,7 +1596,8 @@ class Engine(IBus.EngineSimple): + return True + + self.__cursor_pos += 1 +- self.__lookup_table_visible = False ++ if not self.__osk_mode: ++ self.__lookup_table_visible = False + self.__fill_lookup_table() + self.__invalidate() + return True +@@ -2314,7 +2329,10 @@ class Engine(IBus.EngineSimple): + self.__convert_mode = CONV_MODE_PREDICTION + self.__cursor_pos = 0 + self.__fill_lookup_table() +- self.__lookup_table_visible = False ++ if self.__osk_mode: ++ self.__lookup_table_visible = True ++ else: ++ self.__lookup_table_visible = False + self.__invalidate() + + return True +@@ -2393,7 +2411,10 @@ class Engine(IBus.EngineSimple): + self.__convert_mode = CONV_MODE_ANTHY + self.__cursor_pos = 0 + self.__fill_lookup_table() +- self.__lookup_table_visible = False ++ lf self.__osk_mode: ++ self.__lookup_table_visible = True ++ else: ++ self.__lookup_table_visible = False + self.__invalidate() + + return True +@@ -2549,7 +2570,8 @@ class Engine(IBus.EngineSimple): + index = self.__lookup_table.get_cursor_pos() + candidate = UN(self.__lookup_table.get_candidate(index).get_text()) + self.__segments[self.__cursor_pos] = index, candidate +- self.__lookup_table_visible = False ++ if not self.__osk_mode: ++ self.__lookup_table_visible = False + self.__on_key_right() + self.__invalidate() + return True +diff --git a/engine/python3/engine.py b/engine/python3/engine.py +index 2ebf894..d9013e6 100644 +--- a/engine/python3/engine.py ++++ b/engine/python3/engine.py +@@ -151,6 +151,10 @@ class Engine(IBus.EngineSimple): + self.__prop_dict = {} + self.__input_purpose = 0 + self.__has_input_purpose = False ++ # OSK mode is designed for OSK on gnome-shell, which always shows ++ # IBus lookup window prior to the preedit and selecting a candidate ++ # causes the commmit instead of the selection. ++ self.__osk_mode = False + if hasattr(IBus, 'InputPurpose'): + self.__has_input_purpose = True + try: +@@ -800,7 +804,10 @@ class Engine(IBus.EngineSimple): + keyval = IBus.KEY_0 + else: + keyval = IBus.KEY_1 + index ++ prev_cursor_pos = self.__cursor_pos + self.__on_key_number(keyval) ++ if self.__osk_mode and prev_cursor_pos == self.__cursor_pos: ++ self.__on_key_return() + + def __commit_string(self, text): + self.__reset() +@@ -1089,6 +1096,9 @@ class Engine(IBus.EngineSimple): + self.__reset() + self.__invalidate() + ++ def do_set_capabilities(self, caps): ++ self.__osk_mode = True if caps & IBus.Capabilite.OSK else False ++ + def __destroy(self, obj): + if self.__idle_id != 0: + GLib.source_remove(self.__idle_id) +@@ -1143,7 +1153,10 @@ class Engine(IBus.EngineSimple): + else: + self.__cursor_pos = 0 + self.__fill_lookup_table() +- self.__lookup_table_visible = False ++ if self.__osk_mode: ++ self.__lookup_table_visible = True ++ else: ++ self.__lookup_table_visible = False + + def __end_anthy_convert(self): + if self.__convert_mode == CONV_MODE_OFF: +@@ -1348,7 +1361,8 @@ class Engine(IBus.EngineSimple): + self.__lookup_table.set_cursor_pos(0) + candidate = self.__lookup_table.get_candidate(0).get_text() + self.__segments[self.__cursor_pos] = 0, candidate +- self.__lookup_table_visible = False ++ if not self.__osk_mode: ++ self.__lookup_table_visible = False + elif self.__segments[self.__cursor_pos][0] != \ + NTH_UNCONVERTED_CANDIDATE: + buf = self.__context.get_segment(self.__cursor_pos, +@@ -1577,7 +1591,8 @@ class Engine(IBus.EngineSimple): + return True + + self.__cursor_pos += 1 +- self.__lookup_table_visible = False ++ if not self.__osk_mode: ++ self.__lookup_table_visible = False + self.__fill_lookup_table() + self.__invalidate() + return True +@@ -2308,7 +2323,10 @@ class Engine(IBus.EngineSimple): + self.__convert_mode = CONV_MODE_PREDICTION + self.__cursor_pos = 0 + self.__fill_lookup_table() +- self.__lookup_table_visible = False ++ if self.__osk_mode: ++ self.__lookup_table_visible = True ++ else: ++ self.__lookup_table_visible = False + self.__invalidate() + + return True +@@ -2387,7 +2405,10 @@ class Engine(IBus.EngineSimple): + self.__convert_mode = CONV_MODE_ANTHY + self.__cursor_pos = 0 + self.__fill_lookup_table() +- self.__lookup_table_visible = False ++ lf self.__osk_mode: ++ self.__lookup_table_visible = True ++ else: ++ self.__lookup_table_visible = False + self.__invalidate() + + return True +@@ -2543,7 +2564,8 @@ class Engine(IBus.EngineSimple): + index = self.__lookup_table.get_cursor_pos() + candidate = self.__lookup_table.get_candidate(index).get_text() + self.__segments[self.__cursor_pos] = index, candidate +- self.__lookup_table_visible = False ++ if not self.__osk_mode: ++ self.__lookup_table_visible = False + self.__on_key_right() + self.__invalidate() + return True +-- +2.41.0 + diff --git a/ibus-anthy.spec b/ibus-anthy.spec index e6fb533..bad2c5c 100644 --- a/ibus-anthy.spec +++ b/ibus-anthy.spec @@ -18,7 +18,7 @@ Name: ibus-anthy Version: 1.5.14 -Release: 11%{?dist} +Release: 12%{?dist} Summary: The Anthy engine for IBus input platform License: GPL-2.0-or-later URL: https://github.com/ibus/ibus/wiki @@ -156,6 +156,9 @@ make -C data check %{_datadir}/installed-tests/%{name} %changelog +* Thu Jul 13 2023 Takao Fujiwara - 1.5.14-12 +- Resolves #2015149 Commit candidate text with clicking on candidate list in OSK + * Fri Feb 17 2023 Takao Fujiwara - 1.5.14-11 - Fix to load EN compose table