Fix algorithm dead keys
This commit is contained in:
parent
a902aab7a9
commit
9dd3ddc854
277
ibus-HEAD.patch
277
ibus-HEAD.patch
@ -2343,3 +2343,280 @@ index fa0c9b40..1b815345 100644
|
||||
--
|
||||
2.33.1
|
||||
|
||||
From 19377ad22d8145ea431e5de51f047061c98f8d21 Mon Sep 17 00:00:00 2001
|
||||
From: fujiwarat <takao.fujiwara1@gmail.com>
|
||||
Date: Tue, 1 Mar 2022 18:26:21 +0900
|
||||
Subject: [PATCH] src/ibuscompose: Check algorithm dead key by 9 length
|
||||
|
||||
This change fixes the D-Bus timeout by a long compose preedit text.
|
||||
check_normalize_nfc() calculates the factorical of the compse preedit
|
||||
length and assigne the value to an INT variable and it could excceed
|
||||
the MAX_INT.
|
||||
Probably I think the length of the compose algorizhm dead key would be
|
||||
enough 9. I.e. 9! == 46320 <= SHRT_MAX == 32767
|
||||
|
||||
BUG=https://github.com/ibus/ibus/issues/2385
|
||||
---
|
||||
src/ibuscomposetable.c | 35 +++++++++++++++++++++++------------
|
||||
1 file changed, 23 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c
|
||||
index 250e0139..387a24a8 100644
|
||||
--- a/src/ibuscomposetable.c
|
||||
+++ b/src/ibuscomposetable.c
|
||||
@@ -1,7 +1,7 @@
|
||||
/* -*- mode: C; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
|
||||
/* ibus - The Input Bus
|
||||
* Copyright (C) 2013-2014 Peng Huang <shawn.p.huang@gmail.com>
|
||||
- * Copyright (C) 2013-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||||
+ * Copyright (C) 2013-2022 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -46,6 +46,7 @@
|
||||
#define IBUS_COMPOSE_TABLE_MAGIC "IBusComposeTable"
|
||||
#define IBUS_COMPOSE_TABLE_VERSION (4)
|
||||
#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"
|
||||
+#define IBUS_MAX_COMPOSE_ALGORITHM_LEN 9
|
||||
|
||||
typedef struct {
|
||||
gunichar *sequence;
|
||||
@@ -1659,7 +1660,7 @@ ibus_compose_table_compact_check (const IBusComposeTableCompactEx
|
||||
static gboolean
|
||||
check_normalize_nfc (gunichar* combination_buffer, int n_compose)
|
||||
{
|
||||
- gunichar combination_buffer_temp[IBUS_MAX_COMPOSE_LEN];
|
||||
+ gunichar combination_buffer_temp[IBUS_MAX_COMPOSE_ALGORITHM_LEN + 1];
|
||||
char *combination_utf8_temp = NULL;
|
||||
char *nfc_temp = NULL;
|
||||
int n_combinations;
|
||||
@@ -1682,7 +1683,7 @@ check_normalize_nfc (gunichar* combination_buffer, int n_compose)
|
||||
|
||||
memcpy (combination_buffer_temp,
|
||||
combination_buffer,
|
||||
- IBUS_MAX_COMPOSE_LEN * sizeof (gunichar) );
|
||||
+ IBUS_MAX_COMPOSE_ALGORITHM_LEN * sizeof (gunichar) );
|
||||
|
||||
for (i = 0; i < n_combinations; i++ ) {
|
||||
g_unicode_canonical_ordering (combination_buffer_temp, n_compose);
|
||||
@@ -1694,7 +1695,7 @@ check_normalize_nfc (gunichar* combination_buffer, int n_compose)
|
||||
if (g_utf8_strlen (nfc_temp, -1) == 1) {
|
||||
memcpy (combination_buffer,
|
||||
combination_buffer_temp,
|
||||
- IBUS_MAX_COMPOSE_LEN * sizeof (gunichar) );
|
||||
+ IBUS_MAX_COMPOSE_ALGORITHM_LEN * sizeof (gunichar) );
|
||||
|
||||
g_free (combination_utf8_temp);
|
||||
g_free (nfc_temp);
|
||||
@@ -1708,14 +1709,14 @@ check_normalize_nfc (gunichar* combination_buffer, int n_compose)
|
||||
if (n_compose > 2) {
|
||||
int j = i % (n_compose - 1) + 1;
|
||||
int k = (i+1) % (n_compose - 1) + 1;
|
||||
- if (j >= IBUS_MAX_COMPOSE_LEN) {
|
||||
- g_warning ("j >= IBUS_MAX_COMPOSE_LEN for " \
|
||||
- "combination_buffer_temp");
|
||||
+ if (j >= IBUS_MAX_COMPOSE_ALGORITHM_LEN) {
|
||||
+ g_warning ("j >= %d for combination_buffer_temp",
|
||||
+ IBUS_MAX_COMPOSE_ALGORITHM_LEN);
|
||||
break;
|
||||
}
|
||||
- if (k >= IBUS_MAX_COMPOSE_LEN) {
|
||||
- g_warning ("k >= IBUS_MAX_COMPOSE_LEN for " \
|
||||
- "combination_buffer_temp");
|
||||
+ if (k >= IBUS_MAX_COMPOSE_ALGORITHM_LEN) {
|
||||
+ g_warning ("k >= %d for combination_buffer_temp",
|
||||
+ IBUS_MAX_COMPOSE_ALGORITHM_LEN);
|
||||
break;
|
||||
}
|
||||
temp_swap = combination_buffer_temp[j];
|
||||
@@ -1737,13 +1738,23 @@ ibus_check_algorithmically (const guint16 *compose_buffer,
|
||||
|
||||
{
|
||||
int i;
|
||||
- gunichar combination_buffer[IBUS_MAX_COMPOSE_LEN];
|
||||
+ gunichar combination_buffer[IBUS_MAX_COMPOSE_ALGORITHM_LEN + 1];
|
||||
char *combination_utf8, *nfc;
|
||||
|
||||
if (output_char)
|
||||
*output_char = 0;
|
||||
|
||||
- if (n_compose >= IBUS_MAX_COMPOSE_LEN)
|
||||
+ /* Check the IBUS_MAX_COMPOSE_ALGORITHM_LEN length only here instead of
|
||||
+ * IBUS_MAX_COMPOSE_LEN length.
|
||||
+ * Because this API calls check_normalize_nfc() which calculates the factorial
|
||||
+ * of `n_compose` and assigns the value to `n_combinations`.
|
||||
+ * I.e. 9! == 40320 <= SHRT_MAX == 32767
|
||||
+ * The factorial of exceeding INT_MAX spends a long time in check_normalize_nfc()
|
||||
+ * and causes a D-Bus timeout between GTK clients and IBusEngineSimple.
|
||||
+ * Currenlty IBUS_MAX_COMPOSE_LEN is much larger and supports the long compose
|
||||
+ * sequence however the max 9 would be enough for this mechanical compose.
|
||||
+ */
|
||||
+ if (n_compose > IBUS_MAX_COMPOSE_ALGORITHM_LEN)
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < n_compose && IS_DEAD_KEY (compose_buffer[i]); i++)
|
||||
--
|
||||
2.34.1
|
||||
|
||||
From df664b1f18a9c630ccd884f8ff698abf6cbb1578 Mon Sep 17 00:00:00 2001
|
||||
From: fujiwarat <takao.fujiwara1@gmail.com>
|
||||
Date: Tue, 1 Mar 2022 19:23:25 +0900
|
||||
Subject: [PATCH] src/ibusenginesimple: Support GTK4 coompose file
|
||||
|
||||
Load $XDG_CONFIG_HOME/gtk-4.0/Compose
|
||||
---
|
||||
src/ibusenginesimple.c | 27 +++++++++++++++------------
|
||||
1 file changed, 15 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c
|
||||
index a80e41a5..c57a3ea5 100644
|
||||
--- a/src/ibusenginesimple.c
|
||||
+++ b/src/ibusenginesimple.c
|
||||
@@ -1448,8 +1448,16 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
|
||||
g_free (path);
|
||||
return retval;
|
||||
}
|
||||
- g_free (path);
|
||||
- path = NULL;
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
+
|
||||
+ path = g_build_filename (g_get_user_config_dir (),
|
||||
+ "gtk-4.0", "Compose", NULL);
|
||||
+ if (g_file_test (path, G_FILE_TEST_EXISTS)) {
|
||||
+ ibus_engine_simple_add_compose_file (simple, path);
|
||||
+ g_free (path);
|
||||
+ return retval;
|
||||
+ }
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
|
||||
path = g_build_filename (g_get_user_config_dir (),
|
||||
"gtk-3.0", "Compose", NULL);
|
||||
@@ -1458,8 +1466,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
|
||||
g_free (path);
|
||||
return retval;
|
||||
}
|
||||
- g_free (path);
|
||||
- path = NULL;
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
|
||||
home = g_get_home_dir ();
|
||||
if (home == NULL)
|
||||
@@ -1471,8 +1478,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
|
||||
g_free (path);
|
||||
return retval;
|
||||
}
|
||||
- g_free (path);
|
||||
- path = NULL;
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
|
||||
#if GLIB_CHECK_VERSION (2, 58, 0)
|
||||
langs = g_get_language_names_with_category ("LC_CTYPE");
|
||||
@@ -1508,8 +1514,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
|
||||
|
||||
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
- g_free (path);
|
||||
- path = NULL;
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
}
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 58, 0)
|
||||
@@ -1518,15 +1523,13 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
|
||||
|
||||
if (path != NULL)
|
||||
ibus_engine_simple_add_compose_file (simple, path);
|
||||
- g_free (path);
|
||||
- path = NULL;
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
} else {
|
||||
path = g_build_filename (X11_DATADIR, locale, "Compose", NULL);
|
||||
do {
|
||||
if (g_file_test (path, G_FILE_TEST_EXISTS))
|
||||
break;
|
||||
- g_free (path);
|
||||
- path = NULL;
|
||||
+ g_clear_pointer(&path, g_free);
|
||||
} while (0);
|
||||
if (path == NULL)
|
||||
return retval;
|
||||
--
|
||||
2.34.1
|
||||
|
||||
From faf9f0bbb6edf6ed71bba9dcb314493f6b0276ea Mon Sep 17 00:00:00 2001
|
||||
From: fujiwarat <takao.fujiwara1@gmail.com>
|
||||
Date: Tue, 1 Mar 2022 19:44:17 +0900
|
||||
Subject: [PATCH] client/gtk2: Revert CCedilla change for pt-BR
|
||||
|
||||
gtk_im_context_simple_add_table() is deprecated in GTK4.
|
||||
I decide to delete gtk_im_context_simple_add_table() here because
|
||||
the change 03c9e591430c62354bbf26ef7bd4a2e6acfb7c8f is no longer needed
|
||||
because IBusEngineSimple has implemented to load pt_br compose key
|
||||
by locale
|
||||
|
||||
BUG=chromium-os:11421
|
||||
BUG=http://codereview.appspot.com/3989060
|
||||
---
|
||||
client/gtk2/ibusimcontext.c | 33 +--------------------------------
|
||||
1 file changed, 1 insertion(+), 32 deletions(-)
|
||||
|
||||
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
|
||||
index a5e5e792..e314ae98 100644
|
||||
--- a/client/gtk2/ibusimcontext.c
|
||||
+++ b/client/gtk2/ibusimcontext.c
|
||||
@@ -2,7 +2,7 @@
|
||||
/* vim:set et sts=4: */
|
||||
/* ibus - The Input Bus
|
||||
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
|
||||
- * Copyright (C) 2015-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||||
+ * Copyright (C) 2015-2022 Takao Fujiwara <takao.fujiwara1@gmail.com>
|
||||
* Copyright (C) 2008-2021 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@@ -874,33 +874,6 @@ ibus_im_context_class_fini (IBusIMContextClass *class)
|
||||
g_bus_unwatch_name (_daemon_name_watch_id);
|
||||
}
|
||||
|
||||
-/* Copied from gtk+2.0-2.20.1/modules/input/imcedilla.c to fix crosbug.com/11421.
|
||||
- * Overwrite the original Gtk+'s compose table in gtk+-2.x.y/gtk/gtkimcontextsimple.c. */
|
||||
-
|
||||
-/* The difference between this and the default input method is the handling
|
||||
- * of C+acute - this method produces C WITH CEDILLA rather than C WITH ACUTE.
|
||||
- * For languages that use CCedilla and not acute, this is the preferred mapping,
|
||||
- * and is particularly important for pt_BR, where the us-intl keyboard is
|
||||
- * used extensively.
|
||||
- */
|
||||
-static guint16 cedilla_compose_seqs[] = {
|
||||
-#ifdef DEPRECATED_GDK_KEYSYMS
|
||||
- GDK_dead_acute, GDK_C, 0, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_dead_acute, GDK_c, 0, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_Multi_key, GDK_apostrophe, GDK_C, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_Multi_key, GDK_apostrophe, GDK_c, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_Multi_key, GDK_C, GDK_apostrophe, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_Multi_key, GDK_c, GDK_apostrophe, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
|
||||
-#else
|
||||
- GDK_KEY_dead_acute, GDK_KEY_C, 0, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_KEY_dead_acute, GDK_KEY_c, 0, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_KEY_Multi_key, GDK_KEY_apostrophe, GDK_KEY_C, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_KEY_Multi_key, GDK_KEY_apostrophe, GDK_KEY_c, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_KEY_Multi_key, GDK_KEY_C, GDK_KEY_apostrophe, 0, 0, 0x00C7, /* LATIN_CAPITAL_LETTER_C_WITH_CEDILLA */
|
||||
- GDK_KEY_Multi_key, GDK_KEY_c, GDK_KEY_apostrophe, 0, 0, 0x00E7, /* LATIN_SMALL_LETTER_C_WITH_CEDILLA */
|
||||
-#endif
|
||||
-};
|
||||
-
|
||||
static void
|
||||
ibus_im_context_init (GObject *obj)
|
||||
{
|
||||
@@ -936,10 +909,6 @@ ibus_im_context_init (GObject *obj)
|
||||
|
||||
// Create slave im context
|
||||
ibusimcontext->slave = gtk_im_context_simple_new ();
|
||||
- gtk_im_context_simple_add_table (GTK_IM_CONTEXT_SIMPLE (ibusimcontext->slave),
|
||||
- cedilla_compose_seqs,
|
||||
- 4,
|
||||
- G_N_ELEMENTS (cedilla_compose_seqs) / (4 + 2));
|
||||
|
||||
g_signal_connect (ibusimcontext->slave,
|
||||
"commit",
|
||||
--
|
||||
2.34.1
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
Name: ibus
|
||||
Version: 1.5.25
|
||||
Release: 11%{?dist}
|
||||
Release: 12%{?dist}
|
||||
Summary: Intelligent Input Bus for Linux OS
|
||||
License: LGPLv2+
|
||||
URL: https://github.com/ibus/%name/wiki
|
||||
@ -522,6 +522,9 @@ dconf update || :
|
||||
%{_datadir}/installed-tests/ibus
|
||||
|
||||
%changelog
|
||||
* Tue Mar 01 2022 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.25-12
|
||||
- Fix algorithm dead keys
|
||||
|
||||
* Mon Feb 21 2022 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.25-11
|
||||
- Fix forwarding keycode in GTK4
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user