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

From 310c442b62b569255ffc39bca557920d06881ade Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Tue, 2 May 2023 10:00:03 +0900
Subject: [PATCH] ui/gtk3: Add workaround Emojier can be launched

gnome-shell 44 prevents ibus from launching Emojier GUI.
This workaround can launch the Emojier but still cannot output
the selected emoji character to the focused application.

So another workaround is needed with this patch.
I.e. Type Ctrl-Shift-c keys to copy the seleted emoji instead of
Enter key.

BUG=https://github.com/ibus/ibus/issues/2509
BUG=https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6518
---
 ui/gtk3/emojier.vala | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/ui/gtk3/emojier.vala b/ui/gtk3/emojier.vala
index 69fb8abe..c9cf4469 100644
--- a/ui/gtk3/emojier.vala
+++ b/ui/gtk3/emojier.vala
@@ -2,7 +2,7 @@
  *
  * ibus - The Input Bus
  *
- * Copyright (c) 2017-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (c) 2017-2023 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
@@ -1799,12 +1799,12 @@ public class IBusEmojier : Gtk.ApplicationWindow {
 
         m_rebuilding_gui = true;
         m_rebuilding_gui_timeout_id =
-                GLib.Timeout.add_seconds(10, () => {
+                GLib.Timeout.add_seconds(5, () => {
                     if (!m_rebuilding_gui) {
                         m_rebuilding_gui_timeout_id = 0;
                         return false;
                     }
-                    warning("Rebuilding GUI is time out.");
+                    debug("Rebuilding GUI is time out.");
                     m_rebuilding_gui = false;
                     m_rebuilding_gui_timeout_id = 0;
                     return false;
@@ -2459,7 +2459,6 @@ public class IBusEmojier : Gtk.ApplicationWindow {
 
 
     public override bool focus_in_event(Gdk.EventFocus event) {
-        m_rebuilding_gui = false;
         return base.focus_in_event(event);
     }
 
-- 
2.40.0

From 1a25975d9f55f18eab609e4d147dd32689e367f3 Mon Sep 17 00:00:00 2001
From: Emil Velikov <emil.l.velikov@gmail.com>
Date: Sun, 11 Jun 2023 16:16:35 +0900
Subject: [PATCH 1/2] makefile: don't gzip the man pages

Drop the gzip step from the manpages - distributions already do that as
needed. In addition this resolves the final reproducibility issue with
ibus.

BUG=https://github.com/ibus/ibus/pull/2514
---
 bus/Makefile.am        | 6 +-----
 data/dconf/Makefile.am | 6 +-----
 setup/Makefile.am      | 6 +-----
 tools/Makefile.am      | 6 +-----
 ui/gtk3/Makefile.am    | 6 +-----
 5 files changed, 5 insertions(+), 25 deletions(-)

diff --git a/bus/Makefile.am b/bus/Makefile.am
index e173ee25..d0445d02 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -169,7 +169,6 @@ EXTRA_DIST =                \
 
 CLEANFILES = \
 	$(man_one_DATA)            \
-	$(man_one_files)        \
 	$(NULL)
 
 $(libibus):
@@ -181,14 +180,11 @@ test: ibus-daemon
 		$(builddir)/ibus-daemon -v
 
 man_one_in_files = ibus-daemon.1.in
-man_one_files = $(man_one_in_files:.1.in=.1)
-man_one_DATA =$(man_one_files:.1=.1.gz) 
+man_one_DATA = $(man_one_in_files:.1.in=.1)
 man_onedir = $(mandir)/man1
 %.1: %.1.in
 	$(AM_V_GEN) sed \
 		-e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
 		mv $@.tmp $@
-%.1.gz: %.1
-	$(AM_V_GEN) gzip -c $< > $@.tmp && mv $@.tmp $@
 
 -include $(top_srcdir)/git.mk
diff --git a/data/dconf/Makefile.am b/data/dconf/Makefile.am
index 5360f033..2352f770 100644
--- a/data/dconf/Makefile.am
+++ b/data/dconf/Makefile.am
@@ -38,15 +38,12 @@ dconfdb_DATA = 00-upstream-settings
 		{ rc=$$?; $(RM) -rf $@; exit $$rc; }
 
 man_5_in_files = 00-upstream-settings.5.in ibus.5.in
-man_5_files = $(man_5_in_files:.5.in=.5)
-man_5_DATA =$(man_5_files:.5=.5.gz)
+man_5_DATA = $(man_5_in_files:.5.in=.5)
 man_5dir = $(mandir)/man5
 %.5: %.5.in
 	$(AM_V_GEN) sed \
 	    -e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
 	    mv $@.tmp $@
-%.5.gz: %.5
-	$(AM_V_GEN) gzip -c $< > $@.tmp && mv $@.tmp $@
 
 install-data-hook:
 	if test -z "$(DESTDIR)"; then \
@@ -63,7 +60,6 @@ EXTRA_DIST = \
 
 CLEANFILES = \
     $(man_5_DATA) \
-    $(man_5_files) \
     $(NULL)
 
 MAINTAINERCLEANFILES = \
diff --git a/setup/Makefile.am b/setup/Makefile.am
index 34c8f136..b34aa8fc 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -56,20 +56,16 @@ org.freedesktop.IBus.Setup.desktop: ibus-setup.desktop
 	$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
 
 man_one_in_files = ibus-setup.1.in
-man_one_files = $(man_one_in_files:.1.in=.1)
-man_one_DATA =$(man_one_files:.1=.1.gz) 
+man_one_DATA = $(man_one_in_files:.1.in=.1)
 man_onedir = $(mandir)/man1
 %.1: %.1.in
 	$(AM_V_GEN) sed \
 		-e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
 		mv $@.tmp $@
-%.1.gz: %.1
-	$(AM_V_GEN) gzip -c $< > $@.tmp && mv $@.tmp $@
 
 CLEANFILES = \
     $(desktop_DATA) \
     $(man_one_DATA) \
-    $(man_one_files) \
     *.pyc \
     ibus-setup \
     $(NULL)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index e300f9f3..0d00abed 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -113,15 +113,12 @@ libibusimmodule_la_LDFLAGS = \
     $(NULL)
 
 man_one_in_files = ibus.1.in
-man_one_files = $(man_one_in_files:.1.in=.1)
-man_one_DATA =$(man_one_files:.1=.1.gz)
+man_one_DATA = $(man_one_in_files:.1.in=.1)
 man_onedir = $(mandir)/man1
 %.1: %.1.in
 	$(AM_V_GEN) sed \
 		-e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
 		mv $@.tmp $@
-%.1.gz: %.1
-	$(AM_V_GEN) gzip -c $< > $@.tmp && mv $@.tmp $@
 
 EXTRA_DIST = \
     $(ibus_immodule_vapi) \
@@ -133,7 +130,6 @@ EXTRA_DIST = \
 
 CLEANFILES = \
     $(man_one_DATA) \
-    $(man_one_files) \
     $(NULL)
 
 if ENABLE_EMOJI_DICT
diff --git a/ui/gtk3/Makefile.am b/ui/gtk3/Makefile.am
index 2a9cabde..5e1a8510 100644
--- a/ui/gtk3/Makefile.am
+++ b/ui/gtk3/Makefile.am
@@ -257,15 +257,12 @@ panelbinding.o: $(srcdir)/panelbinding.c
 
 MAINTAINERCLEANFILES += extension.c panelbinding.c
 
-man_seven_files = $(man_seven_in_files:.7.in=.7)
-man_seven_DATA =$(man_seven_files:.7=.7.gz)
+man_seven_DATA = $(man_seven_in_files:.7.in=.7)
 man_sevendir = $(mandir)/man7
 %.7: %.7.in
 	$(AM_V_GEN) sed \
 	    -e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
 	    mv $@.tmp $@
-%.7.gz: %.7
-	$(AM_V_GEN) gzip -c $< > $@.tmp && mv $@.tmp $@
 
 desktop_in_files = \
     ibus-ui-emojier.desktop.in \
@@ -293,7 +290,6 @@ CLEANFILES += \
     $(desktop_DATA) \
     $(desktop_notrans_files) \
     $(man_seven_DATA) \
-    $(man_seven_files) \
     $(NULL)
 
 endif
-- 
2.40.0

From 03a486c1ec98647e7f8c7dbb70e6e4d3898c9322 Mon Sep 17 00:00:00 2001
From: Emil Velikov <emil.l.velikov@gmail.com>
Date: Sun, 11 Jun 2023 16:16:40 +0900
Subject: [PATCH 2/2] makefile: manage the manpages via AC_CONFIG_FILES()

The AC_CONFIG_FILES macro already known how to handle @VERSION@
substitution, while also ensuring the input files are in the tarball
(EXTRA_DIST) and substituted files are removed on make distclean
(CONFIG_CLEAN_FILES).

BUG=https://github.com/ibus/ibus/pull/2514
---
 bus/Makefile.am        | 12 +-----------
 configure.ac           |  6 ++++++
 data/dconf/Makefile.am | 12 +-----------
 setup/Makefile.am      |  9 +--------
 tools/Makefile.am      | 12 +-----------
 ui/gtk3/Makefile.am    | 10 +---------
 6 files changed, 11 insertions(+), 50 deletions(-)

diff --git a/bus/Makefile.am b/bus/Makefile.am
index d0445d02..99715a15 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -163,14 +163,9 @@ test_stress_LDADD = \
 	$(NULL)
 
 EXTRA_DIST =                \
-	$(man_one_in_files)     \
 	marshalers.list         \
 	$(NULL)
 
-CLEANFILES = \
-	$(man_one_DATA)            \
-	$(NULL)
-
 $(libibus):
 	$(MAKE) -C $(top_builddir)/src
 
@@ -179,12 +174,7 @@ test: ibus-daemon
 		G_DEBUG=fatal_warnings \
 		$(builddir)/ibus-daemon -v
 
-man_one_in_files = ibus-daemon.1.in
-man_one_DATA = $(man_one_in_files:.1.in=.1)
+man_one_DATA = ibus-daemon.1
 man_onedir = $(mandir)/man1
-%.1: %.1.in
-	$(AM_V_GEN) sed \
-		-e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
-		mv $@.tmp $@
 
 -include $(top_srcdir)/git.mk
diff --git a/configure.ac b/configure.ac
index b3eacbcb..73583bab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -831,6 +831,7 @@ bindings/Makefile
 bindings/pygobject/Makefile
 bindings/vala/Makefile
 bus/Makefile
+bus/ibus-daemon.1
 bus/services/Makefile
 client/Makefile
 client/gtk2/Makefile
@@ -847,6 +848,8 @@ data/icons/Makefile
 data/its/Makefile
 data/keymaps/Makefile
 data/dconf/Makefile
+data/dconf/00-upstream-settings.5
+data/dconf/ibus.5
 docs/Makefile
 docs/reference/Makefile
 docs/reference/ibus/ibus-docs.sgml
@@ -858,13 +861,16 @@ ibus/interface/Makefile
 m4/Makefile
 portal/Makefile
 setup/Makefile
+setup/ibus-setup.1
 src/Makefile
 src/compose/Makefile
 src/ibusversion.h
 src/tests/Makefile
 tools/Makefile
+tools/ibus.1
 ui/Makefile
 ui/gtk3/Makefile
+ui/gtk3/ibus-emoji.7
 util/Makefile
 util/IMdkit/Makefile
 Makefile
diff --git a/data/dconf/Makefile.am b/data/dconf/Makefile.am
index 2352f770..b0601aa8 100644
--- a/data/dconf/Makefile.am
+++ b/data/dconf/Makefile.am
@@ -37,13 +37,8 @@ dconfdb_DATA = 00-upstream-settings
 	$(AM_V_GEN) $(srcdir)/make-dconf-override-db.sh > $@ || \
 		{ rc=$$?; $(RM) -rf $@; exit $$rc; }
 
-man_5_in_files = 00-upstream-settings.5.in ibus.5.in
-man_5_DATA = $(man_5_in_files:.5.in=.5)
+man_5_DATA = 00-upstream-settings.5 ibus.5
 man_5dir = $(mandir)/man5
-%.5: %.5.in
-	$(AM_V_GEN) sed \
-	    -e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
-	    mv $@.tmp $@
 
 install-data-hook:
 	if test -z "$(DESTDIR)"; then \
@@ -52,16 +47,11 @@ install-data-hook:
 
 EXTRA_DIST = \
     $(gsettings_SCHEMAS) \
-    $(man_5_in_files) \
     make-dconf-override-db.sh \
     profile/ibus \
     00-upstream-settings \
     $(NULL)
 
-CLEANFILES = \
-    $(man_5_DATA) \
-    $(NULL)
-
 MAINTAINERCLEANFILES = \
     00-upstream-settings \
     $(NULL)
diff --git a/setup/Makefile.am b/setup/Makefile.am
index b34aa8fc..831f883c 100644
--- a/setup/Makefile.am
+++ b/setup/Makefile.am
@@ -55,24 +55,17 @@ desktopdir = $(datadir)/applications
 org.freedesktop.IBus.Setup.desktop: ibus-setup.desktop
 	$(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
 
-man_one_in_files = ibus-setup.1.in
-man_one_DATA = $(man_one_in_files:.1.in=.1)
+man_one_DATA = ibus-setup.1
 man_onedir = $(mandir)/man1
-%.1: %.1.in
-	$(AM_V_GEN) sed \
-		-e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
-		mv $@.tmp $@
 
 CLEANFILES = \
     $(desktop_DATA) \
-    $(man_one_DATA) \
     *.pyc \
     ibus-setup \
     $(NULL)
 
 EXTRA_DIST = \
     $(desktop_notrans_files) \
-    $(man_one_in_files) \
     ibus-setup.in \
     setup.ui \
     $(NULL)
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 0d00abed..daf18f28 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -112,26 +112,16 @@ libibusimmodule_la_LDFLAGS = \
     -export-symbols-regex "ibus_.*"                     \
     $(NULL)
 
-man_one_in_files = ibus.1.in
-man_one_DATA = $(man_one_in_files:.1.in=.1)
+man_one_DATA = ibus.1
 man_onedir = $(mandir)/man1
-%.1: %.1.in
-	$(AM_V_GEN) sed \
-		-e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
-		mv $@.tmp $@
 
 EXTRA_DIST = \
     $(ibus_immodule_vapi) \
     $(ibusimmodule_gir) \
-    $(man_one_in_files) \
     ibus.bash \
     IBusIMModule-1.0.metadata \
     $(NULL)
 
-CLEANFILES = \
-    $(man_one_DATA) \
-    $(NULL)
-
 if ENABLE_EMOJI_DICT
 if ENABLE_UI
 AM_VALAFLAGS += \
diff --git a/ui/gtk3/Makefile.am b/ui/gtk3/Makefile.am
index 5e1a8510..4a6506fe 100644
--- a/ui/gtk3/Makefile.am
+++ b/ui/gtk3/Makefile.am
@@ -147,8 +147,6 @@ emoji_headers =         \
     ibusemojidialog.h   \
     $(NULL)
 
-man_seven_in_files = ibus-emoji.7.in
-
 # References:
 # libappindicator/src/notification-item.xml
 # libappindicator/src/notification-watcher.xml
@@ -156,7 +154,6 @@ man_seven_in_files = ibus-emoji.7.in
 # kdelibs/kdeui/knotifications/src/org.kde.StatusNotifierWatcher.xml
 EXTRA_DIST =                            \
     $(emoji_headers)                    \
-    $(man_seven_in_files)               \
     emojierapp.vala                     \
     extension.vala                      \
     gtkextension.xml.in                 \
@@ -257,12 +254,8 @@ panelbinding.o: $(srcdir)/panelbinding.c
 
 MAINTAINERCLEANFILES += extension.c panelbinding.c
 
-man_seven_DATA = $(man_seven_in_files:.7.in=.7)
+man_seven_DATA = ibus-emoji.7
 man_sevendir = $(mandir)/man7
-%.7: %.7.in
-	$(AM_V_GEN) sed \
-	    -e 's|@VERSION[@]|$(VERSION)|g' $< > $@.tmp && \
-	    mv $@.tmp $@
 
 desktop_in_files = \
     ibus-ui-emojier.desktop.in \
@@ -289,7 +282,6 @@ org.freedesktop.IBus.Panel.Extension.Gtk3.desktop: ibus-extension-gtk3.desktop
 CLEANFILES += \
     $(desktop_DATA) \
     $(desktop_notrans_files) \
-    $(man_seven_DATA) \
     $(NULL)
 
 endif
-- 
2.40.0

From 4831ed595b346f1ab9224b44e571532785ca86c7 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Sun, 11 Jun 2023 16:25:56 +0900
Subject: [PATCH] setup: Unselect Add button in Select Input Method dialog

After click "More" ListBoxRow cell in the "Select an input method"
dialog, "Add" button is sensitive but clicking "Add" button causes
a SEGV in enginedialog.py:get_selected_engine() because the more cell
has no engine memmber.

BUG=rhbz#2213145
---
 setup/enginedialog.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/setup/enginedialog.py b/setup/enginedialog.py
index 470f801c..ba6a4819 100644
--- a/setup/enginedialog.py
+++ b/setup/enginedialog.py
@@ -4,7 +4,7 @@
 # ibus - The Input Bus
 #
 # Copyright (c) 2015 Peng Huang <shawn.p.huang@gmail.com>
-# Copyright (c) 2015-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
+# Copyright (c) 2015-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
 # Copyright (c) 2013-2015 Red Hat, Inc.
 #
 # This program is free software; you can redistribute it and/or
@@ -145,6 +145,8 @@ class EngineDialog(Gtk.Dialog):
 
     def __row_activated(self, box, row):
         if row == self.__more_row:
+            # Undo sensitive Gtk.ResponseType.APPLY button
+            self.__list.unselect_row(row)
             self.__show_more()
             return
         if row.back:
-- 
2.40.0

From 76f2f4a3aa25b399d65c947d76d61d5ae4723bc7 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Sun, 11 Jun 2023 19:59:17 +0900
Subject: [PATCH 1/2] configure: Run autoupdate

Avoids these warnings when running autogen.sh:

configure.ac:67: warning: The macro `AC_GNU_SOURCE' is obsolete.
configure.ac:67: You should run autoupdate.
./lib/autoconf/specific.m4:311: AC_GNU_SOURCE is expanded from...
configure.ac:67: the top level
configure.ac:129: warning: The macro `AC_PROG_CC_STDC' is obsolete.
configure.ac:129: You should run autoupdate.
./lib/autoconf/c.m4:1671: AC_PROG_CC_STDC is expanded from...
configure.ac:129: the top level
configure.ac:139: warning: The macro `AM_DISABLE_STATIC' is obsolete.
configure.ac:139: You should run autoupdate.
m4/ltoptions.m4:260: AM_DISABLE_STATIC is expanded from...
configure.ac:139: the top level
configure.ac:140: warning: The macro `AC_ISC_POSIX' is obsolete.
configure.ac:140: You should run autoupdate.
./lib/autoconf/specific.m4:549: AC_ISC_POSIX is expanded from...
configure.ac:140: the top level
configure.ac:141: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:141: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:141: the top level

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

diff --git a/configure.ac b/configure.ac
index 73583bab..cbdfbd05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,7 +64,7 @@ AC_SUBST(VALA_TARGET_GLIB_VERSION)
 # Init automake.
 AM_INIT_AUTOMAKE([1.11.1 parallel-tests])
 AM_MAINTAINER_MODE([enable])
-AC_GNU_SOURCE
+AC_USE_SYSTEM_EXTENSIONS
 
 # Support silent build rules. Disable
 # by either passing --disable-silent-rules to configure or passing V=1
@@ -126,7 +126,6 @@ AC_SUBST(DATE_DISPLAY)
 # Check for programs.
 AC_PROG_CC
 AM_PROG_CC_C_O
-AC_PROG_CC_STDC
 AM_PROG_VALAC([0.20])
 AC_PROG_INSTALL
 AC_PROG_MAKE_SET
@@ -136,9 +135,9 @@ AM_GNU_GETTEXT_VERSION([0.19.8])
 AM_GNU_GETTEXT([external])
 
 # Define PACKAGE_VERSION_* variables.
-AM_DISABLE_STATIC
-AC_ISC_POSIX
-AC_HEADER_STDC
+AC_DISABLE_STATIC([])
+AC_SEARCH_LIBS([strerror],[cposix])
+
 LT_INIT
 
 # Check header filess.
-- 
2.40.0

From b97e6669ea8127dd50ce49d061edd4ce579bbb42 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Sun, 11 Jun 2023 19:59:18 +0900
Subject: [PATCH 2/2] src/ibuscomposetable: Fix unaligned accesses

Fixes: https://github.com/ibus/ibus/commit/19ca1065

BUG=https://github.com/ibus/ibus/issues/2518
---
 src/ibuscomposetable.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/src/ibuscomposetable.c b/src/ibuscomposetable.c
index fc486692..c807c751 100644
--- a/src/ibuscomposetable.c
+++ b/src/ibuscomposetable.c
@@ -732,8 +732,8 @@ compose_data_to_variant (gconstpointer compose_data,
                          gboolean reverse_endianness,
                          GError **error)
 {
-    guint16 *compose_data16 = NULL;
-    guint32 *compose_data32 = NULL;
+    guint16 data16;
+    guint32 data32;
     guint16 *target_data16 = NULL;
     guint32 *target_data32 = NULL;
     gsize i, length;
@@ -759,18 +759,20 @@ compose_data_to_variant (gconstpointer compose_data,
                              "Failed to malloc");
                 return NULL;
             }
-            compose_data32 = (guint32*)compose_data;
-            for (i = 0; i < length; i++)
-                target_data32[i] = GUINT32_SWAP_LE_BE (compose_data32[i]);
+            for (i = 0; i < length; i++) {
+                memcpy(&data32, (char *)compose_data + i * sizeof (data32), sizeof (data32));
+                target_data32[i] = GUINT32_SWAP_LE_BE (data32);
+            }
         } else {
             if (!(target_data16 = g_new0 (guint16, length))) {
                 g_set_error (error, IBUS_ERROR, IBUS_ERROR_FAILED,
                              "Failed to malloc");
                 return NULL;
             }
-            compose_data16 = (guint16*)compose_data;
-            for (i = 0; i < length; i++)
-                target_data16[i] = GUINT16_SWAP_LE_BE (compose_data16[i]);
+            for (i = 0; i < length; i++) {
+                memcpy(&data16, (char *)compose_data + i * sizeof (data16), sizeof (data16));
+                target_data16[i] = GUINT16_SWAP_LE_BE (data16);
+            }
         }
     } else {
         if (is_32bit)
@@ -1365,8 +1367,9 @@ ibus_compose_table_new_with_list (GList   *compose_list,
         if (is_32bit) {
             for (j = 0; compose_data->values[j]; j++) {
                 g_assert (v_index_32bit + j <  v_size_32bit);
-                ibus_compose_seqs_32bit_second[v_index_32bit + j] =
-                        compose_data->values[j];
+                memcpy(&ibus_compose_seqs_32bit_second[v_index_32bit + j],
+                       &compose_data->values[j],
+                       sizeof *ibus_compose_seqs_32bit_second);
             }
             g_assert (m + 1 < (s_size_total - s_size_16bit) * n_index_stride);
             ibus_compose_seqs_32bit_first[m++] = j;
-- 
2.40.0