diff --git a/ibus-HEAD.patch b/ibus-HEAD.patch index dc9f150..53cd713 100644 --- a/ibus-HEAD.patch +++ b/ibus-HEAD.patch @@ -4435,3 +4435,94 @@ index f8dced6b..92464234 100755 -- 2.35.3 +From d47dbfada41aa4fb5df9f7cffe873786fc4849cc Mon Sep 17 00:00:00 2001 +From: fujiwarat +Date: Mon, 25 Jul 2022 17:22:21 +0900 +Subject: [PATCH] client/x11: Enhance Xutf8TextListToTextProperty + +XCompoundTextStyle depends on the current locale and some locales fail +to to get the compound text style. +If Xutf8TextListToTextProperty() fails, now ibus-x11 tries to get +the compound text style with UTF-8 encoding. + +BUG=https://github.com/ibus/ibus/issues/2422 +--- + client/x11/main.c | 41 ++++++++++++++++++++++++++++++++++------- + 1 file changed, 34 insertions(+), 7 deletions(-) + +diff --git a/client/x11/main.c b/client/x11/main.c +index fe30c1d6..6057cc03 100644 +--- a/client/x11/main.c ++++ b/client/x11/main.c +@@ -2,7 +2,7 @@ + /* vim:set et sts=4: */ + /* ibus + * Copyright (C) 2007-2015 Peng Huang +- * Copyright (C) 2015-2021 Takao Fujiwara ++ * Copyright (C) 2015-2022 Takao Fujiwara + * Copyright (C) 2007-2015 Red Hat, Inc. + * + * main.c: +@@ -48,6 +48,8 @@ + + #include + ++#define ESC_SEQUENCE_ISO10646_1 "\033%G" ++ + #define LOG(level, fmt_args...) \ + if (g_debug_level >= (level)) { \ + g_debug (fmt_args); \ +@@ -254,9 +256,17 @@ _xim_preedit_callback_draw (XIMS xims, X11IC *x11ic, const gchar *preedit_string + text.feedback = feedback; + + if (len > 0) { +- Xutf8TextListToTextProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), +- (char **)&preedit_string, +- 1, XCompoundTextStyle, &tp); ++ int ret = Xutf8TextListToTextProperty ( ++ GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), ++ (char **)&preedit_string, ++ 1, XCompoundTextStyle, &tp); ++ if (ret == EXIT_FAILURE) { ++ XFree (tp.value); ++ tp.value = (unsigned char *)g_strdup_printf ( ++ "%s%s", ++ ESC_SEQUENCE_ISO10646_1, ++ preedit_string); ++ } + text.encoding_is_wchar = 0; + text.length = strlen ((char*)tp.value); + text.string.multi_byte = (char*)tp.value; +@@ -883,9 +893,26 @@ _context_commit_text_cb (IBusInputContext *context, + + XTextProperty tp; + IMCommitStruct cms = {0}; +- +- Xutf8TextListToTextProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), +- (gchar **)&(text->text), 1, XCompoundTextStyle, &tp); ++ int ret; ++ ++ ret = Xutf8TextListToTextProperty ( ++ GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), ++ (gchar **)&(text->text), 1, XCompoundTextStyle, &tp); ++ /* XCompoundTextStyle uses the encoding escaped sequence + encoded chars ++ * matched to the specified multibyte characters: text->text, and ++ * libX11.so sorts the encoding sets by locale. ++ * If an encoded string fails to be matched, ibus-x11 specifies the ++ * ISO10641-1 encoding and that escaped sequence is "\033%G": ++ * https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/xlibi18n/lcCT.c ++ * , and the encoding is UTF-8 with utf8_wctomb(): ++ * https://gitlab.freedesktop.org/xorg/lib/libx11/-/blob/master/src/xlibi18n/lcUniConv/utf8.h ++ */ ++ if (ret == EXIT_FAILURE) { ++ XFree (tp.value); ++ tp.value = (unsigned char *)g_strdup_printf ("%s%s", ++ ESC_SEQUENCE_ISO10646_1, ++ text->text); ++ } + + cms.major_code = XIM_COMMIT; + cms.icid = x11ic->icid; +-- +2.35.3 + diff --git a/ibus.spec b/ibus.spec index d1dd42a..9e23198 100644 --- a/ibus.spec +++ b/ibus.spec @@ -39,7 +39,7 @@ Name: ibus Version: 1.5.26 -Release: 14%{?dist} +Release: 15%{?dist} Summary: Intelligent Input Bus for Linux OS License: LGPLv2+ URL: https://github.com/ibus/%name/wiki @@ -524,6 +524,9 @@ dconf update || : %{_datadir}/installed-tests/ibus %changelog +* Fri Jul 29 2022 Takao Fujiwara - 1.5.26-15 +- Enhance Xutf8TextListToTextProperty in ibus-x11 + * Thu Jul 21 2022 Fedora Release Engineering - 1.5.26-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild