Blob Blame History Raw
From a140924e437346ebb7cd30c6e4d316ab5d447871 Mon Sep 17 00:00:00 2001
From: Simon Deziel <simon@sdeziel.info>
Date: Wed, 22 Feb 2023 19:05:17 +0900
Subject: [PATCH] src/services: use a shell exec in systemd service files

exec sub-command avoids keeping the parent shell around. Refer sh(1)
Fedora sh is bash.

BUG=https://github.com/ibus/ibus/pull/2453
---
 bus/services/org.freedesktop.IBus.session.GNOME.service.in   | 2 +-
 bus/services/org.freedesktop.IBus.session.generic.service.in | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/bus/services/org.freedesktop.IBus.session.GNOME.service.in b/bus/services/org.freedesktop.IBus.session.GNOME.service.in
index 7f718e3c..858cf10d 100644
--- a/bus/services/org.freedesktop.IBus.session.GNOME.service.in
+++ b/bus/services/org.freedesktop.IBus.session.GNOME.service.in
@@ -18,7 +18,7 @@ Conflicts=gnome-session@gnome-login.target
 [Service]
 Type=dbus
 # Only pull --xim in X11 session, it is done via Xwayland-session.d on Wayland
-ExecStart=sh -c '@bindir@/ibus-daemon --panel disable $([ "$XDG_SESSION_TYPE" = "x11" ] && echo "--xim")'
+ExecStart=sh -c 'exec @bindir@/ibus-daemon --panel disable $([ "$XDG_SESSION_TYPE" = "x11" ] && echo "--xim")'
 Restart=on-abnormal
 BusName=org.freedesktop.IBus
 TimeoutStopSec=5
diff --git a/bus/services/org.freedesktop.IBus.session.generic.service.in b/bus/services/org.freedesktop.IBus.session.generic.service.in
index 9d493159..e7b7ce4f 100644
--- a/bus/services/org.freedesktop.IBus.session.generic.service.in
+++ b/bus/services/org.freedesktop.IBus.session.generic.service.in
@@ -7,8 +7,7 @@ Conflicts=gnome-session-initialized.target
 
 [Service]
 Type=dbus
-# Only pull --xim in X11 session, it is done via Xwayland-session.d on Wayland
-ExecStart=sh -c '@bindir@/ibus-daemon $IBUS_DAEMON_ARGS'
+ExecStart=sh -c 'exec @bindir@/ibus-daemon $IBUS_DAEMON_ARGS'
 Restart=on-abnormal
 BusName=org.freedesktop.IBus
 TimeoutStopSec=5
-- 
2.39.2

From 7da18d08ce85405e41ba7bf363661292bc97ca39 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 22 Feb 2023 23:53:35 +0900
Subject: [PATCH] src: Call IBUS_TYPE_EMOJI_DATA in ibus_init()

Seems the evaluation of IBUS_EMOJI_DATA() depends on the compiler
optimization.

BUG=https://github.com/ibus/ibus/issues/2476
---
 src/ibusshare.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/ibusshare.c b/src/ibusshare.c
index 340168c8..bb59f3cb 100644
--- a/src/ibusshare.c
+++ b/src/ibusshare.c
@@ -308,12 +308,15 @@ ibus_init (void)
     IBUS_TYPE_TEXT;
     IBUS_TYPE_ATTRIBUTE;
     IBUS_TYPE_ATTR_LIST;
-    IBUS_TYPE_LOOKUP_TABLE;
     IBUS_TYPE_COMPONENT;
+    IBUS_TYPE_EMOJI_DATA;
     IBUS_TYPE_ENGINE_DESC;
+    IBUS_TYPE_LOOKUP_TABLE;
     IBUS_TYPE_OBSERVED_PATH;
     IBUS_TYPE_REGISTRY;
     IBUS_TYPE_X_EVENT;
+    IBUS_TYPE_UNICODE_BLOCK;
+    IBUS_TYPE_UNICODE_DATA;
     _ibus_register_resource ();
 }
 
-- 
2.38.1

From ce5e2bb43ea4c2f5780f4a3bfd7509f812b60afa Mon Sep 17 00:00:00 2001
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Date: Tue, 28 Feb 2023 18:05:29 +0900
Subject: [PATCH] src: Define X11_LOCALEDATADIR for BSD Compose data

FreeBSD and NetBSD have X11 locale Compose data directories in
${X11_PREFIX}/lib/X11/locale instead of ${X11_PREFIX}/share/X11/locale:
https://github.com/freedesktop/xorg-lib-libX11/blob/20a3f99/configure.ac#L336-L340

BUG=https://github.com/ibus/ibus/pull/2478
---
 configure.ac             | 8 ++++++++
 src/Makefile.am          | 2 +-
 src/gencomposetable.c    | 6 ++----
 src/ibuscomposetable.c   | 5 ++---
 src/ibusenginesimple.c   | 5 ++---
 src/tests/Makefile.am    | 2 +-
 src/tests/ibus-compose.c | 3 +--
 7 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index f446ae92..ece1d9ee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -349,6 +349,14 @@ else
 fi
 AC_SUBST(X11_PREFIX)
 
+# Check locale dir for Compose files.
+AC_CHECK_FILE($X11_PREFIX/share/X11/locale/locale.dir,
+              X11_LOCALEDATADIR="$X11_PREFIX/share/X11/locale",
+              [AC_CHECK_FILE($X11_PREFIX/lib/X11/locale/locale.dir,
+                             X11_LOCALEDATADIR="$X11_PREFIX/lib/X11/locale",
+                             X11_LOCALEDATADIR="$(datadir)/X11/locale")])
+AC_SUBST(X11_LOCALEDATADIR)
+
 if test x"$enable_wayland" = x"yes"; then
     # Check for wayland
     PKG_CHECK_MODULES(WAYLAND, [
diff --git a/src/Makefile.am b/src/Makefile.am
index 426376dd..c2e8daa6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,7 +54,7 @@ AM_CPPFLAGS =                                           \
     -DIBUS_DISABLE_DEPRECATION_WARNINGS                 \
     -DIBUS_COMPILATION                                  \
     -DISOCODES_PREFIX=\"$(ISOCODES_PREFIX)\"            \
-    -DX11_DATA_PREFIX=\"$(X11_PREFIX)\"                 \
+    -DX11_LOCALEDATADIR=\"$(X11_LOCALEDATADIR)\"        \
     $(NULL)
 
 # ibus library
diff --git a/src/gencomposetable.c b/src/gencomposetable.c
index 3fe6ff86..6e52d6a6 100644
--- a/src/gencomposetable.c
+++ b/src/gencomposetable.c
@@ -28,8 +28,6 @@
 #include "ibuscomposetable.h"
 #include "ibusenginesimpleprivate.h"
 
-#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"
-
 
 static void
 save_compose_table_endianness (IBusComposeTableEx *compose_table,
@@ -84,7 +82,7 @@ main (int argc, char *argv[])
     if (!path || !g_file_test (path, G_FILE_TEST_EXISTS)) {
         g_clear_pointer (&path, g_free);
         for (sys_lang = sys_langs; *sys_lang; sys_lang++) {
-            path = g_build_filename (X11_DATADIR, *sys_lang,
+            path = g_build_filename (X11_LOCALEDATADIR, *sys_lang,
                                      "Compose", NULL);
             if (!path)
                 continue;
@@ -93,7 +91,7 @@ main (int argc, char *argv[])
         }
     }
     if (!path) {
-        g_warning ("en_US compose file is not found in %s.", X11_DATADIR);
+        g_warning ("en_US compose file is not found in %s.", X11_LOCALEDATADIR);
         return 1;
     } else {
         g_debug ("Create a cache of %s", path);
diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c
index 3e7b0f41..fc486692 100644
--- a/src/ibuscomposetable.c
+++ b/src/ibuscomposetable.c
@@ -39,7 +39,6 @@
 
 #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 {
@@ -285,7 +284,7 @@ expand_include_path (const char *include_path) {
             case 'S': /* system compose dir */
                 o = out;
                 former = g_strndup (head, i - head);
-                out = g_strdup_printf ("%s%s%s", o, former, X11_DATADIR);
+                out = g_strdup_printf ("%s%s%s", o, former, X11_LOCALEDATADIR);
                 head = i + 2;
                 g_free (o);
                 g_free (former);
@@ -397,7 +396,7 @@ get_en_compose_file (void)
     char * const *sys_lang = NULL;
     char *path = NULL;
     for (sys_lang = sys_langs; *sys_lang; sys_lang++) {
-        path = g_build_filename (X11_DATADIR, *sys_lang, "Compose", NULL);
+        path = g_build_filename (X11_LOCALEDATADIR, *sys_lang, "Compose", NULL);
         if (g_file_test (path, G_FILE_TEST_EXISTS))
             break;
         g_clear_pointer (&path, g_free);
diff --git a/src/ibusenginesimple.c b/src/ibusenginesimple.c
index 409d5a56..585d7870 100644
--- a/src/ibusenginesimple.c
+++ b/src/ibusenginesimple.c
@@ -37,7 +37,6 @@
 #include <memory.h>
 #include <stdlib.h>
 
-#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"
 #define IBUS_ENGINE_SIMPLE_GET_PRIVATE(o)  \
    ((IBusEngineSimplePrivate *)ibus_engine_simple_get_instance_private (o))
 
@@ -1440,7 +1439,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
             for (sys_lang = sys_langs; *sys_lang; sys_lang++) {
                 if (g_ascii_strncasecmp (*lang, *sys_lang,
                                          strlen (*sys_lang)) == 0) {
-                    path = g_build_filename (X11_DATADIR,
+                    path = g_build_filename (X11_LOCALEDATADIR,
                                              *lang, "Compose", NULL);
                     break;
                 }
@@ -1462,7 +1461,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
             ibus_engine_simple_add_compose_file (simple, path);
         g_clear_pointer(&path, g_free);
     } else {
-        path = g_build_filename (X11_DATADIR, locale, "Compose", NULL);
+        path = g_build_filename (X11_LOCALEDATADIR, locale, "Compose", NULL);
         do {
             if (g_file_test (path, G_FILE_TEST_EXISTS))
                 break;
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index ca5285bd..8d1d16e3 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -30,7 +30,7 @@ AM_CPPFLAGS = \
     @GLIB2_CFLAGS@                          \
     @GIO2_CFLAGS@                           \
     -DIBUS_DISABLE_DEPRECATION_WARNINGS     \
-    -DX11_DATA_PREFIX=\"$(X11_PREFIX)\"     \
+    -DX11_LOCALEDATADIR=\"$(X11_LOCALEDATADIR)\" \
     -I$(top_srcdir)/src                     \
     -I$(top_builddir)/src                   \
     $(NULL)
diff --git a/src/tests/ibus-compose.c b/src/tests/ibus-compose.c
index 0be01d27..da1a1298 100644
--- a/src/tests/ibus-compose.c
+++ b/src/tests/ibus-compose.c
@@ -6,7 +6,6 @@
 #define GREEN "\033[0;32m"
 #define RED   "\033[0;31m"
 #define NC    "\033[0m"
-#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"
 
 IBusBus *m_bus;
 gchar *m_compose_file;
@@ -36,7 +35,7 @@ get_compose_path ()
             break;
         if (g_strcmp0 (*l, "C") == 0)
             break;
-        compose_path = g_build_filename (X11_DATADIR,
+        compose_path = g_build_filename (X11_LOCALEDATADIR,
                                          *l,
                                          "Compose",
                                          NULL);
-- 
2.39.2

From 9d9dca9e103e88b33e786c4a46f44123a6cf11c6 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 8 Mar 2023 19:44:16 +0900
Subject: [PATCH] client/x11: Fix Key typing order

ibus-x11 now also uses the hybrid process key events with
IBUS_ENABLE_SYNC_MODE=2 and it waits for the async API
with GSource and g_main_context_iteration() in xim_forward_event().

But g_main_context_iteration() calls gdk_event_source_dispatch()
and it can call another xim_forward_event() and the callbacks
of ibus_input_context_process_key_event_async() can be nested.
So if the forwarding API is called out of the callbacks of
ibus_input_context_process_key_event_async(), the key events
order is swapped due to the delayed return of
g_main_context_iteration().

To resolve this issue, the forwarding API should be called in
the callbacks of ibus_input_context_process_key_event_async().

BUG=https://github.com/ibus/ibus/issues/2480
---
 client/x11/main.c | 160 ++++++++++++++++++++++++----------------------
 1 file changed, 83 insertions(+), 77 deletions(-)

diff --git a/client/x11/main.c b/client/x11/main.c
index 905fd251..83d95cb7 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 <shawn.p.huang@gmail.com>
- * Copyright (C) 2015-2022 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (C) 2015-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
  * Copyright (C) 2007-2015 Red Hat, Inc.
  *
  * main.c:
@@ -49,6 +49,8 @@
 #include <getopt.h>
 
 #define ESC_SEQUENCE_ISO10646_1 "\033%G"
+/* Wait for about 120 secs to return a key from async process-key-event. */
+#define MAX_WAIT_KEY_TIME       120000
 
 #define LOG(level, fmt_args...) \
     if (g_debug_level >= (level)) { \
@@ -461,11 +463,39 @@ xim_unset_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
 
 }
 
+static void
+_xim_forward_key_event_done (X11IC   *x11ic,
+                             XEvent  *event,
+                             gboolean processed)
+{
+    IMForwardEventStruct fe;
+    if (processed) {
+        if (!x11ic->has_preedit_area) {
+            _xim_set_cursor_location (x11ic);
+        }
+        return;
+    }
+    g_assert (x11ic);
+    g_assert (event);
+
+    memset (&fe, 0, sizeof (fe));
+    fe.major_code = XIM_FORWARD_EVENT;
+    fe.icid = x11ic->icid;
+    fe.connect_id = x11ic->connect_id;
+    fe.sync_bit = 0;
+    fe.serial_number = 0L;
+    fe.event = *event;
+    IMForwardEvent (_xims, (XPointer) &fe);
+}
+
+
 typedef struct {
-    IMForwardEventStruct *pfe;
     int                   count;
     guint                 count_cb_id;
     gboolean              retval;
+    X11IC                *x11ic;
+    CARD16                connect_id;
+    XEvent                event;
 } ProcessKeyEventReplyData;
 
 static void
@@ -474,7 +504,7 @@ _process_key_event_done (GObject      *object,
                          gpointer      user_data)
 {
     IBusInputContext *context = (IBusInputContext *)object;
-    IMForwardEventStruct *pfe = (IMForwardEventStruct*) user_data;
+    ProcessKeyEventReplyData *data = (ProcessKeyEventReplyData *)user_data;
 
     GError *error = NULL;
     gboolean retval = ibus_input_context_process_key_event_async_finish (
@@ -488,16 +518,15 @@ _process_key_event_done (GObject      *object,
     }
 
     if (g_hash_table_lookup (_connections,
-                             GINT_TO_POINTER ((gint) pfe->connect_id))
+                             GINT_TO_POINTER ((gint)data->connect_id))
         == NULL) {
-        g_slice_free (IMForwardEventStruct, pfe);
+        g_slice_free (ProcessKeyEventReplyData, data);
         return;
     }
 
-    if (retval == FALSE) {
-        IMForwardEvent (_xims, (XPointer) pfe);
-    }
-    g_slice_free (IMForwardEventStruct, pfe);
+    if (retval == FALSE)
+        _xim_forward_key_event_done (data->x11ic, &data->event, retval);
+    g_slice_free (ProcessKeyEventReplyData, data);
 }
 
 static void
@@ -518,6 +547,21 @@ _process_key_event_reply_done (GObject      *object,
     }
     g_return_if_fail (data);
     data->retval = retval;
+    if (g_hash_table_lookup (_connections,
+                             GINT_TO_POINTER ((gint)data->connect_id))
+        == NULL) {
+        return;
+    }
+    /* _xim_forward_key_event_done() should be called in
+     * _process_key_event_reply_done() because g_main_context_iteration()
+     * can call another xim_forward_event() and xim_forward_event() can be
+     * nested and the first _process_key_event_reply_done() is returned
+     * at last with g_main_context_iteration() so
+     * if _xim_forward_key_event_done() is called out of
+     * _process_key_event_reply_done(), the key events order
+     * can be swapped.
+     */
+    _xim_forward_key_event_done (data->x11ic, &data->event, retval);
     data->count = 0;
     g_source_remove (data->count_cb_id);
 }
@@ -529,9 +573,8 @@ _process_key_event_count_cb (gpointer user_data)
     g_return_val_if_fail (data, G_SOURCE_REMOVE);
     if (!data->count)
         return G_SOURCE_REMOVE;
-    /* Wait for about 10 secs. */
-    if (data->count++ == 10000) {
-        data->count = 0;
+    if (data->count++ == MAX_WAIT_KEY_TIME) {
+        g_warning ("Key event is not returned for %usecs.", MAX_WAIT_KEY_TIME);
         return G_SOURCE_REMOVE;
     }
     return G_SOURCE_CONTINUE;
@@ -571,32 +614,13 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
                                       event.keyval,
                                       event.hardware_keycode - 8,
                                       event.state);
-        if (retval) {
-            if (!x11ic->has_preedit_area) {
-                _xim_set_cursor_location (x11ic);
-            }
-            return 1;
-        }
-
-        IMForwardEventStruct fe;
-        memset (&fe, 0, sizeof (fe));
-
-        fe.major_code = XIM_FORWARD_EVENT;
-        fe.icid = x11ic->icid;
-        fe.connect_id = x11ic->connect_id;
-        fe.sync_bit = 0;
-        fe.serial_number = 0L;
-        fe.event = call_data->event;
-
-        IMForwardEvent (_xims, (XPointer) &fe);
-
+        _xim_forward_key_event_done (x11ic, &call_data->event, retval);
         retval = 1;
         break;
     }
     case 2: {
         GSource *source = g_timeout_source_new (1);
         ProcessKeyEventReplyData *data = NULL;
-        IMForwardEventStruct fe;
 
         if (source)
             data = g_slice_new0 (ProcessKeyEventReplyData);
@@ -610,11 +634,13 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
             if (source)
                 g_source_destroy (source);
         } else {
-            CARD16 connect_id = x11ic->connect_id;
             data->count = 1;
             g_source_attach (source, NULL);
             g_source_unref (source);
             data->count_cb_id = g_source_get_id (source);
+            data->connect_id = call_data->connect_id;
+            data->x11ic = x11ic;
+            data->event = *((XEvent*)xevent);
             ibus_input_context_process_key_event_async (
                     x11ic->context,
                     event.keyval,
@@ -626,7 +652,7 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
                     data);
             g_source_set_callback (source, _process_key_event_count_cb,
                                    data, NULL);
-            while (data->count)
+            while (data->count > 0 && data->count < MAX_WAIT_KEY_TIME)
                 g_main_context_iteration (NULL, TRUE);
             if (source->ref_count > 0) {
                 /* g_source_get_id() could causes a SEGV */
@@ -634,46 +660,33 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
                         "issue in %p.", source);
             }
             retval = data->retval;
-            g_slice_free (ProcessKeyEventReplyData, data);
-
-            if (g_hash_table_lookup (_connections,
-                                     GINT_TO_POINTER ((gint)connect_id))
-                == NULL) {
+            if (data->count == 0) {
+                g_slice_free (ProcessKeyEventReplyData, data);
                 return 1;
             }
         }
 
-        if (retval) {
-            if (! x11ic->has_preedit_area) {
-                _xim_set_cursor_location (x11ic);
-            }
-            return 1;
+        g_slice_free (ProcessKeyEventReplyData, data);
+        if (g_hash_table_lookup (_connections,
+                                 GINT_TO_POINTER ((gint)call_data->connect_id))
+                == NULL) {
+                return 1;
         }
-
-        memset (&fe, 0, sizeof (fe));
-
-        fe.major_code = XIM_FORWARD_EVENT;
-        fe.icid = x11ic->icid;
-        fe.connect_id = x11ic->connect_id;
-        fe.sync_bit = 0;
-        fe.serial_number = 0L;
-        fe.event = call_data->event;
-
-        IMForwardEvent (_xims, (XPointer) &fe);
-
+        _xim_forward_key_event_done (x11ic, &call_data->event, retval);
         retval = 1;
         break;
     }
     default: {
-        IMForwardEventStruct *pfe;
+        ProcessKeyEventReplyData *data;
 
-        pfe = g_slice_new0 (IMForwardEventStruct);
-        pfe->major_code = XIM_FORWARD_EVENT;
-        pfe->icid = x11ic->icid;
-        pfe->connect_id = x11ic->connect_id;
-        pfe->sync_bit = 0;
-        pfe->serial_number = 0L;
-        pfe->event = call_data->event;
+        if (!(data = g_slice_new0 (ProcessKeyEventReplyData))) {
+            g_warning ("Cannot allocate async data");
+            _xim_forward_key_event_done (x11ic, &call_data->event, 0);
+            return 1;
+        }
+        data->connect_id = call_data->connect_id;
+        data->x11ic = x11ic;
+        data->event = call_data->event;
 
         ibus_input_context_process_key_event_async (
                                       x11ic->context,
@@ -683,7 +696,7 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
                                       -1,
                                       NULL,
                                       _process_key_event_done,
-                                      pfe);
+                                      data);
         retval = 1;
     }
     }
@@ -962,11 +975,10 @@ _xim_forward_key_event (X11IC   *x11ic,
                         guint    keycode,
                         guint    state)
 {
-    g_return_if_fail (x11ic != NULL);
-
-    IMForwardEventStruct fe = {0};
     XEvent xkp = {0};
 
+    g_return_if_fail (x11ic != NULL);
+
     xkp.xkey.type = (state & IBUS_RELEASE_MASK) ? KeyRelease : KeyPress;
     xkp.xkey.serial = 0L;
     xkp.xkey.send_event = False;
@@ -975,20 +987,14 @@ _xim_forward_key_event (X11IC   *x11ic,
     xkp.xkey.window =
         x11ic->focus_window ? x11ic->focus_window : x11ic->client_window;
     xkp.xkey.subwindow = None;
-    xkp.xkey.root = DefaultRootWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
+    xkp.xkey.root = DefaultRootWindow (
+            GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()));
 
     xkp.xkey.time = 0;
     xkp.xkey.state = state;
     xkp.xkey.keycode = (keycode == 0) ? 0 : keycode + 8;
 
-    fe.major_code = XIM_FORWARD_EVENT;
-    fe.icid = x11ic->icid;
-    fe.connect_id = x11ic->connect_id;
-    fe.sync_bit = 0;
-    fe.serial_number = 0L;
-    fe.event = xkp;
-
-    IMForwardEvent (_xims, (XPointer) & fe);
+    _xim_forward_key_event_done (x11ic, &xkp, FALSE);
 }
 
 static void
-- 
2.38.1

From 5b5d0795f297e330fdc84b6be6beab1305b0cda9 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 15 Mar 2023 10:22:05 +0900
Subject: [PATCH] util/IMdkit: Disable while loop before call
 ForwardEventMessageProc()

Seems ProcessQueue() had a wrong XFree() with async process-key-event.
Fixes: c0fec89ae76f9522319f58107ab234992b249ec6

BUG=https://github.com/ibus/ibus/issues/2484
---
 util/IMdkit/i18nPtHdr.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/util/IMdkit/i18nPtHdr.c b/util/IMdkit/i18nPtHdr.c
index 8dc52714..ec20e322 100644
--- a/util/IMdkit/i18nPtHdr.c
+++ b/util/IMdkit/i18nPtHdr.c
@@ -1747,11 +1747,13 @@ static void ProcessQueue (XIMS ims, CARD16 connect_id)
         XimProtoHdr *hdr = (XimProtoHdr *) client->pending->p;
         unsigned char *p1 = (unsigned char *) (hdr + 1);
         IMProtocol call_data;
+        XIMPending *old = client->pending;
 
         call_data.major_code = hdr->major_opcode;
         call_data.any.minor_code = hdr->minor_opcode;
         call_data.any.connect_id = connect_id;
 
+        client->pending = old->next;
         switch (hdr->major_opcode)
         {
         case XIM_FORWARD_EVENT:
@@ -1760,12 +1762,7 @@ static void ProcessQueue (XIMS ims, CARD16 connect_id)
         }
         /*endswitch*/
         XFree (hdr);
-        {
-            XIMPending *old = client->pending;
-
-            client->pending = old->next;
-            XFree (old);
-        }
+        XFree (old);
     }
     /*endwhile*/
     return;
-- 
2.39.2

From f82140b1368c5ec4c0b70e5caea2931ceed5589c Mon Sep 17 00:00:00 2001
From: Sibo Dong <46512211+dongsibo@users.noreply.github.com>
Date: Tue, 21 Feb 2023 16:38:03 -0500
Subject: [PATCH] ui/gtk3: Update Emoji shortcut key in ibus-emoji(7)

The default Emoji shortcut key was changed but not updated in the
ibus-emoji.7 man page.

Fixes: https://github.com/ibus/ibus/commit/1520c39

BUG=https://github.com/ibus/ibus/pull/2475
---
 ui/gtk3/ibus-emoji.7.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/gtk3/ibus-emoji.7.in b/ui/gtk3/ibus-emoji.7.in
index b4d941ec..31074300 100644
--- a/ui/gtk3/ibus-emoji.7.in
+++ b/ui/gtk3/ibus-emoji.7.in
@@ -51,7 +51,7 @@ E.g. "Noto Color Emoji", "Android Emoji" font.
 
 .SH "KEYBOARD OPERATIONS"
 .TP
-\fBControl-Period or Control-Semicolon\fR
+\fBSuper-Period\fR
 Launch IBus Emojier. The shortcut key can be customized by
 .B ibus\-setup (1).
 .TP
-- 
2.40.0

From 9553dbf12ec42a58beb671a7039827fbd652e14d Mon Sep 17 00:00:00 2001
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Date: Mon, 27 Mar 2023 19:45:37 +0900
Subject: [PATCH] Portability fixes for preparation of NetBSD CI

- Makefile: Ignore errors on $(RM) -r "`uname -i`"

- autogen: Replace make with $MAKE

- data/dconf: BSD does not support the --tmpdir long option
              in mktemp. Also add the cleanup function.

BUG=https://github.com/ibus/ibus/pull/2482
---
 Makefile.am                          |  2 +-
 autogen.sh                           |  7 ++++---
 data/dconf/make-dconf-override-db.sh | 11 ++++++++---
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 17e56b38..16548d25 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -139,7 +139,7 @@ srpm: dist @PACKAGE_NAME@.spec
 			@PACKAGE_NAME@.spec
 
 clean-rpm:
-	$(RM) -r "`uname -i`"
+	-$(RM) -r "`uname -i`"
 
 clean-local: clean-rpm
 
diff --git a/autogen.sh b/autogen.sh
index 9b1d8342..4ea8d757 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -4,6 +4,7 @@
 : ${srcdir=$(dirname $0)}
 : ${srcdir:=.}
 : ${SAVE_DIST_FILES:=0}
+: ${MAKE:=make}
 
 olddir=$(pwd)
 # shellcheck disable=SC2016
@@ -73,7 +74,7 @@ cd "$olddir"
     (test "$1" = "--help" ) && {
         exit 0
     } || {
-        echo "Now type 'make' to compile $PKG_NAME" || exit 1
+        echo "Now type '$MAKE' to compile $PKG_NAME" || exit 1
     }
 } || {
     echo "Skipping configure process."
@@ -83,8 +84,8 @@ cd "$srcdir"
 (test "x$SAVE_DIST_FILES" = "x0" ) && {
     # rm engine/simple.xml.in src/ibusemojigen.h src/ibusunicodegen.h
     for d in engine src src/compose; do
-        echo "make -C $d maintainer-clean-generic"
-        make -C $d maintainer-clean-generic
+        echo "$MAKE -C $d maintainer-clean-generic"
+        $MAKE -C $d maintainer-clean-generic
    done
 } || :
 cd "$olddir"
diff --git a/data/dconf/make-dconf-override-db.sh b/data/dconf/make-dconf-override-db.sh
index 601c1c3f..32cb1530 100755
--- a/data/dconf/make-dconf-override-db.sh
+++ b/data/dconf/make-dconf-override-db.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 
 set -e
 
@@ -6,7 +6,7 @@ set -e
 # breaks dbus-launch.  There's dbus-run-session which is
 # better, but not everyone has it yet.
 export DBUS_FATAL_WARNINGS=0
-export TMPDIR=$(mktemp -d --tmpdir="$PWD")
+export TMPDIR=$(mktemp -d -p "$PWD")
 export XDG_CONFIG_HOME="$TMPDIR/config"
 export XDG_CACHE_HOME="$TMPDIR/cache"
 export GSETTINGS_SCHEMA_DIR="$TMPDIR/schemas"
@@ -14,7 +14,12 @@ mkdir -p $XDG_CONFIG_HOME $XDG_CACHE_HOME $GSETTINGS_SCHEMA_DIR
 
 eval `dbus-launch --sh-syntax`
 
-trap 'rm -rf $TMPDIR; kill $DBUS_SESSION_BUS_PID' ERR
+trap cleanup EXIT
+
+cleanup() {
+  test $? -eq 0 && exit
+  rm -rf $TMPDIR; kill $DBUS_SESSION_BUS_PID
+}
 
 # in case that schema is not installed on the system
 glib-compile-schemas --targetdir "$GSETTINGS_SCHEMA_DIR" "$PWD"
-- 
2.39.2

From 630f3f73f62a121abb1af5b215d193aec4e0053c Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 5 Apr 2023 14:28:49 +0900
Subject: [PATCH] configure: Use AC_C_BIGENDIAN for BSD systems

NetBSD does not define __BYTE_ORDER and use AC_C_BIGENDIAN instead.

BUG=https://github.com/ibus/ibus/pull/2477
---
 configure.ac | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/configure.ac b/configure.ac
index ece1d9ee..b3eacbcb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -152,35 +152,12 @@ AC_CHECK_LIB(c, dlclose, LIBDL="", [AC_CHECK_LIB(dl, dlclose, LIBDL="-ldl")])
 AC_SUBST(LIBDL)
 
 # Check endianness.
-AC_MSG_CHECKING([build system endianness])
-ENDIAN=unknown
-AC_RUN_IFELSE(
-    [AC_LANG_PROGRAM(
-        [[
-            #include <endian.h>
-            #if __BYTE_ORDER != __LITTLE_ENDIAN
-            #error
-            #endif
-        ]]
-    )],
-    [ENDIAN=little]
-)
-AC_RUN_IFELSE(
-    [AC_LANG_PROGRAM(
-        [[
-            #include <endian.h>
-            #if __BYTE_ORDER != __BIG_ENDIAN
-            #error
-            #endif
-        ]]
-    )],
-    [ENDIAN=big]
-)
+AC_C_BIGENDIAN([ENDIAN=big], [ENDIAN=little], [ENDIAN=unknown], [ENDIAN=big])
 if test x"$ENDIAN" != xlittle  -a x"$ENDIAN" != xbig; then
-    AC_MSG_ERROR([Cannot deermine endianness without endian.h])
+    AC_MSG_ERROR([Cannot determine endianness. Use ac_cv_c_bigendian to yes or no])
 fi
-AC_MSG_RESULT($ENDIAN)
 AC_SUBST(ENDIAN)
+ENDIAN_MSG="$ENDIAN (ac_cv_c_bigendian=$ac_cv_c_bigendian)"
 
 # Check packages.
 # Check glib2.
@@ -902,7 +879,7 @@ Build options:
   Install prefix                $prefix
   Build shared libs             $enable_shared
   Build static libs             $enable_static
-  Build endianness              $ENDIAN
+  Build endianness              $ENDIAN_MSG
   CFLAGS                        $CFLAGS
   PYTHON                        $PYTHON
   PYTHON2                       $PYTHON2
-- 
2.39.2

From 67a0f36de029fe3adc21c90c7fb8669d0d68cbe2 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Thu, 13 Apr 2023 12:22:50 +0900
Subject: [PATCH] src: Generate ibusenumtypes.h for gen-internal-compose-table

`make clean` deletes ibusenumtypes.h and ibus.h incudes ibusenumtypes.h
and it's required by the gen-internal-compose-table build.

BUG=https://github.com/ibus/ibus/issues/2501
---
 src/Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/Makefile.am b/src/Makefile.am
index c2e8daa6..adc7f04a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -194,6 +194,7 @@ gen_internal_compose_table_SOURCES = \
     ibuserror.c         \
     ibuskeynames.c      \
     ibuskeyuni.c        \
+    ibusenumtypes.h     \
     $(NULL)
 gen_internal_compose_table_CFLAGS = $(AM_CFLAGS)
 gen_internal_compose_table_LDADD = \
-- 
2.39.2