public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/ibus] rawhide: Fix CI and memory issues
@ 2026-11-12 2:27 Takao Fujiwara
0 siblings, 0 replies; only message in thread
From: Takao Fujiwara @ 2026-11-12 2:27 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/ibus
Branch : rawhide
Commit : 84307394467de3caa924d879d826d92dac9a5e15
Author : Takao Fujiwara <tfujiwar@redhat.com>
Date : 2026-11-12T11:24:56+09:00
Stats : +1678/-166 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/ibus/c/84307394467de3caa924d879d826d92dac9a5e15?branch=rawhide
Log:
Fix CI and memory issues
- Fix gsettings in ibus-desktop-testing in Fedora 45
- Fix typo in po/Makevars
- Tie ibus services to the graphical session
- Delete _process_key_event_hybrid_async()
- Fix to check if IBusInputContext is available in IBus clients
- Fix stale rules after connection destruction in ibus-daemon
---
diff --git a/ibus-1385349-segv-bus-proxy.patch b/ibus-1385349-segv-bus-proxy.patch
index 32f1f65..7a4ff15 100644
--- a/ibus-1385349-segv-bus-proxy.patch
+++ b/ibus-1385349-segv-bus-proxy.patch
@@ -1,6 +1,6 @@
-From 990b86ee8dc4c1e76dfa2459116ca282621082c3 Mon Sep 17 00:00:00 2001
+From 73f719eaa4841e74dc9396a71cef98973d1fce1a Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
-Date: Tue, 22 Sep 2026 19:48:59 +0900
+Date: Thu, 12 Nov 2026 10:41:00 +0900
Subject: [PATCH] Fix SEGV in bus_panel_proxy_focus_in()
rhbz#1350291 SEGV in BUS_IS_CONNECTION(skip_connection) in
@@ -17,9 +17,6 @@ WIP: Add a GError.
rhbz#1663528 SEGV in g_mutex_clear() in bus_dbus_impl_destroy()
If the mutex is not unlocked, g_mutex_clear() causes assert.
-rhbz#2195895 SEGV in client/x11/main.c:_xim_set_cursor_location()
-check if IBusInputContext was disconnected.
-
rhbz#1795499 rhbz#1936777 SEGV in ibus_bus_get_bus_address() because of
no _bus->priv.
_changed_cb() should not be called after ibus_bus_destroy() is called.
@@ -47,21 +44,19 @@ Closes: rhbz#1795499
Closes: rhbz#1771238
Closes: rhbz#1767976
Closes: rhbz#2151344
-Closes: rhbz#2195895
Closes: rhbz#2239633
Closes: rhbz#2480408
---
- bus/dbusimpl.c | 47 +++++++++++++++++++++++++++++---
+ bus/dbusimpl.c | 47 ++++++++++++++++++++++++++++++---
bus/panelproxy.c | 9 ++++++-
client/wayland/ibuswaylandim.c | 20 +++++++++++++-
- client/x11/main.c | 49 ++++++++++++++++++++++++++++++----
- portal/portal.c | 25 +++++++++++++----
+ portal/portal.c | 25 ++++++++++++++----
src/ibusbus.c | 6 +++++
- ui/gtk3/switcher.vala | 48 ++++++++++++++++++++-------------
- 7 files changed, 169 insertions(+), 35 deletions(-)
+ ui/gtk3/switcher.vala | 48 ++++++++++++++++++++--------------
+ 6 files changed, 125 insertions(+), 30 deletions(-)
diff --git a/bus/dbusimpl.c b/bus/dbusimpl.c
-index 143cdcd5..aff18a74 100644
+index 8c65fe1e..48d681e7 100644
--- a/bus/dbusimpl.c
+++ b/bus/dbusimpl.c
@@ -634,6 +634,7 @@ static void
@@ -149,7 +144,7 @@ index 143cdcd5..aff18a74 100644
if (incoming) {
/* is incoming message */
diff --git a/bus/panelproxy.c b/bus/panelproxy.c
-index 4c2c8885..a7bec193 100644
+index 3ac17b9a..5130f664 100644
--- a/bus/panelproxy.c
+++ b/bus/panelproxy.c
@@ -124,6 +124,8 @@ bus_panel_proxy_new (BusConnection *connection,
@@ -183,7 +178,7 @@ index 4c2c8885..a7bec193 100644
panel->panel_type = panel_type;
return panel;
diff --git a/client/wayland/ibuswaylandim.c b/client/wayland/ibuswaylandim.c
-index 95575951..d807bccf 100644
+index cfb58563..55c0bb34 100644
--- a/client/wayland/ibuswaylandim.c
+++ b/client/wayland/ibuswaylandim.c
@@ -547,7 +547,7 @@ ibus_wayland_im_commit_text (IBusWaylandIM *wlim,
@@ -255,155 +250,8 @@ index 95575951..d807bccf 100644
if (!priv->surrounding_text)
return;
-diff --git a/client/x11/main.c b/client/x11/main.c
-index accebde5..cac4cd61 100644
---- a/client/x11/main.c
-+++ b/client/x11/main.c
-@@ -45,6 +45,7 @@
- #include <iconv.h>
- #include <signal.h>
- #include <stdlib.h>
-+#include <unistd.h>
-
- #include <getopt.h>
-
-@@ -69,6 +70,7 @@ typedef struct _X11ICONN X11ICONN;
- typedef struct _X11IC X11IC;
- struct _X11IC {
- IBusInputContext *context;
-+ gboolean ibus_connected;
- Window client_window;
- Window focus_window;
- gint32 input_style;
-@@ -327,6 +329,18 @@ _xim_store_ic_values (X11IC *x11ic, IMChangeICStruct *call_data)
- return 1;
- }
-
-+static void
-+ibus_ic_connection_closed_cb (GDBusConnection *connection,
-+ gboolean remote_peer_vanished,
-+ GError *error,
-+ X11IC *x11ic)
-+{
-+ /* rhbz#2195895 The moment of the IBusBus disconnection would be
-+ * different from the moment of XIM_DISCONNECT.
-+ */
-+ x11ic->ibus_connected = FALSE;
-+}
-+
-
- static int
- xim_create_ic (XIMS xims, IMChangeICStruct *call_data)
-@@ -334,6 +348,7 @@ xim_create_ic (XIMS xims, IMChangeICStruct *call_data)
- static int base_icid = 1;
- X11IC *x11ic;
- guint32 capabilities = IBUS_CAP_FOCUS;
-+ GDBusConnection *connection;
-
- call_data->icid = base_icid ++;
-
-@@ -345,8 +360,9 @@ xim_create_ic (XIMS xims, IMChangeICStruct *call_data)
-
- x11ic->icid = call_data->icid;
- x11ic->connect_id = call_data->connect_id;
-- x11ic->conn = (X11ICONN *)g_hash_table_lookup (_connections,
-- GINT_TO_POINTER ((gint) call_data->connect_id));
-+ x11ic->conn = (X11ICONN *)g_hash_table_lookup (
-+ _connections,
-+ GINT_TO_POINTER ((gint) call_data->connect_id));
- if (x11ic->conn == NULL) {
- g_slice_free (X11IC, x11ic);
- g_return_val_if_reached (0);
-@@ -376,6 +392,10 @@ xim_create_ic (XIMS xims, IMChangeICStruct *call_data)
- G_CALLBACK (_context_enabled_cb), x11ic);
- g_signal_connect (x11ic->context, "disabled",
- G_CALLBACK (_context_disabled_cb), x11ic);
-+ connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (x11ic->context));
-+ x11ic->ibus_connected = !g_dbus_connection_is_closed (connection);
-+ g_signal_connect (connection, "closed",
-+ G_CALLBACK (ibus_ic_connection_closed_cb), x11ic);
-
-
- if (x11ic->input_style & XIMPreeditCallbacks)
-@@ -400,11 +420,19 @@ xim_destroy_ic (XIMS xims, IMChangeICStruct *call_data)
- LOG (1, "XIM_DESTROY_IC ic=%d connect_id=%d",
- call_data->icid, call_data->connect_id);
-
-- x11ic = (X11IC *)g_hash_table_lookup (_x11_ic_table,
-- GINT_TO_POINTER ((gint) call_data->icid));
-+ x11ic = (X11IC *)g_hash_table_lookup (
-+ _x11_ic_table,
-+ GINT_TO_POINTER ((gint) call_data->icid));
- g_return_val_if_fail (x11ic != NULL, 0);
-
- if (x11ic->context) {
-+ GDBusConnection *connection =
-+ g_dbus_proxy_get_connection (G_DBUS_PROXY (x11ic->context));
-+ x11ic->ibus_connected = FALSE;
-+ g_signal_handlers_disconnect_by_func (
-+ connection,
-+ (GCallback)ibus_ic_connection_closed_cb,
-+ x11ic);
- ibus_proxy_destroy ((IBusProxy *)x11ic->context);
- g_object_unref (x11ic->context);
- x11ic->context = NULL;
-@@ -412,7 +440,8 @@ xim_destroy_ic (XIMS xims, IMChangeICStruct *call_data)
-
- g_hash_table_remove (_x11_ic_table,
- GINT_TO_POINTER ((gint) call_data->icid));
-- x11ic->conn->clients = g_list_remove (x11ic->conn->clients, (gconstpointer)x11ic);
-+ x11ic->conn->clients = g_list_remove (x11ic->conn->clients,
-+ (gconstpointer)x11ic);
-
- g_free (x11ic->preedit_string);
- x11ic->preedit_string = NULL;
-@@ -439,6 +468,8 @@ xim_set_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
- x11ic = (X11IC *) g_hash_table_lookup (_x11_ic_table,
- GINT_TO_POINTER ((gint) call_data->icid));
- g_return_val_if_fail (x11ic != NULL, 0);
-+ if (!x11ic->ibus_connected)
-+ return 1;
-
- ibus_input_context_focus_in (x11ic->context);
- _xim_set_cursor_location (x11ic);
-@@ -458,6 +489,8 @@ xim_unset_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
- x11ic = (X11IC *) g_hash_table_lookup (_x11_ic_table,
- GINT_TO_POINTER ((gint) call_data->icid));
- g_return_val_if_fail (x11ic != NULL, 0);
-+ if (!x11ic->ibus_connected)
-+ return 1;
-
- ibus_input_context_focus_out (x11ic->context);
-
-@@ -712,6 +745,8 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
- _x11_ic_table,
- GINT_TO_POINTER ((gint) call_data->icid));
- g_return_val_if_fail (x11ic != NULL, 0);
-+ if (!x11ic->ibus_connected)
-+ return 0;
-
- xevent = (XKeyEvent*) &(call_data->event);
-
-@@ -870,6 +905,8 @@ _xim_set_cursor_location (X11IC *x11ic)
- }
- }
-
-+ if (!x11ic->ibus_connected)
-+ return;
- ibus_input_context_set_cursor_location (x11ic->context,
- preedit_area.x,
- preedit_area.y,
-@@ -950,6 +987,8 @@ xim_reset_ic (XIMS xims, IMResetICStruct *call_data)
- x11ic = (X11IC *) g_hash_table_lookup (_x11_ic_table,
- GINT_TO_POINTER ((gint) call_data->icid));
- g_return_val_if_fail (x11ic != NULL, 0);
-+ if (!x11ic->ibus_connected)
-+ return 1;
-
- ibus_input_context_reset (x11ic->context);
-
diff --git a/portal/portal.c b/portal/portal.c
-index 5cd38779..5110baad 100644
+index e9736b22..bcaf33d9 100644
--- a/portal/portal.c
+++ b/portal/portal.c
@@ -92,6 +92,11 @@ static void portal_context_g_signal (GDBusProxy *proxy,
@@ -462,7 +310,7 @@ index 5cd38779..5110baad 100644
g_object_unref (portal_context);
}
diff --git a/src/ibusbus.c b/src/ibusbus.c
-index 540d1da3..defdb73b 100644
+index 45094502..473b3e64 100644
--- a/src/ibusbus.c
+++ b/src/ibusbus.c
@@ -750,6 +750,12 @@ ibus_bus_destroy (IBusObject *object)
@@ -479,7 +327,7 @@ index 540d1da3..defdb73b 100644
bus->priv->monitor = NULL;
}
diff --git a/ui/gtk3/switcher.vala b/ui/gtk3/switcher.vala
-index d4a5fa11..788eea06 100644
+index 99ce2b35..e7fc8265 100644
--- a/ui/gtk3/switcher.vala
+++ b/ui/gtk3/switcher.vala
@@ -251,27 +251,37 @@ class Switcher : Gtk.Window {
@@ -540,5 +388,5 @@ index d4a5fa11..788eea06 100644
seat.ungrab();
--
-2.55.0
+2.56.0
diff --git a/ibus-HEAD.patch b/ibus-HEAD.patch
index e69de29..328b9c9 100644
--- a/ibus-HEAD.patch
+++ b/ibus-HEAD.patch
@@ -0,0 +1,1654 @@
+From 23682789bec3b479f9a01e5a69ff58fbc2d9d709 Mon Sep 17 00:00:00 2001
+From: fujiwarat <takao.fujiwara1@gmail.com>
+Date: Wed, 7 Oct 2026 22:16:35 +0900
+Subject: [PATCH 1/8] src/tests/ibus-desktop-testing: Fix gsettings in Fedora 45
+
+`dbus_run_session` deletes the `XDG_RUNTIME_DIR` environment variable.
+
+Part-of: #2965
+---
+ src/tests/ibus-desktop-testing-module | 50 +++++++++++++++++++--------
+ 1 file changed, 36 insertions(+), 14 deletions(-)
+
+diff --git a/src/tests/ibus-desktop-testing-module b/src/tests/ibus-desktop-testing-module
+index 96308656..2cf83a12 100755
+--- a/src/tests/ibus-desktop-testing-module
++++ b/src/tests/ibus-desktop-testing-module
+@@ -517,19 +517,37 @@ init_gnome()
+ # debug messages to gsettings output and could not get the result correctly.
+ backup_G_MESSAGES_DEBUG="$G_MESSAGES_DEBUG"
+ unset G_MESSAGES_DEBUG
++ sudo -u "$LOGIN_USER" systemctl status --no-pager dbus
++ LOGIN_UID=`id -u "$LOGIN_USER"`
++ LOGIN_GID=`id -g "$LOGIN_USER"`
++ RUNNING_USER_SYSTEMD=1
++ if ! systemctl status --no-pager "user@${LOGIN_UID}" ; then
++ RUNNING_USER_SYSTEMD=0
++ systemctl start "user@${LOGIN_UID}"
++ fi
++ systemctl status --no-pager "user@${LOGIN_UID}"
++ ls -al "/run/user/$LOGIN_UID" || :
++ df "/run/user/$LOGIN_UID"
++ if test ! -d "/run/user/$LOGIN_UID/dconf" ; then
++ mkdir -p "/run/user/$LOGIN_UID/dconf"
++ chown "$LOGIN_USER:$LOGIN_GID" "/run/user/$LOGIN_UID/dconf"
++ chmod 700 "/run/user/$LOGIN_UID/dconf"
++ fi
++ # `dbus-run-session` deletes the `XDG_RUNTIME_DIR` env variable.
++ DBUS_RUN_SESSION="env XDG_RUNTIME_DIR=/run/user/$LOGIN_UID DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$LOGIN_UID/bus"
+ # Disable Tour dialog to get focus
+ GET_WELCOME_DIALOG="gsettings get org.gnome.shell welcome-dialog-last-shown-version"
+ if test $LOGIN_USER = $USER ; then
+- V=`dbus-run-session $GET_WELCOME_DIALOG`
++ V=`$DBUS_RUN_SESSION $GET_WELCOME_DIALOG`
+ else
+- V=`sudo -u $LOGIN_USER dbus-run-session $GET_WELCOME_DIALOG`
++ V=`sudo -u $LOGIN_USER $DBUS_RUN_SESSION $GET_WELCOME_DIALOG`
+ fi
+ if [ x"$V" = x"''" ] ; then
+ SET_WELCOME_DIALOG="gsettings set org.gnome.shell welcome-dialog-last-shown-version '100'"
+ if test $LOGIN_USER = $USER ; then
+- dbus-run-session $SET_WELCOME_DIALOG
++ $DBUS_RUN_SESSION $SET_WELCOME_DIALOG
+ else
+- sudo -u $LOGIN_USER dbus-run-session $SET_WELCOME_DIALOG
++ sudo -u $LOGIN_USER $DBUS_RUN_SESSION $SET_WELCOME_DIALOG
+ fi
+ fi
+ # gnome-shell now starts overview mode by login.
+@@ -614,23 +632,23 @@ _EOF_LOCALE_CONF
+ fi
+ GET_DISABLE_USER_EX="gsettings get org.gnome.shell disable-user-extensions"
+ if test $LOGIN_USER = $USER ; then
+- V=`dbus-run-session $GET_DISABLE_USER_EX`
++ V=`$DBUS_RUN_SESSION $GET_DISABLE_USER_EX`
+ else
+- V=`sudo -u $LOGIN_USER dbus-run-session $GET_DISABLE_USER_EX`
++ V=`sudo -u $LOGIN_USER $DBUS_RUN_SESSION $GET_DISABLE_USER_EX`
+ fi
+ if [ x"$V" = x"true" ] ; then
+ SET_DISABLE_USER_EX="gsettings set org.gnome.shell disable-user-extensions false"
+ if test $LOGIN_USER = $USER ; then
+- dbus-run-session $SET_DISABLE_USER_EX
++ $DBUS_RUN_SESSION $SET_DISABLE_USER_EX
+ else
+- sudo -u $LOGIN_USER dbus-run-session $SET_DISABLE_USER_EX
++ sudo -u $LOGIN_USER $DBUS_RUN_SESSION $SET_DISABLE_USER_EX
+ fi
+ fi
+ GET_ENABLED_EXS="gsettings get org.gnome.shell enabled-extensions"
+ if test $LOGIN_USER = $USER ; then
+- V=`dbus-run-session $GET_ENABLED_EXS`
++ V=`$DBUS_RUN_SESSION $GET_ENABLED_EXS`
+ else
+- V=`sudo -u $LOGIN_USER dbus-run-session $GET_ENABLED_EXS`
++ V=`sudo -u $LOGIN_USER $DBUS_RUN_SESSION $GET_ENABLED_EXS`
+ fi
+ echo "$V" | grep "no-overview" > /dev/null
+ V2=$?
+@@ -643,21 +661,25 @@ _EOF_LOCALE_CONF
+ fi
+ SET_ENABLED_EXS="gsettings set org.gnome.shell enabled-extensions \"$V4\""
+ if test $LOGIN_USER = $USER ; then
+- eval dbus-run-session $SET_ENABLED_EXS
++ eval $DBUS_RUN_SESSION $SET_ENABLED_EXS
+ else
+- eval sudo -u $LOGIN_USER dbus-run-session $SET_ENABLED_EXS
++ eval sudo -u $LOGIN_USER $DBUS_RUN_SESSION $SET_ENABLED_EXS
+ fi
+ fi
+ # Disable notify dialog when the disk usage is low.
+ SET_NOTIFY_DISK="gsettings set org.gnome.settings-daemon.plugins.housekeeping free-size-gb-no-notify 0"
+ if test $LOGIN_USER = $USER ; then
+- eval dbus-run-session $SET_NOTIFY_DISK
++ eval $DBUS_RUN_SESSION $SET_NOTIFY_DISK
+ else
+- eval sudo -u $LOGIN_USER dbus-run-session $SET_NOTIFY_DISK
++ eval sudo -u $LOGIN_USER $DBUS_RUN_SESSION $SET_NOTIFY_DISK
+ fi
+ if [ x"$backup_G_MESSAGES_DEBUG" != x ] ; then
+ export G_MESSAGES_DEBUG="$backup_G_MESSAGES_DEBUG"
+ fi
++ if test $RUNNING_USER_SYSTEMD -eq 0 ; then
++ systemctl stop "user@${LOGIN_UID}"
++ fi
++ systemctl status --no-pager "user@${LOGIN_UID}" || :
+ }
+
+
+--
+2.56.0
+
+From 3f4b027b41e8580de5ad453b18e18caee1026163 Mon Sep 17 00:00:00 2001
+From: fujiwarat <takao.fujiwara1@gmail.com>
+Date: Fri, 6 Nov 2026 15:50:48 +0900
+Subject: [PATCH 2/8] po: Fix typo in Makevars
+
+Add a workaround for msgfmt error with th parallel build.
+
+Part-of: #2965
+---
+ po/Makevars | 12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+diff --git a/po/Makevars b/po/Makevars
+index 1d16cc98..1076dce2 100644
+--- a/po/Makevars
++++ b/po/Makevars
+@@ -44,5 +44,13 @@ MSGID_BUGS_ADDRESS = $(PACKAGE_BUGREPORT)
+ EXTRA_LOCALE_CATEGORIES =
+
+ # https://wiki.gnome.org/Initiatives/GnomeGoals/GettextMigration
+-PO_DEPENDS_ON_POT = "no"
+-DIST_DEPENDS_ON_UPDAE_PO = "no"
++PO_DEPENDS_ON_POT = no
++DIST_DEPENDS_ON_UPDATE_PO = no
++
++# FIXME: `make -j$(nproc) -C po` calls duplicated msgfmt:
++# https://bugzilla.redhat.com/show_bug.cgi?id=2567178
++# rm -f it.gmo && msgfmt -c --statistics --verbose -o it.gmo it.po
++# rm -f ja.gmo && msgfmt -c --statistics --verbose -o ja.gmo ja.po
++# rm -f it.gmo && msgfmt -c --statistics --verbose -o it.gmo it.po
++# Force sequential execution inside the po directory to protect msgfmt
++.NOTPARALLEL:
+--
+2.56.0
+
+From 5e82535b09b32935dde12d5dba81510ed6ad54ba Mon Sep 17 00:00:00 2001
+From: Joan Torres Lopez <joantolo@redhat.com>
+Date: Wed, 28 Oct 2026 20:01:45 +0100
+Subject: [PATCH 3/8] bus: Tie generic-session ibus-daemon to the graphical session
+
+The GNOME session unit already ties ibus-daemon to
+gnome-session-initialized.target, but the generic (non-GNOME) session
+unit had no PartOf=/After= to any session target, so a
+D-Bus-activated instance could outlive logout or start with no session
+at all. Tie it to graphical-session.target instead.
+
+Part-of: #2974
+---
+ bus/services/org.freedesktop.IBus.session.generic.service.in | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/bus/services/org.freedesktop.IBus.session.generic.service.in b/bus/services/org.freedesktop.IBus.session.generic.service.in
+index e7b7ce4f..a5f60663 100644
+--- a/bus/services/org.freedesktop.IBus.session.generic.service.in
++++ b/bus/services/org.freedesktop.IBus.session.generic.service.in
+@@ -4,6 +4,8 @@ CollectMode=inactive-or-failed
+
+ # Never run in GNOME
+ Conflicts=gnome-session-initialized.target
++PartOf=graphical-session.target
++After=graphical-session.target
+
+ [Service]
+ Type=dbus
+--
+2.56.0
+
+From 995e14f4e5b54005d12f689bfed36b3dd2112a8d Mon Sep 17 00:00:00 2001
+From: Joan Torres Lopez <joantolo@redhat.com>
+Date: Wed, 28 Oct 2026 20:01:52 +0100
+Subject: [PATCH 4/8] portal: Tie ibus-portal to the graphical session
+
+ibus-portal is D-Bus activatable but had no systemd unit at all, so an
+activated instance had no connection to the session's lifecycle. Add a
+systemd user unit (meson and autotools) tied to
+graphical-session.target with PartOf=/After=, and route
+activation through it via SystemdService=.
+
+Part-of: #2974
+---
+ portal/Makefile.am | 10 +++++++++-
+ portal/ibus-portal.service.in | 9 +++++++++
+ portal/meson.build | 12 ++++++++++++
+ portal/org.freedesktop.portal.IBus.service.in | 1 +
+ 4 files changed, 31 insertions(+), 1 deletion(-)
+ create mode 100644 portal/ibus-portal.service.in
+
+diff --git a/portal/Makefile.am b/portal/Makefile.am
+index 15d5b181..4d2f1cf6 100644
+--- a/portal/Makefile.am
++++ b/portal/Makefile.am
+@@ -72,9 +72,15 @@ dbusservice_in_files = org.freedesktop.portal.IBus.service.in
+ dbusservice_DATA = $(dbusservice_in_files:.service.in=.service)
+ dbusservicedir=${datadir}/dbus-1/services
+
+-org.freedesktop.portal.IBus.service: org.freedesktop.portal.IBus.service.in
++%.service: %.service.in
+ $(AM_V_GEN) sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@.tmp && mv $@.tmp $@
+
++if ENABLE_SYSTEMD
++systemdservice_in_files = ibus-portal.service.in
++systemdservice_DATA = $(systemdservice_in_files:.service.in=.service)
++systemdservicedir = $(SYSTEMD_USER_UNIT_DIR)
++endif
++
+ $(ibus_dbus_built_sources) : org.freedesktop.IBus.Portal.xml
+ $(AM_V_GEN) $(GDBUS_CODEGEN) \
+ --interface-prefix org.freedesktop.IBus. \
+@@ -85,11 +91,13 @@ $(ibus_dbus_built_sources) : org.freedesktop.IBus.Portal.xml
+
+ EXTRA_DIST = \
+ $(dbusservice_in_files) \
++ $(systemdservice_in_files) \
+ org.freedesktop.IBus.Portal.xml \
+ $(NULL)
+
+ CLEANFILES = \
+ $(dbusservice_DATA) \
++ $(systemdservice_DATA) \
+ $(NULL)
+
+
+diff --git a/portal/ibus-portal.service.in b/portal/ibus-portal.service.in
+new file mode 100644
+index 00000000..a3d75f0a
+--- /dev/null
++++ b/portal/ibus-portal.service.in
+@@ -0,0 +1,9 @@
++[Unit]
++Description=IBus Portal
++PartOf=graphical-session.target
++After=graphical-session.target
++
++[Service]
++Type=dbus
++BusName=org.freedesktop.portal.IBus
++ExecStart=@libexecdir@/ibus-portal
+diff --git a/portal/meson.build b/portal/meson.build
+index a733830a..8ea8ebeb 100644
+--- a/portal/meson.build
++++ b/portal/meson.build
+@@ -9,6 +9,18 @@ configure_file(
+ install_dir: get_option('datadir') / 'dbus-1' / 'services',
+ )
+
++if enable_systemd
++ configure_file(
++ input: 'ibus-portal.service.in',
++ output: '@BASENAME@',
++ configuration: {
++ 'libexecdir': get_option('prefix') / get_option('libexecdir'),
++ },
++ install: true,
++ install_dir: systemduserunitdir,
++ )
++endif
++
+ # Portal executable
+ ibus_portal_sources = files(
+ 'portal.c',
+diff --git a/portal/org.freedesktop.portal.IBus.service.in b/portal/org.freedesktop.portal.IBus.service.in
+index 47ae9ffc..56995984 100644
+--- a/portal/org.freedesktop.portal.IBus.service.in
++++ b/portal/org.freedesktop.portal.IBus.service.in
+@@ -1,3 +1,4 @@
+ [D-BUS Service]
+ Name=org.freedesktop.portal.IBus
+ Exec=@libexecdir@/ibus-portal
++SystemdService=ibus-portal.service
+--
+2.56.0
+
+From 08034f8e70c5a4d69439fcb84f6057eba0595ded Mon Sep 17 00:00:00 2001
+From: fujiwarat <takao.fujiwara1@gmail.com>
+Date: Mon, 9 Nov 2026 14:28:21 +0900
+Subject: [PATCH 5/8] client: Delete _process_key_event_hybrid_async()
+
+Originally _process_key_event_hybrid_async() has been added to fix
+the event order using _process_key_event_async() in the issue;
+that X11 applications does not receive the right key events (#2480).
+
+But it causes an another regression; that some key events are skipped
+in GTK applications in _process_key_event_hybrid_async() (#2486).
+
+If we would fix #2486 in the hybrid process_key_event, it would mean the
+logics are almost same between the hybrid process key event and the async
+one like the PR #2535 and it could bring up the issue #2480 in
+_process_key_event_hybrid_async().
+
+Now all issues has been fixed in the _process_key_event_sync() by
+the commits 38f09c6 and 7502abbe in the PR #2532
+to add ibus_input_context_set_post_process_key_event()
+and ibus_input_context_post_process_key_event() in
+_process_key_event_sync().
+
+So the _process_key_event_hybrid_async() is no longer needed and
+it can be deleted safely now.
+
+Part-of: #2960
+Closes: #2535
+---
+ client/gtk2/ibusimcontext.c | 102 +-------------------------
+ client/wayland/ibuswaylandim.c | 126 +--------------------------------
+ client/x11/main.c | 124 +-------------------------------
+ 3 files changed, 7 insertions(+), 345 deletions(-)
+
+diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
+index df2da28f..f993aad0 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-2025 Takao Fujiwara <takao.fujiwara1@gmail.com>
++ * Copyright (C) 2015-2026 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (C) 2008-2025 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+@@ -398,12 +398,6 @@ typedef struct {
+ IBusIMContext *ibusimcontext;
+ } ProcessKeyEventData;
+
+-typedef struct {
+- int count;
+- guint count_cb_id;
+- gboolean retval;
+-} ProcessKeyEventReplyData;
+-
+
+ static void
+ _process_key_event_done (GObject *object,
+@@ -455,45 +449,6 @@ _process_key_event_done (GObject *object,
+ }
+
+
+-static void
+-_process_key_event_reply_done (GObject *object,
+- GAsyncResult *res,
+- gpointer user_data)
+-{
+- IBusInputContext *context = (IBusInputContext *)object;
+- ProcessKeyEventReplyData *data = (ProcessKeyEventReplyData *)user_data;
+- GError *error = NULL;
+- gboolean retval = ibus_input_context_process_key_event_async_finish (
+- context,
+- res,
+- &error);
+- if (error != NULL) {
+- g_warning ("Process Key Event failed: %s.", error->message);
+- g_error_free (error);
+- }
+- g_return_if_fail (data);
+- data->retval = retval;
+- data->count = 0;
+- g_source_remove (data->count_cb_id);
+-}
+-
+-
+-static gboolean
+-_process_key_event_count_cb (gpointer user_data)
+-{
+- ProcessKeyEventReplyData *data = (ProcessKeyEventReplyData *)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;
+- return G_SOURCE_REMOVE;
+- }
+- return G_SOURCE_CONTINUE;
+-}
+-
+-
+ static gboolean
+ _process_key_event_sync (IBusInputContext *context,
+ guint keyval,
+@@ -547,48 +502,6 @@ _process_key_event_async (IBusInputContext *context,
+
+
+ static gboolean
+-_process_key_event_hybrid_async (IBusInputContext *context,
+- guint keyval,
+- guint keycode,
+- guint state)
+-{
+- GSource *source = g_timeout_source_new (1);
+- ProcessKeyEventReplyData *data = NULL;
+- gboolean retval = FALSE;
+-
+- if (source)
+- data = g_slice_new0 (ProcessKeyEventReplyData);
+- if (!data) {
+- g_warning ("Cannot wait for the reply of the process key event.");
+- retval = _process_key_event_sync (context, keyval, keycode, state);
+- if (source)
+- g_source_destroy (source);
+- return retval;
+- }
+- data->count = 1;
+- g_source_attach (source, NULL);
+- g_source_unref (source);
+- data->count_cb_id = g_source_get_id (source);
+- ibus_input_context_process_key_event_async (context,
+- keyval,
+- keycode - 8,
+- state,
+- -1,
+- NULL,
+- _process_key_event_reply_done,
+- data);
+- g_source_set_callback (source, _process_key_event_count_cb, data, NULL);
+- while (data->count)
+- g_main_context_iteration (NULL, TRUE);
+- /* #2498 Checking source->ref_count might cause Nautilus hang up
+- */
+- retval = data->retval;
+- g_slice_free (ProcessKeyEventReplyData, data);
+- return retval;
+-}
+-
+-
+-static gboolean
+ _process_key_event (IBusInputContext *context,
+ #if GTK_CHECK_VERSION (3, 98, 4)
+ GdkEvent *event,
+@@ -624,11 +537,6 @@ _process_key_event (IBusInputContext *context,
+ retval = _process_key_event_sync (context, keyval, keycode, state);
+ break;
+ }
+- case 2: {
+- retval = _process_key_event_hybrid_async (context,
+- keyval, keycode, state);
+- break;
+- }
+ default: {
+ retval = _process_key_event_async (context,
+ keyval, keycode, state,
+@@ -867,6 +775,7 @@ _get_char_env (const gchar *name,
+ if (value == NULL)
+ return defval;
+
++ /* The mode 0 and 2 have the same behavior for the back compatibility. */
+ if (g_strcmp0 (value, "") == 0 ||
+ g_strcmp0 (value, "0") == 0 ||
+ g_strcmp0 (value, "false") == 0 ||
+@@ -874,7 +783,7 @@ _get_char_env (const gchar *name,
+ g_strcmp0 (value, "FALSE") == 0) {
+ return 0;
+ } else if (!g_strcmp0 (value, "2")) {
+- return 2;
++ return 0;
+ }
+
+ return 1;
+@@ -997,11 +906,6 @@ ibus_im_context_class_init (IBusIMContextClass *class)
+ * the IBus client does not perform anything. Otherwise the IBus client
+ * forwards the key event with the gdk_event_put() in GTK3,
+ * gtk_im_context_filter_key() in GTK4, IMForwardEvent() in XIM API.
+- * 2: Hybrid asynchronous process key event:
+- * Wait for the return of the IBus "ProcessKeyEvent" D-Bus method
+- * *asynchronously* with a GSource loop and forward the return value
+- * to the IBus event owner synchronously. So IBus clients perform
+- * virtually synchronously to cover problems of IBus synchronous APIs.
+ *
+ * The purpose of the asynchronous process is that each IBus input
+ * method can process the key events without D-Bus timeout and also
+diff --git a/client/wayland/ibuswaylandim.c b/client/wayland/ibuswaylandim.c
+index 70869b0f..fed8a0fa 100644
+--- a/client/wayland/ibuswaylandim.c
++++ b/client/wayland/ibuswaylandim.c
+@@ -231,7 +231,6 @@ struct _IBusWaylandKeyEvent
+ guint count_cb_id;
+ guint repeat_rate_id;
+ char *ibus_object_path;
+- gboolean retval;
+ };
+ typedef struct _IBusWaylandKeyEvent IBusWaylandKeyEvent;
+
+@@ -298,6 +297,7 @@ _get_char_env (const gchar *name,
+ if (value == NULL)
+ return defval;
+
++ /* The mode 0 and 2 have the same behavior for the back compatibility. */
+ if (g_strcmp0 (value, "") == 0 ||
+ g_strcmp0 (value, "0") == 0 ||
+ g_strcmp0 (value, "false") == 0 ||
+@@ -305,7 +305,7 @@ _get_char_env (const gchar *name,
+ g_strcmp0 (value, "FALSE") == 0) {
+ return 0;
+ } else if (!g_strcmp0 (value, "2")) {
+- return 2;
++ return 0;
+ }
+
+ return 1;
+@@ -2109,55 +2109,6 @@ _process_key_event_done (GObject *object,
+ }
+
+
+-static void
+-_process_key_event_reply_done (GObject *object,
+- GAsyncResult *res,
+- gpointer user_data)
+-{
+- IBusInputContext *context = (IBusInputContext *)object;
+- IBusWaylandKeyEvent *event = (IBusWaylandKeyEvent *)user_data;
+- GError *error = NULL;
+- gboolean retval = ibus_input_context_process_key_event_async_finish (
+- context,
+- res,
+- &error);
+- if (error != NULL) {
+- IBusWaylandIMPrivate *priv = NULL;
+- if (event && event->wlim && IBUS_IS_WAYLAND_IM (event->wlim)) {
+- priv = ibus_wayland_im_get_instance_private (event->wlim);
+- }
+- if (priv && priv->log) {
+- fprintf (priv->log, "Process Key Event failed: %s\n",
+- error->message);
+- fflush (priv->log);
+- } else {
+- g_warning ("Process Key Event failed: %s", error->message);
+- }
+- g_error_free (error);
+- }
+- g_return_if_fail (event);
+- event->retval = retval;
+- event->count = 0;
+- g_source_remove (event->count_cb_id);
+-}
+-
+-
+-static gboolean
+-_process_key_event_count_cb (gpointer user_data)
+-{
+- IBusWaylandKeyEvent *event = (IBusWaylandKeyEvent *)user_data;
+- g_return_val_if_fail (event, G_SOURCE_REMOVE);
+- if (!event->count)
+- return G_SOURCE_REMOVE;
+- /* Wait for about 10 secs. */
+- if (event->count++ == 10000) {
+- event->count = 0;
+- return G_SOURCE_REMOVE;
+- }
+- return G_SOURCE_CONTINUE;
+-}
+-
+-
+ static void
+ _process_key_event_sync (IBusWaylandIM *wlim,
+ IBusWaylandKeyEvent *event)
+@@ -2231,71 +2182,6 @@ _process_key_event_async (IBusWaylandIM *wlim,
+ }
+
+
+-static void
+-_process_key_event_hybrid_async (IBusWaylandIM *wlim,
+- IBusWaylandKeyEvent *event)
+-{
+- IBusWaylandIMPrivate *priv;
+- GSource *source;
+- IBusWaylandKeyEvent *async_event = NULL;
+-
+- g_return_if_fail (IBUS_IS_WAYLAND_IM (wlim));
+- g_assert (event);
+- priv = ibus_wayland_im_get_instance_private (wlim);
+- source = g_timeout_source_new (1);
+- if (source)
+- async_event = g_slice_new0 (IBusWaylandKeyEvent);
+- if (!async_event) {
+- if (priv->log) {
+- fprintf (priv->log, "Cannot wait for the reply of the "
+- "process key event.\n");
+- fflush (priv->log);
+- } else {
+- g_warning ("Cannot wait for the reply of the process key event.");
+- }
+- _process_key_event_sync (wlim, event);
+- if (source)
+- g_source_destroy (source);
+- return;
+- }
+- async_event->count = 1;
+- async_event->wlim = wlim;
+- g_source_attach (source, NULL);
+- g_source_unref (source);
+- async_event->count_cb_id = g_source_get_id (source);
+- ibus_input_context_process_key_event_async (priv->ibuscontext,
+- event->sym,
+- event->key,
+- event->modifiers,
+- -1,
+- NULL,
+- _process_key_event_reply_done,
+- async_event);
+- g_source_set_callback (source, _process_key_event_count_cb,
+- async_event, NULL);
+- while (async_event->count)
+- g_main_context_iteration (NULL, TRUE);
+- /* #2498 Checking source->ref_count might cause Nautilus hang up
+- */
+- if (priv->ibuscontext) {
+- async_event->retval = ibus_wayland_im_post_key (wlim,
+- event->key,
+- event->modifiers,
+- event->state,
+- event->sym,
+- async_event->retval);
+- }
+- if (priv->ibuscontext && !async_event->retval) {
+- ibus_wayland_im_keycode (wlim,
+- event->key_serial,
+- event->time,
+- event->key,
+- event->state);
+- }
+- g_slice_free (IBusWaylandKeyEvent, async_event);
+-}
+-
+-
+ static gboolean
+ _process_key_event_repeat_rate_cb (gpointer user_data)
+ {
+@@ -2327,9 +2213,6 @@ _process_key_event_repeat_rate_cb (gpointer user_data)
+ case 1:
+ _process_key_event_sync (wlim, event);
+ break;
+- case 2:
+- _process_key_event_hybrid_async (wlim, event);
+- break;
+ default:
+ _process_key_event_async (wlim, event);
+ }
+@@ -2377,9 +2260,6 @@ _process_key_event_repeat_delay_cb (gpointer user_data)
+ case 1:
+ _process_key_event_sync (event->wlim, event);
+ break;
+- case 2:
+- _process_key_event_hybrid_async (event->wlim, event);
+- break;
+ default:
+ _process_key_event_async (event->wlim, event);
+ }
+@@ -2586,8 +2466,6 @@ input_method_keyboard_key (void *data,
+ switch (_use_sync_mode) {
+ case 1:
+ return _process_key_event_sync (wlim, &event);
+- case 2:
+- return _process_key_event_hybrid_async (wlim, &event);
+ default:
+ return _process_key_event_async (wlim, &event);
+ }
+diff --git a/client/x11/main.c b/client/x11/main.c
+index 35410a79..7c05111c 100644
+--- a/client/x11/main.c
++++ b/client/x11/main.c
+@@ -49,8 +49,6 @@
+ #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)) { \
+@@ -493,9 +491,6 @@ _xim_forward_key_event_done (X11IC *x11ic,
+
+
+ typedef struct {
+- int count;
+- guint count_cb_id;
+- gboolean retval;
+ X11IC *x11ic;
+ CARD16 connect_id;
+ XEvent event;
+@@ -534,59 +529,6 @@ _process_key_event_done (GObject *object,
+ }
+
+
+-static void
+-_process_key_event_reply_done (GObject *object,
+- GAsyncResult *res,
+- gpointer user_data)
+-{
+- IBusInputContext *context = (IBusInputContext *)object;
+- ProcessKeyEventReplyData *data = (ProcessKeyEventReplyData *)user_data;
+- GError *error = NULL;
+- gboolean retval = ibus_input_context_process_key_event_async_finish (
+- context,
+- res,
+- &error);
+- if (error != NULL) {
+- g_warning ("Process Key Event failed: %s.", error->message);
+- g_error_free (error);
+- }
+- 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);
+-}
+-
+-
+-static gboolean
+-_process_key_event_count_cb (gpointer user_data)
+-{
+- ProcessKeyEventReplyData *data = (ProcessKeyEventReplyData *)user_data;
+- g_return_val_if_fail (data, G_SOURCE_REMOVE);
+- if (!data->count)
+- return G_SOURCE_REMOVE;
+- 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;
+-}
+-
+-
+ static int
+ _process_key_event_sync (X11IC *x11ic,
+ IMForwardEventStruct *call_data,
+@@ -637,67 +579,6 @@ _process_key_event_async (X11IC *x11ic,
+ }
+
+
+-static int
+-_process_key_event_hybrid_async (X11IC *x11ic,
+- IMForwardEventStruct *call_data,
+- GdkEventKey *event)
+-{
+- GSource *source;
+- ProcessKeyEventReplyData *data = NULL;
+- gboolean bus_retval;
+-
+- g_assert (x11ic);
+- g_assert (call_data);
+- g_assert (event);
+- source = g_timeout_source_new (1);
+- if (source)
+- data = g_slice_new0 (ProcessKeyEventReplyData);
+- if (!data) {
+- int xim_retval;
+- g_warning ("Cannot wait for the reply of the process key event.");
+- xim_retval = _process_key_event_sync (x11ic, call_data, event);
+- if (source)
+- g_source_destroy (source);
+- return xim_retval;
+- }
+- 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 = call_data->event;
+- ibus_input_context_process_key_event_async (x11ic->context,
+- event->keyval,
+- event->hardware_keycode - 8,
+- event->state,
+- -1,
+- NULL,
+- _process_key_event_reply_done,
+- data);
+- g_source_set_callback (source, _process_key_event_count_cb,
+- data, NULL);
+- while (data->count > 0 && data->count < MAX_WAIT_KEY_TIME)
+- g_main_context_iteration (NULL, TRUE);
+- /* #2498 Checking source->ref_count might cause Nautilus hang up
+- */
+- bus_retval = data->retval;
+- if (data->count == 0) {
+- g_slice_free (ProcessKeyEventReplyData, data);
+- return 1;
+- }
+-
+- g_slice_free (ProcessKeyEventReplyData, data);
+- if (g_hash_table_lookup (_connections,
+- GINT_TO_POINTER ((gint)call_data->connect_id))
+- == NULL) {
+- return 1;
+- }
+- _xim_forward_key_event_done (x11ic, &call_data->event, bus_retval);
+- return 1;
+-}
+-
+-
+ static int
+ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
+ {
+@@ -728,8 +609,6 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
+ switch (_use_sync_mode) {
+ case 1:
+ return _process_key_event_sync (x11ic, call_data, &event);
+- case 2:
+- return _process_key_event_hybrid_async (x11ic, call_data, &event);
+ default:
+ return _process_key_event_async (x11ic, call_data, &event);
+ }
+@@ -1193,6 +1072,7 @@ _get_char_env (const gchar *name,
+ if (value == NULL)
+ return defval;
+
++ /* The mode 0 and 2 have the same behavior for the back compatibility. */
+ if (g_strcmp0 (value, "") == 0 ||
+ g_strcmp0 (value, "0") == 0 ||
+ g_strcmp0 (value, "false") == 0 ||
+@@ -1200,7 +1080,7 @@ _get_char_env (const gchar *name,
+ g_strcmp0 (value, "FALSE") == 0) {
+ return 0;
+ } else if (!g_strcmp0 (value, "2")) {
+- return 2;
++ return 0;
+ }
+
+ return 1;
+--
+2.56.0
+
+From c7df2f5ee989eece36690ad8016de3c50e74d793 Mon Sep 17 00:00:00 2001
+From: fujiwarat <takao.fujiwara1@gmail.com>
+Date: Sun, 27 Sep 2026 23:03:11 +0900
+Subject: [PATCH 6/8] client: Fix to check if IBusInputContext is available
+
+- Declare g_assert() instead of g_return_if_fail() if they
+ cannot happen logically.
+- Use g_object_ref() during D-Bus methods or async functions.
+- Check `!IBUS_IS_INPUT_CONTEXT(context)` instead of `!context`
+ for g_object_ref().
+- Use the return value of g_object_ref() to work after the original
+ object is cleared.
+
+Part-of: #2960
+Closes: #2878
+Closes: #2977
+Closes: #2978
+---
+ client/gtk2/ibusimcontext.c | 57 +++++++++++++++++++-----
+ client/wayland/ibuswaylandim.c | 67 +++++++++++++++++-----------
+ client/x11/main.c | 81 ++++++++++++++++++++--------------
+ 3 files changed, 135 insertions(+), 70 deletions(-)
+
+diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
+index f993aad0..b9f09050 100644
+--- a/client/gtk2/ibusimcontext.c
++++ b/client/gtk2/ibusimcontext.c
+@@ -408,12 +408,13 @@ _process_key_event_done (GObject *object,
+
+ ProcessKeyEventData *data = (ProcessKeyEventData *)user_data;
+ GdkEvent *event = data->event;
+-#if GTK_CHECK_VERSION (3, 98, 4)
+- IBusIMContext *ibusimcontext = data->ibusimcontext;
+-#endif
+ GError *error = NULL;
+ gboolean retval;
++#if GTK_CHECK_VERSION (3, 98, 4)
++ IBusIMContext *ibusimcontext = data->ibusimcontext;
+
++ g_assert (IBUS_IS_IM_CONTEXT (ibusimcontext));
++#endif
+ g_slice_free (ProcessKeyEventData, data);
+ retval = ibus_input_context_process_key_event_async_finish (context,
+ res,
+@@ -426,7 +427,6 @@ _process_key_event_done (GObject *object,
+
+ if (retval == FALSE) {
+ #if GTK_CHECK_VERSION (3, 98, 4)
+- g_return_if_fail (GTK_IS_IM_CONTEXT (ibusimcontext));
+ gtk_im_context_filter_key (
+ GTK_IM_CONTEXT (ibusimcontext),
+ gdk_event_get_event_type (event) == GDK_KEY_PRESS,
+@@ -443,9 +443,11 @@ _process_key_event_done (GObject *object,
+ }
+ #if GTK_CHECK_VERSION (3, 98, 4)
+ gdk_event_unref (event);
++ g_object_unref (ibusimcontext);
+ #else
+ gdk_event_free (event);
+ #endif
++ g_object_unref (context);
+ }
+
+
+@@ -458,11 +460,16 @@ _process_key_event_sync (IBusInputContext *context,
+ gboolean retval;
+
+ g_assert (IBUS_IS_INPUT_CONTEXT (context));
++ /* Refer `context` because it can be freed during the D-Bus methods in
++ * ibus_input_context_process_key_event().
++ */
++ g_object_ref (context);
+ retval = ibus_input_context_process_key_event (context,
+ keyval,
+ keycode - 8,
+ state);
+ ibus_input_context_post_process_key_event (context);
++ g_object_unref (context);
+ return retval;
+ }
+
+@@ -475,20 +482,25 @@ _process_key_event_async (IBusInputContext *context,
+ GdkEvent *event,
+ IBusIMContext *ibusimcontext)
+ {
+- ProcessKeyEventData *data = g_slice_new0 (ProcessKeyEventData);
++ ProcessKeyEventData *data;
+
+ g_assert (event);
++ g_assert (IBUS_IS_INPUT_CONTEXT (context));
++
++ data = g_slice_new0 (ProcessKeyEventData);
+ if (!data) {
+ g_warning ("Cannot allocate async data");
+ return _process_key_event_sync (context, keyval, keycode, state);
+ }
+ #if GTK_CHECK_VERSION (3, 98, 4)
+ data->event = gdk_event_ref (event);
++ data->ibusimcontext = g_object_ref (ibusimcontext);
+ #else
++ /* `data->ibusimcontext` is not needed in GTK3, 2. */
+ data->event = gdk_event_copy (event);
+ #endif
+- data->ibusimcontext = ibusimcontext;
+- ibus_input_context_process_key_event_async (context,
++ ibus_input_context_process_key_event_async (
++ g_object_ref (context),
+ keyval,
+ keycode - 8,
+ state,
+@@ -654,7 +666,7 @@ _key_snooper_cb (GtkWidget *widget,
+ ibuscontext = _fake_context;
+ }
+
+- if (ibuscontext == NULL)
++ if (!IBUS_IS_INPUT_CONTEXT (ibuscontext))
+ return FALSE;
+
+ if (G_UNLIKELY (event->state & IBUS_HANDLED_MASK))
+@@ -1250,7 +1262,7 @@ ibus_im_context_filter_keypress (GtkIMContext *context,
+ ibusimcontext->time = event->time;
+ #endif
+
+- if (ibusimcontext->ibuscontext) {
++ if (IBUS_IS_INPUT_CONTEXT (ibusimcontext->ibuscontext)) {
+ if (_process_key_event (ibusimcontext->ibuscontext,
+ event,
+ ibusimcontext)) {
+@@ -1873,7 +1885,7 @@ _bus_connected_cb (IBusBus *bus,
+ IBusIMContext *ibusimcontext)
+ {
+ IDEBUG ("%s", __FUNCTION__);
+- if (ibusimcontext)
++ if (IBUS_IS_IM_CONTEXT (ibusimcontext))
+ _create_input_context (ibusimcontext);
+ else
+ _create_fake_input_context ();
+@@ -1969,7 +1981,9 @@ _create_gdk_event (IBusIMContext *ibusimcontext,
+ gunichar c = 0;
+ gchar buf[8];
+
+- GdkEventKey *event = (GdkEventKey *)gdk_event_new ((state & IBUS_RELEASE_MASK) ? GDK_KEY_RELEASE : GDK_KEY_PRESS);
++ GdkEventKey *event =
++ (GdkEventKey *)gdk_event_new ((state & IBUS_RELEASE_MASK) ?
++ GDK_KEY_RELEASE : GDK_KEY_PRESS);
+
+ if (ibusimcontext && ibusimcontext->client_window)
+ event->window = g_object_ref (ibusimcontext->client_window);
+@@ -2324,6 +2338,7 @@ _create_input_context_done (IBusBus *bus,
+ IBusInputContext *context = ibus_bus_create_input_context_async_finish (
+ _bus, res, &error);
+
++ g_assert (IBUS_IS_IM_CONTEXT (ibusimcontext));
+ if (ibusimcontext->cancellable != NULL) {
+ g_object_unref (ibusimcontext->cancellable);
+ ibusimcontext->cancellable = NULL;
+@@ -2408,14 +2423,31 @@ _create_input_context_done (IBusBus *bus,
+ #else
+ GdkEventKey *event;
+ #endif
++ /* Refer `context` because it can be unref during while(). */
++ g_object_ref (context);
++ g_object_ref (ibusimcontext);
+ while ((event = g_queue_pop_head (ibusimcontext->events_queue))) {
+- _process_key_event (context, event, ibusimcontext);
++ /* `ibusimcontext->ibuscontext` can be null in
++ * _ibus_context_destroy_cb(). If `ibusimcontext->ibuscontext`
++ * is null but `context` is *not* null, _process_key_event()
++ * should not be called.
++ */
++ if (IBUS_IS_INPUT_CONTEXT (ibusimcontext->ibuscontext) &&
++ ibusimcontext->ibuscontext == context) {
++ if (!_process_key_event (context, event, ibusimcontext) &&
++ GTK_IS_IM_CONTEXT (ibusimcontext->slave)) {
++ gtk_im_context_filter_keypress (ibusimcontext->slave,
++ event);
++ }
++ }
+ #if GTK_CHECK_VERSION (3, 98, 4)
+ gdk_event_unref (event);
+ #else
+ gdk_event_free ((GdkEvent *)event);
+ #endif
+ }
++ g_object_unref (context);
++ g_object_unref (ibusimcontext);
+ }
+ }
+
+@@ -2429,6 +2461,7 @@ _create_input_context (IBusIMContext *ibusimcontext)
+ gchar *client_name;
+ IDEBUG ("%s", __FUNCTION__);
+
++ g_assert (IBUS_IS_IM_CONTEXT (ibusimcontext));
+ g_assert (ibusimcontext->ibuscontext == NULL);
+
+ g_return_if_fail (ibusimcontext->cancellable == NULL);
+diff --git a/client/wayland/ibuswaylandim.c b/client/wayland/ibuswaylandim.c
+index fed8a0fa..cfb58563 100644
+--- a/client/wayland/ibuswaylandim.c
++++ b/client/wayland/ibuswaylandim.c
+@@ -2067,10 +2067,11 @@ _process_key_event_done (GObject *object,
+ &error);
+ IBusWaylandIMPrivate *priv = NULL;
+
++ g_assert (event);
++ g_assert (IBUS_IS_WAYLAND_IM (event->wlim));
++
+ if (error != NULL) {
+- if (event && event->wlim && IBUS_IS_WAYLAND_IM (event->wlim)) {
+- priv = ibus_wayland_im_get_instance_private (event->wlim);
+- }
++ priv = ibus_wayland_im_get_instance_private (event->wlim);
+ if (priv && priv->log) {
+ fprintf (priv->log, "Process Key Event failed: %s\n",
+ error->message);
+@@ -2080,15 +2081,13 @@ _process_key_event_done (GObject *object,
+ }
+ g_error_free (error);
+ }
+- g_return_if_fail (event);
+- g_return_if_fail (IBUS_IS_WAYLAND_IM (event->wlim));
+
+ priv = ibus_wayland_im_get_instance_private (event->wlim);
+ /* Should ignore key events after input_method_deactivate() is called
+ * even if context->ref_count is not 0 yet but priv->ibuscontext is null
+ * because of the async time lag.
+ */
+- if (priv->ibuscontext) {
++ if (IBUS_IS_INPUT_CONTEXT (priv->ibuscontext)) {
+ retval = ibus_wayland_im_post_key (event->wlim,
+ event->key,
+ event->modifiers,
+@@ -2097,7 +2096,7 @@ _process_key_event_done (GObject *object,
+ retval);
+ }
+ /* Check retral from ibus_wayland_im_post_key() */
+- if (priv->ibuscontext && !retval) {
++ if (IBUS_IS_INPUT_CONTEXT (priv->ibuscontext) && !retval) {
+ ibus_wayland_im_keycode (event->wlim,
+ event->key_serial,
+ event->time,
+@@ -2105,7 +2104,9 @@ _process_key_event_done (GObject *object,
+ event->state);
+ }
+
++ g_object_unref (event->wlim);
+ g_slice_free (IBusWaylandKeyEvent, event);
++ g_object_unref (context);
+ }
+
+
+@@ -2114,18 +2115,30 @@ _process_key_event_sync (IBusWaylandIM *wlim,
+ IBusWaylandKeyEvent *event)
+ {
+ IBusWaylandIMPrivate *priv;
++ IBusInputContext *ibuscontext;
+ gboolean retval;
+
+- g_return_if_fail (IBUS_IS_WAYLAND_IM (wlim));
++ /* `wlim` cannot be %NULL here because
++ * input_method_keyboard_key() already checks it.
++ */
++ g_assert (IBUS_IS_WAYLAND_IM (wlim));
+ g_assert (event);
+ priv = ibus_wayland_im_get_instance_private (wlim);
+- if (!priv->ibuscontext)
+- return;
+- retval = ibus_input_context_process_key_event (priv->ibuscontext,
++ /* `priv->ibuscontext` cannot be %NULL here even if `G_DISABLE_ASSERT`
++ * is defined because input_method_keyboard_key() already checks it.
++ */
++ g_assert (IBUS_IS_INPUT_CONTEXT (priv->ibuscontext));
++
++ /* Use the local `ibuscontext` instead of `priv->ibuscontext` because
++ * `priv->ibuscontext` can be %NULL during the D-Bus method in
++ * ibus_input_context_process_key_event().
++ */
++ ibuscontext = g_object_ref (priv->ibuscontext);
++ retval = ibus_input_context_process_key_event (ibuscontext,
+ event->sym,
+ event->key,
+ event->modifiers);
+- ibus_input_context_post_process_key_event (priv->ibuscontext);
++ ibus_input_context_post_process_key_event (ibuscontext);
+ retval = ibus_wayland_im_post_key (wlim,
+ event->key,
+ event->modifiers,
+@@ -2139,6 +2152,7 @@ _process_key_event_sync (IBusWaylandIM *wlim,
+ event->key,
+ event->state);
+ }
++ g_object_unref (ibuscontext);
+ }
+
+
+@@ -2149,9 +2163,11 @@ _process_key_event_async (IBusWaylandIM *wlim,
+ IBusWaylandIMPrivate *priv;
+ IBusWaylandKeyEvent *async_event;
+
+- g_return_if_fail (IBUS_IS_WAYLAND_IM (wlim));
++ g_assert (IBUS_IS_WAYLAND_IM (wlim));
+ g_assert (event);
+ priv = ibus_wayland_im_get_instance_private (wlim);
++ g_assert (IBUS_IS_INPUT_CONTEXT (priv->ibuscontext));
++
+ async_event = g_slice_new0 (IBusWaylandKeyEvent);
+ if (!async_event) {
+ if (priv->log) {
+@@ -2170,15 +2186,16 @@ _process_key_event_async (IBusWaylandIM *wlim,
+ async_event->sym = event->sym;
+ async_event->modifiers = event->modifiers & ~IBUS_RELEASE_MASK;
+ async_event->state = event->state;
+- async_event->wlim = wlim;
+- ibus_input_context_process_key_event_async (priv->ibuscontext,
+- event->sym,
+- event->key,
+- event->modifiers,
+- -1,
+- NULL,
+- _process_key_event_done,
+- async_event);
++ async_event->wlim = g_object_ref (wlim);
++ ibus_input_context_process_key_event_async (
++ g_object_ref (priv->ibuscontext),
++ event->sym,
++ event->key,
++ event->modifiers,
++ -1,
++ NULL,
++ _process_key_event_done,
++ async_event);
+ }
+
+
+@@ -2199,7 +2216,7 @@ _process_key_event_repeat_rate_cb (gpointer user_data)
+ }
+ priv = ibus_wayland_im_get_instance_private (wlim);
+
+- if (!priv->ibuscontext) {
++ if (!IBUS_IS_INPUT_CONTEXT (priv->ibuscontext)) {
+ event->repeat_rate_id = 0;
+ return G_SOURCE_REMOVE;
+ }
+@@ -2239,7 +2256,7 @@ _process_key_event_repeat_delay_cb (gpointer user_data)
+ priv = ibus_wayland_im_get_instance_private (wlim);
+
+ /* The key release event was sent to non-Wayland apps likes xterm. */
+- if (!priv->ibuscontext) {
++ if (!IBUS_IS_INPUT_CONTEXT (priv->ibuscontext)) {
+ event->count_cb_id = 0;
+ return G_SOURCE_REMOVE;
+ }
+@@ -2404,7 +2421,7 @@ input_method_keyboard_key (void *data,
+ return;
+ }
+
+- if (!priv->ibuscontext) {
++ if (!IBUS_IS_INPUT_CONTEXT (priv->ibuscontext)) {
+ gboolean retval = ibus_wayland_im_post_key (wlim,
+ key,
+ priv->modifiers,
+diff --git a/client/x11/main.c b/client/x11/main.c
+index 7c05111c..030c9d6b 100644
+--- a/client/x11/main.c
++++ b/client/x11/main.c
+@@ -465,45 +465,43 @@ xim_unset_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
+
+
+ static void
+-_xim_forward_key_event_done (X11IC *x11ic,
+- XEvent *event,
+- gboolean processed)
++forward_event_data_forward (IMForwardEventStruct *data,
++ gboolean processed)
+ {
++ X11IC *x11ic;
+ IMForwardEventStruct fe;
++
++ g_assert (data);
++ x11ic = (X11IC *)g_hash_table_lookup (
++ _x11_ic_table,
++ GINT_TO_POINTER ((gint)data->icid));
++ if (!x11ic)
++ return;
+ 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.icid = data->icid;
++ fe.connect_id = data->connect_id;
+ fe.sync_bit = 0;
+ fe.serial_number = 0L;
+- fe.event = *event;
+- IMForwardEvent (_xims, (XPointer) &fe);
++ fe.event = data->event;
++ IMForwardEvent (_xims, (XPointer)&fe);
+ }
+
+
+-typedef struct {
+- X11IC *x11ic;
+- CARD16 connect_id;
+- XEvent event;
+-} ProcessKeyEventReplyData;
+-
+-
+ static void
+ _process_key_event_done (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+ {
+ IBusInputContext *context = (IBusInputContext *)object;
+- ProcessKeyEventReplyData *data = (ProcessKeyEventReplyData *)user_data;
++ IMForwardEventStruct *data = (IMForwardEventStruct*)user_data;
+
+ GError *error = NULL;
+ gboolean retval = ibus_input_context_process_key_event_async_finish (
+@@ -519,13 +517,15 @@ _process_key_event_done (GObject *object,
+ if (g_hash_table_lookup (_connections,
+ GINT_TO_POINTER ((gint)data->connect_id))
+ == NULL) {
+- g_slice_free (ProcessKeyEventReplyData, data);
++ g_slice_free (IMForwardEventStruct, data);
++ g_object_unref (context);
+ return;
+ }
+
+ if (retval == FALSE)
+- _xim_forward_key_event_done (data->x11ic, &data->event, retval);
+- g_slice_free (ProcessKeyEventReplyData, data);
++ forward_event_data_forward (data, retval);
++ g_slice_free (IMForwardEventStruct, data);
++ g_object_unref (context);
+ }
+
+
+@@ -534,18 +534,23 @@ _process_key_event_sync (X11IC *x11ic,
+ IMForwardEventStruct *call_data,
+ GdkEventKey *event)
+ {
++ IBusInputContext *context;
+ gboolean retval;
+
+ g_assert (x11ic);
+ g_assert (call_data);
+ g_assert (event);
++ g_assert (IBUS_IS_INPUT_CONTEXT (x11ic->context));
++ context = g_object_ref (x11ic->context);
+ retval = ibus_input_context_process_key_event (
+- x11ic->context,
++ context,
+ event->keyval,
+ event->hardware_keycode - 8,
+ event->state);
+- ibus_input_context_post_process_key_event (x11ic->context);
+- _xim_forward_key_event_done (x11ic, &call_data->event, retval);
++ ibus_input_context_post_process_key_event (context);
++
++ g_object_unref (context);
++ forward_event_data_forward (call_data, retval);
+ return 1;
+ }
+
+@@ -555,19 +560,18 @@ _process_key_event_async (X11IC *x11ic,
+ IMForwardEventStruct *call_data,
+ GdkEventKey *event)
+ {
+- ProcessKeyEventReplyData *data;
++ IMForwardEventStruct *data;
+
+ g_assert (x11ic);
+ g_assert (call_data);
+ g_assert (event);
+- if (!(data = g_slice_new0 (ProcessKeyEventReplyData))) {
++ g_assert (IBUS_IS_INPUT_CONTEXT (x11ic->context));
++ if (!(data = g_slice_dup (IMForwardEventStruct, call_data))) {
+ g_warning ("Cannot allocate async data");
+ return _process_key_event_sync (x11ic, call_data, event);
+ }
+- data->connect_id = call_data->connect_id;
+- data->x11ic = x11ic;
+- data->event = call_data->event;
+- ibus_input_context_process_key_event_async (x11ic->context,
++ /* Use `data` instead of `x11ic` because x11ic can be a shallow snapshot. */
++ ibus_input_context_process_key_event_async (g_object_ref (x11ic->context),
+ event->keyval,
+ event->hardware_keycode - 8,
+ event->state,
+@@ -586,16 +590,22 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
+ XKeyEvent *xevent;
+ GdkEventKey event;
+
++ g_return_val_if_fail (call_data != NULL, 0);
+ LOG (1, "XIM_FORWARD_EVENT ic=%d connect_id=%d",
+ call_data->icid, call_data->connect_id);
+
+- x11ic = (X11IC *) g_hash_table_lookup (
++ x11ic = (X11IC *)g_hash_table_lookup (
+ _x11_ic_table,
+- GINT_TO_POINTER ((gint) call_data->icid));
++ GINT_TO_POINTER ((gint)call_data->icid));
+ g_return_val_if_fail (x11ic != NULL, 0);
+
+ xevent = (XKeyEvent*) &(call_data->event);
+
++ if (!IBUS_IS_INPUT_CONTEXT (x11ic->context)) {
++ forward_event_data_forward (call_data, FALSE);
++ return 0;
++ }
++
+ translate_key_event (gdk_display_get_default (),
+ (GdkEvent *)&event, (XEvent *)xevent);
+
+@@ -717,7 +727,8 @@ xim_disconnect_ic (XIMS xims, IMDisConnectStruct *call_data)
+ static void
+ _xim_set_cursor_location (X11IC *x11ic)
+ {
+- g_return_if_fail (x11ic != NULL);
++ /* The parent function should ensure x11ic is not null. */
++ g_assert (x11ic);
+
+ GdkRectangle preedit_area = x11ic->preedit_area;
+
+@@ -889,6 +900,7 @@ _xim_forward_key_event (X11IC *x11ic,
+ guint state)
+ {
+ XEvent xkp = {0};
++ IMForwardEventStruct data = { 0, };
+
+ g_return_if_fail (x11ic != NULL);
+
+@@ -907,7 +919,10 @@ _xim_forward_key_event (X11IC *x11ic,
+ xkp.xkey.state = state;
+ xkp.xkey.keycode = (keycode == 0) ? 0 : keycode + 8;
+
+- _xim_forward_key_event_done (x11ic, &xkp, FALSE);
++ data.connect_id = x11ic->connect_id;
++ data.icid = x11ic->icid;
++ data.event = xkp;
++ forward_event_data_forward (&data, FALSE);
+ }
+
+ static void
+--
+2.56.0
+
+From 6d3332d3e8edeff081e6e7e27059d114002eefd2 Mon Sep 17 00:00:00 2001
+From: zhangpan <98025960+zhangpan2001@users.noreply.github.com>
+Date: Thu, 12 Nov 2026 00:21:37 +0900
+Subject: [PATCH 7/8] bus/matchrule: Fix stale rules after connection destruction
+
+Destroy a match rule when connection destruction removes its last recipient.
+Add a regression test covering both the intermediate and final disconnect
+cases.
+
+Closes: #2948
+Part-of: #2949
+---
+ bus/matchrule.c | 23 +++++++++++++++++++----
+ bus/test-matchrule.c | 34 ++++++++++++++++++++++++++++++++++
+ 2 files changed, 53 insertions(+), 4 deletions(-)
+
+diff --git a/bus/matchrule.c b/bus/matchrule.c
+index 7a53e553..684e0f25 100644
+--- a/bus/matchrule.c
++++ b/bus/matchrule.c
+@@ -654,14 +654,29 @@ bus_match_rule_connection_destroy_cb (BusConnection *connection,
+ BusRecipient *recipient = (BusRecipient *)p->data;
+
+ if (recipient->connection == connection) {
++ /* Drop all registrations for this connection, regardless of
++ * the recipient's reference count.
++ * bus_match_rule_remove_recipient() removes one registration
++ * at a time. Disposal also clears the connection's destroy
++ * handler.
++ *
++ * E.g. With two accidental "AddMatch" D-Bus methods,
++ * bus_match_rule_add_recipient() increases the refcount of
++ * the recipient but the caller does not know if it's called
++ * twice due to the void API.
++ * With two accidental "RemoveMatch" D-Bus methods,
++ * bus_match_rule_remove_recipient() decreases the refcount of
++ * the recipient.
++ * bus_match_rule_connection_destroy_cb() destroys the recipient
++ * with any refcounts when the #BusConnection is destoryed.
++ */
+ rule->recipients = g_list_delete_link (rule->recipients, p);
+ bus_recipient_free (recipient);
++ if (rule->recipients == NULL) {
++ ibus_object_destroy (IBUS_OBJECT (rule));
++ }
+ return;
+ }
+-
+- if (rule->recipients == NULL) {
+- ibus_object_destroy (IBUS_OBJECT (rule));
+- }
+ }
+ g_assert_not_reached ();
+ }
+diff --git a/bus/test-matchrule.c b/bus/test-matchrule.c
+index 15a4ed45..b7cd8866 100644
+--- a/bus/test-matchrule.c
++++ b/bus/test-matchrule.c
+@@ -62,6 +62,38 @@ test (void)
+ g_object_unref (rule);
+ }
+
++static void
++test_connection_destroy (void)
++{
++ BusMatchRule *rule;
++ BusConnection *connection1;
++ BusConnection *connection2;
++
++ rule = bus_match_rule_new ("type='signal'");
++ connection1 = BUS_CONNECTION (g_object_new (BUS_TYPE_CONNECTION, NULL));
++ connection2 = BUS_CONNECTION (g_object_new (BUS_TYPE_CONNECTION, NULL));
++
++ bus_match_rule_add_recipient (rule, connection1);
++ bus_match_rule_add_recipient (rule, connection2);
++ g_assert_cmpuint (g_list_length (rule->recipients), ==, 2);
++
++ ibus_object_destroy (IBUS_OBJECT (connection1));
++ /* ibus_object_destroy(connection) calls
++ * bus_match_rule_connection_destroy_cb() and the rule is destroyed
++ * in case the length of `rule->recipients` is 0.
++ */
++ g_assert_false (IBUS_OBJECT_DESTROYED (rule));
++ g_assert_cmpuint (g_list_length (rule->recipients), ==, 1);
++
++ ibus_object_destroy (IBUS_OBJECT (connection2));
++ g_assert_true (IBUS_OBJECT_DESTROYED (rule));
++ g_assert_null (rule->recipients);
++
++ g_object_unref (connection1);
++ g_object_unref (connection2);
++ g_object_unref (rule);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -70,5 +102,7 @@ main (int argc, char *argv[])
+ g_type_init ();
+ #endif
+ g_test_add_func ("/test-matchrule", test);
++ g_test_add_func ("/test-matchrule/connection-destroy",
++ test_connection_destroy);
+ return g_test_run ();
+ }
+--
+2.56.0
+
+From 7d228eafa986ee43bf41aa0d675a04540ab767e7 Mon Sep 17 00:00:00 2001
+From: zhangpan <98025960+zhangpan2001@users.noreply.github.com>
+Date: Thu, 12 Nov 2026 00:21:46 +0900
+Subject: [PATCH 8/8] bus/test-matchrule: Add tests for repeated registrations and GDBus close
+
+Add tests for destroying a connection with two registrations of the same
+rule and for closing a real GDBusConnection. Both tests check that the
+rule is destroyed and its recipient list is empty.
+
+Skip the GDBusConnection close test when dbus-daemon is unavailable.
+
+Closes: #2948
+Part-of: #2949
+---
+ bus/test-matchrule.c | 98 ++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 98 insertions(+)
+
+diff --git a/bus/test-matchrule.c b/bus/test-matchrule.c
+index b7cd8866..28467ecb 100644
+--- a/bus/test-matchrule.c
++++ b/bus/test-matchrule.c
+@@ -94,6 +94,100 @@ test_connection_destroy (void)
+ g_object_unref (rule);
+ }
+
++static void
++test_connection_destroy_repeated (void)
++{
++ BusMatchRule *rule;
++ BusConnection *connection;
++
++ rule = bus_match_rule_new ("type='signal'");
++ connection = BUS_CONNECTION (g_object_new (BUS_TYPE_CONNECTION, NULL));
++
++ bus_match_rule_add_recipient (rule, connection);
++ bus_match_rule_add_recipient (rule, connection);
++ g_assert_cmpuint (g_list_length (rule->recipients), ==, 1);
++
++ ibus_object_destroy (IBUS_OBJECT (connection));
++ /* Even if bus_match_rule_add_recipient() is called twice accidentally,
++ * ibus_object_destroy(connection) calls
++ * bus_match_rule_connection_destroy_cb() and the rule should be destroyed.
++ */
++ g_assert_true (IBUS_OBJECT_DESTROYED (rule));
++ g_assert_null (rule->recipients);
++
++ g_object_unref (connection);
++ g_object_unref (rule);
++}
++
++static gboolean
++connection_close_timeout (gpointer data)
++{
++ gboolean *timed_out = data;
++ *timed_out = TRUE;
++ return G_SOURCE_REMOVE;
++}
++
++static void
++test_dbus_connection_closed (void)
++{
++ GTestDBus *test_dbus;
++ GDBusConnection *dbus_connection;
++ BusConnection *connection;
++ BusMatchRule *rule;
++ GSource *timeout;
++ GError *error = NULL;
++ gboolean timed_out = FALSE;
++ gchar *dbus_daemon;
++
++ dbus_daemon = g_find_program_in_path ("dbus-daemon");
++ if (dbus_daemon == NULL) {
++ g_test_skip ("dbus-daemon is not available");
++ return;
++ }
++ g_free (dbus_daemon);
++
++ test_dbus = g_test_dbus_new (G_TEST_DBUS_NONE);
++ g_test_dbus_up (test_dbus);
++ dbus_connection = g_dbus_connection_new_for_address_sync (
++ g_test_dbus_get_bus_address (test_dbus),
++ G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT |
++ G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
++ NULL, NULL, &error);
++ g_assert_no_error (error);
++ g_assert_nonnull (dbus_connection);
++ g_dbus_connection_set_exit_on_close (dbus_connection, FALSE);
++
++ connection = bus_connection_new (dbus_connection);
++ rule = bus_match_rule_new ("type='signal'");
++ bus_match_rule_add_recipient (rule, connection);
++
++ g_assert_true (g_dbus_connection_close_sync (dbus_connection,
++ NULL, &error));
++ g_assert_no_error (error);
++
++ timeout = g_timeout_source_new_seconds (5);
++ g_source_set_callback (timeout, connection_close_timeout, &timed_out, NULL);
++ g_source_attach (timeout, NULL);
++ while (!IBUS_OBJECT_DESTROYED (connection) && !timed_out)
++ g_main_context_iteration (NULL, TRUE);
++ g_source_destroy (timeout);
++ g_source_unref (timeout);
++
++ /* Assert if `timed_out` becomes %TRUE */
++ g_assert_true (IBUS_OBJECT_DESTROYED (connection));
++ /* g_dbus_connection_close_sync() will calls
++ * bus_match_rule_connection_destroy_cb() and the rule is destroyed.
++ */
++ g_assert_true (IBUS_OBJECT_DESTROYED (rule));
++ g_assert_null (rule->recipients);
++
++ g_object_unref (connection);
++ g_object_unref (rule);
++ g_object_unref (dbus_connection);
++ g_test_dbus_down (test_dbus);
++ g_object_unref (test_dbus);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -104,5 +198,9 @@ main (int argc, char *argv[])
+ g_test_add_func ("/test-matchrule", test);
+ g_test_add_func ("/test-matchrule/connection-destroy",
+ test_connection_destroy);
++ g_test_add_func ("/test-matchrule/connection-destroy-repeated",
++ test_connection_destroy_repeated);
++ g_test_add_func ("/test-matchrule/dbus-connection-closed",
++ test_dbus_connection_closed);
+ return g_test_run ();
+ }
+--
+2.56.0
+
diff --git a/ibus.spec b/ibus.spec
index fef8942..aed9038 100644
--- a/ibus.spec
+++ b/ibus.spec
@@ -49,7 +49,7 @@
Name: ibus
Version: 1.5.35
# https://github.com/fedora-infra/rpmautospec/issues/101
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1-or-later
URL: https://github.com/ibus/%name/wiki
@@ -58,6 +58,7 @@ Source1: https://github.com/ibus/%name/releases/download/%{source_version
Source2: %{name}-xinput
Source3: %{name}.conf.5
# Patch: %%{name}-HEAD.patch
+Patch: %{name}-HEAD.patch
# Under testing #1349148 #1385349 #1350291 #1406699 #1432252 #1601577
Patch: %{name}-1385349-segv-bus-proxy.patch
@@ -465,6 +466,7 @@ dconf update || :
%{_sysconfdir}/xdg/Xwayland-session.d/10-ibus-x11
%dir %{_prefix}/lib/systemd/user/gnome-session.target.wants
%{_prefix}/lib/systemd/user/gnome-session.target.wants/*.service
+%{_prefix}/lib/systemd/user/ibus-portal.service
%{_prefix}/lib/systemd/user/org.freedesktop.IBus.session.*.service
%verify(not mtime) %dir %pkgcache
%verify(not mtime) %dir %pkgcache/bus
@@ -550,6 +552,14 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
+* Thu Nov 12 2026 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.35-2
+- Fix gsettings in ibus-desktop-testing in Fedora 45
+- Fix typo in po/Makevars
+- Tie ibus services to the graphical session
+- Delete _process_key_event_hybrid_async()
+- Fix to check if IBusInputContext is available in IBus clients
+- Fix stale rules after connection destruction in ibus-daemon
+
* Thu Nov 05 2026 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.35-1
- Bump to 1.5.35
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-12 2:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 2:27 [rpms/ibus] rawhide: Fix CI and memory issues Takao Fujiwara
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox