ibus/ibus-HEAD.patch
2023-07-12 09:29:03 +09:00

4824 lines
179 KiB
Diff

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
From f0492c86f7c42d35bedff1a1910075617243d1f0 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Sun, 18 Jun 2023 10:59:35 +0900
Subject: [PATCH] m4: Update m4 files
- Revert .gitignore because m4 files cannot be added
- Delete as-version.m4 which has been unused since 2010
- Update the latest introspection.m4
- Update the latest vapigen.m4
Fixes: https://github.com/ibus/ibus/commit/d23bbdd
Fixes: https://github.com/ibus/ibus/commit/3b3f56d
BUG=https://github.com/ibus/ibus/pull/2527
---
m4/Makefile.am | 1 -
m4/as-version.m4 | 71 ---------------------------------------------
m4/introspection.m4 | 60 ++++++++++++++++++++++++++++++++++----
m4/vapigen.m4 | 19 +++++++-----
5 files changed, 66 insertions(+), 86 deletions(-)
delete mode 100644 m4/as-version.m4
diff --git a/m4/Makefile.am b/m4/Makefile.am
index dcf84ac3..49ecbb89 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -21,7 +21,6 @@
# USA
EXTRA_DIST = \
- as-version.m4 \
ibuslocale.m4 \
vapigen.m4 \
$(NULL)
diff --git a/m4/as-version.m4 b/m4/as-version.m4
deleted file mode 100644
index a5b43990..00000000
--- a/m4/as-version.m4
+++ /dev/null
@@ -1,71 +0,0 @@
-dnl as-version.m4 0.2.0
-
-dnl autostars m4 macro for versioning
-
-dnl Thomas Vander Stichele <thomas at apestaart dot org>
-
-dnl $Id: as-version.m4,v 1.4 2004/06/01 09:40:05 thomasvs Exp $
-
-dnl AS_VERSION
-
-dnl example
-dnl AS_VERSION
-
-dnl this macro
-dnl - AC_SUBST's PACKAGE_VERSION_MAJOR, _MINOR, _MICRO
-dnl - AC_SUBST's PACKAGE_VERSION_RELEASE,
-dnl which can be used for rpm release fields
-dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents
-dnl maintainer mode from running correctly
-dnl
-dnl don't forget to put #undef PACKAGE_VERSION_RELEASE in acconfig.h
-dnl if you use acconfig.h
-
-AC_DEFUN([AS_VERSION],
-[
- PACKAGE_VERSION_MAJOR=$(echo AC_PACKAGE_VERSION | cut -d'.' -f1)
- PACKAGE_VERSION_MINOR=$(echo AC_PACKAGE_VERSION | cut -d'.' -f2)
- PACKAGE_VERSION_MICRO=$(echo AC_PACKAGE_VERSION | cut -d'.' -f3)
-
- AC_SUBST(PACKAGE_VERSION_MAJOR)
- AC_SUBST(PACKAGE_VERSION_MINOR)
- AC_SUBST(PACKAGE_VERSION_MICRO)
-])
-
-dnl AS_NANO(ACTION-IF-NO-NANO, [ACTION-IF-NANO])
-
-dnl requires AC_INIT to be called before
-dnl For projects using a fourth or nano number in your versioning to indicate
-dnl development or prerelease snapshots, this macro allows the build to be
-dnl set up differently accordingly.
-
-dnl this macro:
-dnl - parses AC_PACKAGE_VERSION, set by AC_INIT, and extracts the nano number
-dnl - sets the variable PACKAGE_VERSION_NANO
-dnl - sets the variable PACKAGE_VERSION_RELEASE, which can be used
-dnl for rpm release fields
-dnl - executes ACTION-IF-NO-NANO or ACTION-IF-NANO
-
-dnl example:
-dnl AS_NANO(RELEASE="yes", RELEASE="no")
-
-AC_DEFUN([AS_NANO],
-[
- AC_MSG_CHECKING(nano version)
-
- NANO=$(echo AC_PACKAGE_VERSION | cut -d'.' -f4)
-
- if test x"$NANO" = x || test "x$NANO" = "x0" ; then
- AC_MSG_RESULT([0 (release)])
- NANO=0
- PACKAGE_VERSION_RELEASE=1
- ifelse([$1], , :, [$1])
- else
- AC_MSG_RESULT($NANO)
- PACKAGE_VERSION_RELEASE=0.`date +%Y%m%d.%H%M%S`
- ifelse([$2], , :, [$2])
- fi
- PACKAGE_VERSION_NANO=$NANO
- AC_SUBST(PACKAGE_VERSION_NANO)
- AC_SUBST(PACKAGE_VERSION_RELEASE)
-])
diff --git a/m4/introspection.m4 b/m4/introspection.m4
index 589721c5..b0ccd689 100644
--- a/m4/introspection.m4
+++ b/m4/introspection.m4
@@ -8,6 +8,47 @@ dnl
# serial 1
+dnl This is a copy of AS_AC_EXPAND
+dnl
+dnl (C) 2003, 2004, 2005 Thomas Vander Stichele <thomas at apestaart dot org>
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.
+m4_define([_GOBJECT_INTROSPECTION_AS_AC_EXPAND],
+[
+ EXP_VAR=[$1]
+ FROM_VAR=[$2]
+
+ dnl first expand prefix and exec_prefix if necessary
+ prefix_save=$prefix
+ exec_prefix_save=$exec_prefix
+
+ dnl if no prefix given, then use /usr/local, the default prefix
+ if test "x$prefix" = "xNONE"; then
+ prefix="$ac_default_prefix"
+ fi
+ dnl if no exec_prefix given, then use prefix
+ if test "x$exec_prefix" = "xNONE"; then
+ exec_prefix=$prefix
+ fi
+
+ full_var="$FROM_VAR"
+ dnl loop until it doesn't change anymore
+ while true; do
+ new_full_var="`eval echo $full_var`"
+ if test "x$new_full_var" = "x$full_var"; then break; fi
+ full_var=$new_full_var
+ done
+
+ dnl clean up
+ full_var=$new_full_var
+ AC_SUBST([$1], "$full_var")
+
+ dnl restore prefix and exec_prefix
+ prefix=$prefix_save
+ exec_prefix=$exec_prefix_save
+])
+
m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
[
AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
@@ -41,6 +82,8 @@ m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
],dnl
[auto],[dnl
PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+ dnl Canonicalize enable_introspection
+ enable_introspection=$found_introspection
],dnl
[dnl
AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
@@ -48,20 +91,25 @@ m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
AC_MSG_RESULT([$found_introspection])
+ dnl expand datadir/libdir so we can pass them to pkg-config
+ dnl and get paths relative to our target directories
+ _GOBJECT_INTROSPECTION_AS_AC_EXPAND(_GI_EXP_DATADIR, "$datadir")
+ _GOBJECT_INTROSPECTION_AS_AC_EXPAND(_GI_EXP_LIBDIR, "$libdir")
+
INTROSPECTION_SCANNER=
INTROSPECTION_COMPILER=
INTROSPECTION_GENERATE=
INTROSPECTION_GIRDIR=
INTROSPECTION_TYPELIBDIR=
if test "x$found_introspection" = "xyes"; then
- INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
- INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
- INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
- INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
- INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+ INTROSPECTION_SCANNER=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+ INTROSPECTION_COMPILER=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+ INTROSPECTION_GENERATE=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+ INTROSPECTION_GIRDIR=`$PKG_CONFIG --define-variable=datadir="${_GI_EXP_DATADIR}" --variable=girdir gobject-introspection-1.0`
+ INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --define-variable=libdir="${_GI_EXP_LIBDIR}" --variable=typelibdir gobject-introspection-1.0)"
INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
- INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+ INTROSPECTION_MAKEFILE=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
fi
AC_SUBST(INTROSPECTION_SCANNER)
AC_SUBST(INTROSPECTION_COMPILER)
diff --git a/m4/vapigen.m4 b/m4/vapigen.m4
index 051ccd2e..6228991a 100644
--- a/m4/vapigen.m4
+++ b/m4/vapigen.m4
@@ -16,15 +16,20 @@ dnl You should have received a copy of the GNU Lesser General Public
dnl License along with this library; if not, write to the Free Software
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND-INTROSPECTION], [DEFAULT])
+# VAPIGEN_CHECK([VERSION], [API_VERSION], [FOUND_INTROSPECTION], [DEFAULT])
# --------------------------------------
# Check vapigen existence and version
#
# See http://live.gnome.org/Vala/UpstreamGuide for detailed documentation
AC_DEFUN([VAPIGEN_CHECK],
[
- AC_BEFORE([GOBJECT_INTROSPECTION_CHECK],[$0])
- AC_BEFORE([GOBJECT_INTROSPECTION_REQUIRE],[$0])
+ AS_IF([test "x$3" != "xyes"], [
+ m4_provide_if([GOBJECT_INTROSPECTION_CHECK], [], [
+ m4_provide_if([GOBJECT_INTROSPECTION_REQUIRE], [], [
+ AC_MSG_ERROR([[You must call GOBJECT_INTROSPECTION_CHECK or GOBJECT_INTROSPECTION_REQUIRE before using VAPIGEN_CHECK unless using the FOUND_INTROSPECTION argument is "yes"]])
+ ])
+ ])
+ ])
AC_ARG_ENABLE([vala],
[AS_HELP_STRING([--enable-vala[=@<:@no/auto/yes@:>@]],[build Vala bindings @<:@default=]ifelse($4,,auto,$4)[@:>@])],,[
@@ -77,12 +82,12 @@ AC_DEFUN([VAPIGEN_CHECK],
AS_CASE([$enable_vala],
[yes], [
- VAPIGEN=`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
- VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
+ VAPIGEN=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=vapigen $vapigen_pkg_name`
+ VAPIGEN_MAKEFILE=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=datadir $vapigen_pkg_name`/vala/Makefile.vapigen
AS_IF([test "x$2" = "x"], [
- VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
+ VAPIGEN_VAPIDIR=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=vapidir $vapigen_pkg_name`
], [
- VAPIGEN_VAPIDIR=`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
+ VAPIGEN_VAPIDIR=$PKG_CONFIG_SYSROOT_DIR`$PKG_CONFIG --variable=vapidir_versioned $vapigen_pkg_name`
])
])
--
2.41.0
From 18f0d9f5f245f92dee086ce57a5bb94e63f1c222 Mon Sep 17 00:00:00 2001
From: oreo639 <oreo6391@gmail.com>
Date: Sun, 18 Jun 2023 11:08:59 +0900
Subject: [PATCH] configure: Fix cross compiling
Use AX_PROG_CC_FOR_BUILD to get build CC/CFLAGS/LDFLAGS/etc.
Use PKG_PROG_PKG_CONFIG_FOR_BUILD to find build pkg-config binary.
https://sourceware.org/autobook/autobook/autobook_143.html#Supporting-Cross-Compiler-in-Make
BUG=https://github.com/ibus/ibus/issues/2479
---
configure.ac | 12 +++
m4/Makefile.am | 2 +
m4/ax_prog_cc_for_build.m4 | 155 +++++++++++++++++++++++++++++++++++++
m4/pkg_config_for_build.m4 | 20 +++++
src/Makefile.am | 67 ++++++++++++----
5 files changed, 240 insertions(+), 16 deletions(-)
create mode 100644 m4/ax_prog_cc_for_build.m4
create mode 100644 m4/pkg_config_for_build.m4
diff --git a/configure.ac b/configure.ac
index cbdfbd05..fb51367f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,6 +129,7 @@ AM_PROG_CC_C_O
AM_PROG_VALAC([0.20])
AC_PROG_INSTALL
AC_PROG_MAKE_SET
+AX_PROG_CC_FOR_BUILD
# i18n stuff
AM_GNU_GETTEXT_VERSION([0.19.8])
@@ -150,6 +151,9 @@ AC_CHECK_FUNCS(daemon)
AC_CHECK_LIB(c, dlclose, LIBDL="", [AC_CHECK_LIB(dl, dlclose, LIBDL="-ldl")])
AC_SUBST(LIBDL)
+# Check if cross compiling.
+AM_CONDITIONAL(CROSS_COMPILING, test "x$cross_compiling" = xyes)
+
# Check endianness.
AC_C_BIGENDIAN([ENDIAN=big], [ENDIAN=little], [ENDIAN=unknown], [ENDIAN=big])
if test x"$ENDIAN" != xlittle -a x"$ENDIAN" != xbig; then
@@ -183,6 +187,14 @@ AH_BOTTOM([
#endif
])
+if test "x$cross_compiling" = "xyes"; then
+PKG_PROG_PKG_CONFIG_FOR_BUILD
+GLIB_CFLAGS_FOR_BUILD=`$PKG_CONFIG_FOR_BUILD --cflags glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0 gthread-2.0`
+GLIB_LIBS_FOR_BUILD=`$PKG_CONFIG_FOR_BUILD --libs glib-2.0 gobject-2.0 gio-2.0 gio-unix-2.0 gthread-2.0`
+AC_SUBST(GLIB_CFLAGS_FOR_BUILD)
+AC_SUBST(GLIB_LIBS_FOR_BUILD)
+fi
+
# --disable-tests option.
AC_ARG_ENABLE(tests,
AS_HELP_STRING([--disable-tests],
diff --git a/m4/Makefile.am b/m4/Makefile.am
index 49ecbb89..8ea759e6 100644
--- a/m4/Makefile.am
+++ b/m4/Makefile.am
@@ -21,7 +21,9 @@
# USA
EXTRA_DIST = \
+ ax_prog_cc_for_build.m4 \
ibuslocale.m4 \
+ pkg_config_for_build.m4 \
vapigen.m4 \
$(NULL)
diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4
new file mode 100644
index 00000000..1db8d73f
--- /dev/null
+++ b/m4/ax_prog_cc_for_build.m4
@@ -0,0 +1,155 @@
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PROG_CC_FOR_BUILD
+#
+# DESCRIPTION
+#
+# This macro searches for a C compiler that generates native executables,
+# that is a C compiler that surely is not a cross-compiler. This can be
+# useful if you have to generate source code at compile-time like for
+# example GCC does.
+#
+# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything
+# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD).
+# The value of these variables can be overridden by the user by specifying
+# a compiler with an environment variable (like you do for standard CC).
+#
+# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object
+# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if
+# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are
+# substituted in the Makefile.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Paolo Bonzini <bonzini@gnu.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 21
+
+AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
+AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_CPP])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+
+dnl Use the standard macros, but make them use other variable names
+dnl
+pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
+pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl
+pushdef([ac_cv_prog_cc_c99], ac_cv_build_prog_cc_c99)dnl
+pushdef([ac_cv_prog_cc_c11], ac_cv_build_prog_cc_c11)dnl
+pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
+pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
+pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
+pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
+pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl
+pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
+pushdef([ac_cv_objext], ac_cv_build_objext)dnl
+pushdef([ac_exeext], ac_build_exeext)dnl
+pushdef([ac_objext], ac_build_objext)dnl
+pushdef([CC], CC_FOR_BUILD)dnl
+pushdef([CPP], CPP_FOR_BUILD)dnl
+pushdef([GCC], GCC_FOR_BUILD)dnl
+pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
+pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
+pushdef([EXEEXT], BUILD_EXEEXT)dnl
+pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
+pushdef([OBJEXT], BUILD_OBJEXT)dnl
+pushdef([host], build)dnl
+pushdef([host_alias], build_alias)dnl
+pushdef([host_cpu], build_cpu)dnl
+pushdef([host_vendor], build_vendor)dnl
+pushdef([host_os], build_os)dnl
+pushdef([ac_cv_host], ac_cv_build)dnl
+pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
+pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
+pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
+pushdef([ac_cv_host_os], ac_cv_build_os)dnl
+pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl
+pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl
+pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl
+pushdef([cross_compiling], cross_compiling_build)dnl
+
+cross_compiling_build=no
+
+ac_build_tool_prefix=
+AS_IF([test -n "$build"], [ac_build_tool_prefix="$build-"],
+ [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])
+
+AC_LANG_PUSH([C])
+
+dnl The pushdef([ac_cv_c_compiler_gnu], ...) currently does not cover
+dnl the use of this variable in _AC_LANG_COMPILER_GNU called by
+dnl AC_PROG_CC. Unset this cache variable temporarily as a workaround.
+was_set_c_compiler_gnu=${[ac_cv_c_compiler_gnu]+y}
+AS_IF([test ${was_set_c_compiler_gnu}],
+ [saved_c_compiler_gnu=$[ac_cv_c_compiler_gnu]
+ AS_UNSET([[ac_cv_c_compiler_gnu]])])
+
+AC_PROG_CC
+
+dnl Restore ac_cv_c_compiler_gnu
+AS_IF([test ${was_set_c_compiler_gnu}],
+ [[ac_cv_c_compiler_gnu]=$[saved_c_compiler_gnu]])
+
+_AC_COMPILER_EXEEXT
+_AC_COMPILER_OBJEXT
+AC_PROG_CPP
+
+dnl Restore the old definitions
+dnl
+popdef([cross_compiling])dnl
+popdef([am_cv_prog_cc_c_o])dnl
+popdef([am_cv_CC_dependencies_compiler_type])dnl
+popdef([ac_tool_prefix])dnl
+popdef([ac_cv_host_os])dnl
+popdef([ac_cv_host_vendor])dnl
+popdef([ac_cv_host_cpu])dnl
+popdef([ac_cv_host_alias])dnl
+popdef([ac_cv_host])dnl
+popdef([host_os])dnl
+popdef([host_vendor])dnl
+popdef([host_cpu])dnl
+popdef([host_alias])dnl
+popdef([host])dnl
+popdef([OBJEXT])dnl
+popdef([LDFLAGS])dnl
+popdef([EXEEXT])dnl
+popdef([CPPFLAGS])dnl
+popdef([CFLAGS])dnl
+popdef([GCC])dnl
+popdef([CPP])dnl
+popdef([CC])dnl
+popdef([ac_objext])dnl
+popdef([ac_exeext])dnl
+popdef([ac_cv_objext])dnl
+popdef([ac_cv_exeext])dnl
+popdef([ac_cv_c_compiler_gnu])dnl
+popdef([ac_cv_prog_cc_g])dnl
+popdef([ac_cv_prog_cc_cross])dnl
+popdef([ac_cv_prog_cc_works])dnl
+popdef([ac_cv_prog_cc_c89])dnl
+popdef([ac_cv_prog_gcc])dnl
+popdef([ac_cv_prog_CPP])dnl
+
+dnl restore global variables ac_ext, ac_cpp, ac_compile,
+dnl ac_link, ac_compiler_gnu (dependant on the current
+dnl language after popping):
+AC_LANG_POP([C])
+
+dnl Finally, set Makefile variables
+dnl
+AC_SUBST(BUILD_EXEEXT)dnl
+AC_SUBST(BUILD_OBJEXT)dnl
+AC_SUBST([CFLAGS_FOR_BUILD])dnl
+AC_SUBST([CPPFLAGS_FOR_BUILD])dnl
+AC_SUBST([LDFLAGS_FOR_BUILD])dnl
+])
diff --git a/m4/pkg_config_for_build.m4 b/m4/pkg_config_for_build.m4
new file mode 100644
index 00000000..0422f482
--- /dev/null
+++ b/m4/pkg_config_for_build.m4
@@ -0,0 +1,20 @@
+# PKG_PROG_PKG_CONFIG_FOR_BUILD([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG_FOR_BUILD],
+[m4_pattern_allow([^PKG_CONFIG_FOR_BUILD$])
+AC_ARG_VAR([PKG_CONFIG_FOR_BUILD], [path to build system's pkg-config utility])
+
+if test "x$ac_cv_env_PKG_CONFIG_FOR_BUILD_set" != "xset"; then
+ AC_PATH_PROG([PKG_CONFIG_FOR_BUILD], [pkg-config])
+fi
+if test -n "$PKG_CONFIG_FOR_BUILD"; then
+ _pkg_for_build_min_version=m4_default([$1], [0.9.0])
+ AC_MSG_CHECKING([build system's pkg-config is at least version $_pkg_min_version])
+ if $PKG_CONFIG_FOR_BUILD --atleast-pkgconfig-version $_pkg_min_version; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ PKG_CONFIG_FOR_BUILD=""
+ fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG_FOR_BUILD
diff --git a/src/Makefile.am b/src/Makefile.am
index adc7f04a..68dde2f3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -46,9 +46,6 @@ noinst_PROGRAMS = gen-internal-compose-table
# C preprocessor flags
AM_CPPFLAGS = \
-DG_LOG_DOMAIN=\"IBUS\" \
- @GLIB2_CFLAGS@ \
- @GOBJECT2_CFLAGS@ \
- @GIO2_CFLAGS@ \
-DIBUS_CACHE_DIR=\""$(localstatedir)/cache/ibus"\" \
-DIBUS_DATA_DIR=\"$(pkgdatadir)\" \
-DIBUS_DISABLE_DEPRECATION_WARNINGS \
@@ -65,6 +62,11 @@ libibus_1_0_la_LIBADD = \
@GOBJECT2_LIBS@ \
@GIO2_LIBS@ \
$(NULL)
+libibus_1_0_la_CFLAGS = \
+ @GLIB2_CFLAGS@ \
+ @GOBJECT2_CFLAGS@ \
+ @GIO2_CFLAGS@ \
+ $(NULL)
libibus_1_0_la_LDFLAGS = \
-no-undefined \
-export-symbols-regex "ibus_.*" \
@@ -107,7 +109,7 @@ ibus_sources = \
ibusxevent.c \
ibusxml.c \
$(NULL)
-libibus_1_0_la_SOURCES = \
+libibus_sources = \
ibuscomposetable.c \
ibusenumtypes.c \
ibusmarshalers.c \
@@ -166,6 +168,7 @@ ibus_headers = \
ibusxevent.h \
ibusxml.h \
$(NULL)
+libibus_1_0_la_SOURCES = $(libibus_sources)
ibusincludedir = $(includedir)/ibus-@IBUS_API_VERSION@
ibus_public_headers = \
$(ibus_headers) \
@@ -188,6 +191,35 @@ noinst_HEADERS = \
$(ibus_private_headers) \
$(NULL)
+if CROSS_COMPILING
+# Avoid libtool when building native libraries
+libnativeibus =
+parser_extra_sources = $(libibus_sources)
+
+glib_cflags = @GLIB_CFLAGS_FOR_BUILD@
+glib_libs = @GLIB_LIBS_FOR_BUILD@
+
+$(noinst_PROGRAMS): CC=$(CC_FOR_BUILD)
+$(noinst_PROGRAMS): CCLD=$(CC_FOR_BUILD)
+$(noinst_PROGRAMS): CFLAGS=$(CFLAGS_FOR_BUILD)
+$(noinst_PROGRAMS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+$(noinst_PROGRAMS): LDFLAGS=$(LDFLAGS_FOR_BUILD)
+else
+libnativeibus = $(libibus)
+parser_extra_sources =
+
+glib_libs = \
+ @GLIB2_LIBS@ \
+ @GOBJECT2_LIBS@ \
+ @GIO2_LIBS@ \
+ $(NULL)
+glib_cflags = \
+ @GLIB2_CFLAGS@ \
+ @GOBJECT2_CFLAGS@ \
+ @GIO2_CFLAGS@ \
+ $(NULL)
+endif
+
gen_internal_compose_table_SOURCES = \
gencomposetable.c \
ibuscomposetable.c \
@@ -196,11 +228,12 @@ gen_internal_compose_table_SOURCES = \
ibuskeyuni.c \
ibusenumtypes.h \
$(NULL)
-gen_internal_compose_table_CFLAGS = $(AM_CFLAGS)
+gen_internal_compose_table_CFLAGS = \
+ $(AM_CFLAGS) \
+ $(glib_cflags) \
+ $(NULL)
gen_internal_compose_table_LDADD = \
- @GLIB2_LIBS@ \
- @GOBJECT2_LIBS@ \
- @GIO2_LIBS@ \
+ $(glib_libs) \
$(NULL)
BUILT_SOURCES = \
@@ -363,15 +396,15 @@ install-data-hook:
emoji_parser_SOURCES = \
emoji-parser.c \
+ $(parser_extra_sources) \
$(NULL)
emoji_parser_CFLAGS = \
- $(GLIB2_CFLAGS) \
- $(GOBJECT2_CFLAGS) \
+ $(AM_CFLAGS) \
+ $(glib_cflags) \
$(NULL)
emoji_parser_LDADD = \
- $(libibus) \
- $(GLIB2_LIBS) \
- $(GOBJECT2_LIBS) \
+ $(libnativeibus) \
+ $(glib_libs) \
$(NULL)
endif
@@ -408,13 +441,15 @@ ibusunicodegen.h:
unicode_parser_SOURCES = \
unicode-parser.c \
+ $(parser_extra_sources) \
$(NULL)
unicode_parser_CFLAGS = \
- $(GLIB2_CFLAGS) \
+ $(AM_CFLAGS) \
+ $(glib_cflags) \
$(NULL)
unicode_parser_LDADD = \
- $(GLIB2_LIBS) \
- $(libibus) \
+ $(glib_libs) \
+ $(libnativeibus) \
$(NULL)
endif
--
2.41.0
From 25a2dfc12410fff5f32a3caf793a958d7e41dc4c Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Tue, 4 Jul 2023 22:46:31 +0900
Subject: [PATCH] bus: Avoid to hang the process with SIGUSR1 signal
Seems multiple `Xephyr -query` to a remote GDM login session causes
to leave the some processes of ibus-daemon even if the Xephyr sessions
are terminated and the issue is caused by calling bus_server_quit()
with SIGUSR1 signal.
I cannot reproduce the issue but calling the unsafe code from a signal
handler might lead to hangs and this is another signal connection
not to hang ibus-daemon.
BUG=https://github.com/ibus/ibus/pull/2499
---
bus/main.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/bus/main.c b/bus/main.c
index e80185b1..c4b8d651 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -2,8 +2,8 @@
/* vim:set et sts=4: */
/* ibus - The Input Bus
* Copyright (C) 2008-2013 Peng Huang <shawn.p.huang@gmail.com>
- * Copyright (C) 2013-2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
- * Copyright (C) 2008-2018 Red Hat, Inc.
+ * Copyright (C) 2013-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (C) 2008-2023 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -166,11 +166,12 @@ daemon (gint nochdir, gint noclose)
#endif
#ifdef HAVE_SYS_PRCTL_H
-static void
-_sig_usr1_handler (int sig)
+static gboolean
+_on_sigusr1 (void)
{
g_warning ("The parent process died.");
bus_server_quit (FALSE);
+ return G_SOURCE_REMOVE;
}
#endif
@@ -350,7 +351,7 @@ main (gint argc, gchar **argv)
if (prctl (PR_SET_PDEATHSIG, SIGUSR1))
g_printerr ("Cannot bind SIGUSR1 for parent death\n");
else
- signal (SIGUSR1, _sig_usr1_handler);
+ g_unix_signal_add (SIGUSR1, (GSourceFunc)_on_sigusr1, NULL);
#endif
}
bus_server_run ();
--
2.41.0
From be1f1d0da86006b019aaf78781d8c0c9c68fd46d Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Wed, 5 Jul 2023 13:33:25 +0900
Subject: [PATCH 1/2] src: Fix missing ibusenumtypes.h with parallel build
When `./autogen.sh && make -C src ibusresources.c -j2` runs,
it causes a build failure due to no ibusenumtypes.h file.
The chained dependencies are:
ibusresources.c -> compose/sequences-$(ENDIAN)-endian
-> gen-internal-compose-table -> gencomposetable.c
gencomposetable.c includes ibus.h and it causes no ibusenumtypes.h with
the parallel build with multi CPUs.
ibusenumtypes.h is in BUILT_SOURCES so it is built (with other files in
BUILT_SOURCES) before any other rules.
But ibus.h is included by gencomposetable.c which is needed to generate
ibusresources.c in BUILT_SOURCES.
Since gencomposetable.c is an internal build source file and
it doesn't have to include ibus.h but can include each ibus header
files.
Deleting ibus.h in gencomposetable.c can fix the build failure.
BUG=https://github.com/ibus/ibus/pull/2523
---
src/gencomposetable.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/gencomposetable.c b/src/gencomposetable.c
index 6e52d6a6..35d6ce83 100644
--- a/src/gencomposetable.c
+++ b/src/gencomposetable.c
@@ -20,7 +20,7 @@
* USA
*/
-#include <ibus.h>
+/* #2523 Should not include <ibus.h> but each IBus header file. */
#include <glib.h>
#include <glib/gstdio.h>
#include <errno.h>
--
2.41.0
From f25c48a1989be221e98b863c947e52eaf80dc4a3 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Wed, 5 Jul 2023 13:41:33 +0900
Subject: [PATCH 2/2] src: Fix to build libibus-1.0.la twice
The purpose of autotools is to automatically handle dependencies. By
calling $(MAKE) manually and without specifying any dependencies below,
we are going out of our way to prevent automake from doing its job.
ibusunicodegen.h:
$(MAKE) $(AM_MAKEFLAGS) dicts/unicode-blocks.dict
This avoids a build error whereby libibus-1.0.la is built twice
simultaneously, races with itself, and breaks the build.
dicts/unicode-blocks.dict ibusunicodegen.h: unicode-parser
The two build targets let `make ibusunicodegen.h` try to make
`dicts/unicode-blocks.dict` and `ibusunicodegen.h` with unicode-parser.
Unlike `ibusunicodegen.h`, we cannot add `ibusemojigen.h` to the rule
that produces it (as a side-effect) because the rule is specified with
GNU Make syntax:
dicts/emoji-%.dict: emoji-parser
and doing so yields an error:
config.status: error: Something went wrong bootstrapping makefile
fragments for automatic dependency tracking. If GNU make was
not used, consider re-running the configure script with
MAKE="gmake" (or whatever is necessary). You can also try
re-running configure with the '--disable-dependency-tracking'
option to at least be able to build the package (albeit without
support for automatic dependency tracking).
So instead, add a prerequisite to the rule.
Both emoji-parser and unicode-parser has $(libibus) in LDADD
and $(libibus) is built before emoji-parser and unicode-parser are
built.
BUG=https://github.com/ibus/ibus/pull/2523
---
src/Makefile.am | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index 68dde2f3..fee0b3ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -372,8 +372,9 @@ dicts/emoji-%.dict: emoji-parser
echo "Skip $$plus_comment $@"; \
fi;
-ibusemojigen.h:
- $(MAKE) $(AM_MAKEFLAGS) dicts/emoji-en.dict
+# #2523 Should use autotool dependency
+ibusemojigen.h: dicts/emoji-en.dict
+ $(MAKE) $(AM_MAKEFLAGS) $^
# We put dicts/emoji-%.dict as the make target for the parallel build
# and the make target has to be genarated even if the file size is zero.
@@ -424,7 +425,8 @@ dicts/unicode-names.dict: unicode-parser
echo "Generated $@"; \
fi;
-dicts/unicode-blocks.dict: unicode-parser
+# #2523 Should use autotool dependency
+dicts/unicode-blocks.dict ibusunicodegen.h: unicode-parser
$(AM_V_at)input_file="$(UCD_DIR)/Blocks.txt"; \
if test ! -f "$$input_file" ; then \
echo "WARNING: Not found $$input_file" 1>&2; \
@@ -436,9 +438,6 @@ dicts/unicode-blocks.dict: unicode-parser
echo "Generated $@"; \
fi;
-ibusunicodegen.h:
- $(MAKE) $(AM_MAKEFLAGS) dicts/unicode-blocks.dict
-
unicode_parser_SOURCES = \
unicode-parser.c \
$(parser_extra_sources) \
--
2.41.0
From 139e0be07bfbc96d5ff95e5f5ebd760fbc7d94c0 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 12 Jul 2023 07:39:27 +0900
Subject: [PATCH 1/3] bus: Apply code style to inputcontext.c
---
bus/inputcontext.c | 528 +++++++++++++++++++++++++++------------------
1 file changed, 319 insertions(+), 209 deletions(-)
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
index e76bbdfc..8aded5d8 100644
--- a/bus/inputcontext.c
+++ b/bus/inputcontext.c
@@ -38,7 +38,8 @@ struct _SetEngineByDescData {
GTask *task;
/* a object to cancel bus_engine_proxy_new call */
GCancellable *cancellable;
- /* a object being passed to the bus_input_context_set_engine_by_desc function. if origin_cancellable is cancelled by someone,
+ /* a object being passed to the bus_input_context_set_engine_by_desc
+ * function. if origin_cancellable is cancelled by someone,
* we cancel the cancellable above as well. */
GCancellable *origin_cancellable;
gulong cancelled_handler_id;
@@ -211,112 +212,115 @@ static IBusPropList *props_empty = NULL;
* XML will be automatically rejected by the GDBus library (see
* src/ibusservice.c for details.) */
static const gchar introspection_xml[] =
- "<node>"
- " <interface name='org.freedesktop.IBus.InputContext'>"
+ "<node>\n"
+ " <interface name='org.freedesktop.IBus.InputContext'>\n"
/* properties */
- " <property name='ContentType' type='(uu)' access='write' />"
+ " <property name='ContentType' type='(uu)' access='write' />\n"
" <property name='ClientCommitPreedit' type='(b)' access='write' />\n"
/* methods */
- " <method name='ProcessKeyEvent'>"
- " <arg direction='in' type='u' name='keyval' />"
- " <arg direction='in' type='u' name='keycode' />"
- " <arg direction='in' type='u' name='state' />"
- " <arg direction='out' type='b' name='handled' />"
- " </method>"
- " <method name='SetCursorLocation'>"
- " <arg direction='in' type='i' name='x' />"
- " <arg direction='in' type='i' name='y' />"
- " <arg direction='in' type='i' name='w' />"
- " <arg direction='in' type='i' name='h' />"
- " </method>"
- " <method name='SetCursorLocationRelative'>"
- " <arg direction='in' type='i' name='x' />"
- " <arg direction='in' type='i' name='y' />"
- " <arg direction='in' type='i' name='w' />"
- " <arg direction='in' type='i' name='h' />"
- " </method>"
- " <method name='ProcessHandWritingEvent'>"
- " <arg direction='in' type='ad' name='coordinates' />"
- " </method>"
- " <method name='CancelHandWriting'>"
- " <arg direction='in' type='u' name='n_strokes' />"
- " </method>"
- " <method name='FocusIn' />"
- " <method name='FocusOut' />"
- " <method name='Reset' />"
- " <method name='SetCapabilities'>"
- " <arg direction='in' type='u' name='caps' />"
- " </method>"
- " <method name='PropertyActivate'>"
- " <arg direction='in' type='s' name='name' />"
- " <arg direction='in' type='u' name='state' />"
- " </method>"
- " <method name='SetEngine'>"
- " <arg direction='in' type='s' name='name' />"
- " </method>"
- " <method name='GetEngine'>"
- " <arg direction='out' type='v' name='desc' />"
- " </method>"
- " <method name='SetSurroundingText'>"
- " <arg direction='in' type='v' name='text' />"
- " <arg direction='in' type='u' name='cursor_pos' />"
- " <arg direction='in' type='u' name='anchor_pos' />"
- " </method>"
+ " <method name='ProcessKeyEvent'>\n"
+ " <arg direction='in' type='u' name='keyval' />\n"
+ " <arg direction='in' type='u' name='keycode' />\n"
+ " <arg direction='in' type='u' name='state' />\n"
+ " <arg direction='out' type='b' name='handled' />\n"
+ " </method>\n"
+ " <method name='SetCursorLocation'>\n"
+ " <arg direction='in' type='i' name='x' />\n"
+ " <arg direction='in' type='i' name='y' />\n"
+ " <arg direction='in' type='i' name='w' />\n"
+ " <arg direction='in' type='i' name='h' />\n"
+ " </method>\n"
+ " <method name='SetCursorLocationRelative'>\n"
+ " <arg direction='in' type='i' name='x' />\n"
+ " <arg direction='in' type='i' name='y' />\n"
+ " <arg direction='in' type='i' name='w' />\n"
+ " <arg direction='in' type='i' name='h' />\n"
+ " </method>\n"
+ " <method name='ProcessHandWritingEvent'>\n"
+ " <arg direction='in' type='ad' name='coordinates' />\n"
+ " </method>\n"
+ " <method name='CancelHandWriting'>\n"
+ " <arg direction='in' type='u' name='n_strokes' />\n"
+ " </method>\n"
+ " <method name='FocusIn' />\n"
+ " <method name='FocusOut' />\n"
+ " <method name='Reset' />\n"
+ " <method name='SetCapabilities'>\n"
+ " <arg direction='in' type='u' name='caps' />\n"
+ " </method>\n"
+ " <method name='PropertyActivate'>\n"
+ " <arg direction='in' type='s' name='name' />\n"
+ " <arg direction='in' type='u' name='state' />\n"
+ " </method>\n"
+ " <method name='SetEngine'>\n"
+ " <arg direction='in' type='s' name='name' />\n"
+ " </method>\n"
+ " <method name='GetEngine'>\n"
+ " <arg direction='out' type='v' name='desc' />\n"
+ " </method>\n"
+ " <method name='SetSurroundingText'>\n"
+ " <arg direction='in' type='v' name='text' />\n"
+ " <arg direction='in' type='u' name='cursor_pos' />\n"
+ " <arg direction='in' type='u' name='anchor_pos' />\n"
+ " </method>\n"
/* signals */
- " <signal name='CommitText'>"
- " <arg type='v' name='text' />"
- " </signal>"
- " <signal name='ForwardKeyEvent'>"
- " <arg type='u' name='keyval' />"
- " <arg type='u' name='keycode' />"
- " <arg type='u' name='state' />"
- " </signal>"
- " <signal name='UpdatePreeditText'>"
- " <arg type='v' name='text' />"
- " <arg type='u' name='cursor_pos' />"
- " <arg type='b' name='visible' />"
- " </signal>"
- " <signal name='UpdatePreeditTextWithMode'>"
- " <arg type='v' name='text' />"
- " <arg type='u' name='cursor_pos' />"
- " <arg type='b' name='visible' />"
- " <arg type='u' name='mode' />"
- " </signal>"
- " <signal name='ShowPreeditText'/>"
- " <signal name='HidePreeditText'/>"
- " <signal name='UpdateAuxiliaryText'>"
- " <arg type='v' name='text' />"
- " <arg type='b' name='visible' />"
- " </signal>"
- " <signal name='ShowAuxiliaryText'/>"
- " <signal name='HideAuxiliaryText'/>"
- " <signal name='UpdateLookupTable'>"
- " <arg type='v' name='table' />"
- " <arg type='b' name='visible' />"
- " </signal>"
- " <signal name='ShowLookupTable'/>"
- " <signal name='HideLookupTable'/>"
- " <signal name='PageUpLookupTable'/>"
- " <signal name='PageDownLookupTable'/>"
- " <signal name='CursorUpLookupTable'/>"
- " <signal name='CursorDownLookupTable'/>"
- " <signal name='RegisterProperties'>"
- " <arg type='v' name='props' />"
- " </signal>"
- " <signal name='UpdateProperty'>"
- " <arg type='v' name='prop' />"
- " </signal>"
- " </interface>"
- "</node>";
+ " <signal name='CommitText'>\n"
+ " <arg type='v' name='text' />\n"
+ " </signal>\n"
+ " <signal name='ForwardKeyEvent'>\n"
+ " <arg type='u' name='keyval' />\n"
+ " <arg type='u' name='keycode' />\n"
+ " <arg type='u' name='state' />\n"
+ " </signal>\n"
+ " <signal name='UpdatePreeditText'>\n"
+ " <arg type='v' name='text' />\n"
+ " <arg type='u' name='cursor_pos' />\n"
+ " <arg type='b' name='visible' />\n"
+ " </signal>\n"
+ " <signal name='UpdatePreeditTextWithMode'>\n"
+ " <arg type='v' name='text' />\n"
+ " <arg type='u' name='cursor_pos' />\n"
+ " <arg type='b' name='visible' />\n"
+ " <arg type='u' name='mode' />\n"
+ " </signal>\n"
+ " <signal name='ShowPreeditText'/>\n"
+ " <signal name='HidePreeditText'/>\n"
+ " <signal name='UpdateAuxiliaryText'>\n"
+ " <arg type='v' name='text' />\n"
+ " <arg type='b' name='visible' />\n"
+ " </signal>\n"
+ " <signal name='ShowAuxiliaryText'/>\n"
+ " <signal name='HideAuxiliaryText'/>\n"
+ " <signal name='UpdateLookupTable'>\n"
+ " <arg type='v' name='table' />\n"
+ " <arg type='b' name='visible' />\n"
+ " </signal>\n"
+ " <signal name='ShowLookupTable'/>\n"
+ " <signal name='HideLookupTable'/>\n"
+ " <signal name='PageUpLookupTable'/>\n"
+ " <signal name='PageDownLookupTable'/>\n"
+ " <signal name='CursorUpLookupTable'/>\n"
+ " <signal name='CursorDownLookupTable'/>\n"
+ " <signal name='RegisterProperties'>\n"
+ " <arg type='v' name='props' />\n"
+ " </signal>\n"
+ " <signal name='UpdateProperty'>\n"
+ " <arg type='v' name='prop' />\n"
+ " </signal>\n"
+ " </interface>\n"
+ "</node>\n";
G_DEFINE_TYPE (BusInputContext, bus_input_context, IBUS_TYPE_SERVICE)
-/* TRUE if we can send preedit text to client. FALSE if the panel has to handle it. Note that we check IBUS_CAP_FOCUS here since
- * when the capability is not set, the client has to handle a preedit text regardless of the embed_preedit_text config. */
+/* TRUE if we can send preedit text to client. FALSE if the panel has to handle
+ * it. Note that we check IBUS_CAP_FOCUS here since
+ * when the capability is not set, the client has to handle a preedit text
+ * regardless of the embed_preedit_text config. */
#define PREEDIT_CONDITION \
((context->capabilities & IBUS_CAP_PREEDIT_TEXT) && \
- (bus_ibus_impl_is_embed_preedit_text (BUS_DEFAULT_IBUS) || (context->capabilities & IBUS_CAP_FOCUS) == 0))
+ (bus_ibus_impl_is_embed_preedit_text (\
+ BUS_DEFAULT_IBUS) || (context->capabilities & IBUS_CAP_FOCUS) == 0))
static void
_connection_destroy_cb (BusConnection *connection,
@@ -343,17 +347,21 @@ bus_input_context_class_init (BusInputContextClass *class)
"");
g_object_ref_sink (class->default_engine_desc);
- ibus_object_class->destroy = (IBusObjectDestroyFunc) bus_input_context_destroy;
+ ibus_object_class->destroy =
+ (IBusObjectDestroyFunc)bus_input_context_destroy;
/* override the parent class's implementation. */
IBUS_SERVICE_CLASS (class)->service_method_call =
bus_input_context_service_method_call;
IBUS_SERVICE_CLASS (class)->service_set_property =
bus_input_context_service_set_property;
- /* register the xml so that bus_ibus_impl_service_method_call will be called on a method call defined in the xml (e.g. 'FocusIn'.) */
+ /* register the xml so that bus_ibus_impl_service_method_call will be
+ * called on a method call defined in the xml (e.g. 'FocusIn'.) */
ibus_service_class_add_interfaces (IBUS_SERVICE_CLASS (class), introspection_xml);
- /* install glib signals that would be handled by other classes like ibusimpl.c and panelproxy.c. */
+ /* install glib signals that would be handled by other classes like
+ * ibusimpl.c and panelproxy.c.
+ */
context_signals[PROCESS_KEY_EVENT] =
g_signal_new (I_("process-key-event"),
G_TYPE_FROM_CLASS (class),
@@ -576,8 +584,11 @@ bus_input_context_class_init (BusInputContextClass *class)
G_TYPE_NONE,
0);
- /* This signal is not for notifying an event on this object, but is for requesting an engine as the name shows.
- * On the signal emission, ibusimpl.c will immediately update the context->engine variable. */
+ /* This signal is not for notifying an event on this object, but is for
+ * requesting an engine as the name shows.
+ * On the signal emission, ibusimpl.c will immediately update the
+ * context->engine variable.
+ */
context_signals[REQUEST_ENGINE] =
g_signal_new (I_("request-engine"),
G_TYPE_FROM_CLASS (class),
@@ -614,7 +625,8 @@ bus_input_context_class_init (BusInputContextClass *class)
text_empty = ibus_text_new_from_string ("");
g_object_ref_sink (text_empty);
- lookup_table_empty = ibus_lookup_table_new (9 /* page size */, 0, FALSE, FALSE);
+ lookup_table_empty = ibus_lookup_table_new (9 /* page size */,
+ 0, FALSE, FALSE);
g_object_ref_sink (lookup_table_empty);
props_empty = ibus_prop_list_new ();
g_object_ref_sink (props_empty);
@@ -662,9 +674,10 @@ bus_input_context_destroy (BusInputContext *context)
}
if (context->connection) {
- g_signal_handlers_disconnect_by_func (context->connection,
- (GCallback) _connection_destroy_cb,
- context);
+ g_signal_handlers_disconnect_by_func (
+ context->connection,
+ (GCallback) _connection_destroy_cb,
+ context);
g_object_unref (context->connection);
context->connection = NULL;
}
@@ -674,7 +687,8 @@ bus_input_context_destroy (BusInputContext *context)
context->client = NULL;
}
- IBUS_OBJECT_CLASS (bus_input_context_parent_class)->destroy (IBUS_OBJECT (context));
+ IBUS_OBJECT_CLASS (bus_input_context_parent_class)->
+ destroy (IBUS_OBJECT (context));
}
static gboolean
@@ -689,25 +703,30 @@ bus_input_context_send_signal (BusInputContext *context,
return TRUE;
}
- GDBusMessage *message = g_dbus_message_new_signal (ibus_service_get_object_path ((IBusService *)context),
- interface_name,
- signal_name);
+ GDBusMessage *message = g_dbus_message_new_signal (
+ ibus_service_get_object_path ((IBusService *)context),
+ interface_name,
+ signal_name);
g_dbus_message_set_sender (message, "org.freedesktop.IBus");
- g_dbus_message_set_destination (message, bus_connection_get_unique_name (context->connection));
+ g_dbus_message_set_destination (
+ message,
+ bus_connection_get_unique_name (context->connection));
if (parameters != NULL)
g_dbus_message_set_body (message, parameters);
- gboolean retval = g_dbus_connection_send_message (bus_connection_get_dbus_connection (context->connection),
- message,
- G_DBUS_SEND_MESSAGE_FLAGS_NONE,
- NULL, error);
+ gboolean retval = g_dbus_connection_send_message (
+ bus_connection_get_dbus_connection (context->connection),
+ message,
+ G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+ NULL, error);
g_object_unref (message);
return retval;
}
/**
* bus_input_context_emit_signal:
- * @signal_name: The D-Bus signal name to emit which is in the introspection_xml.
+ * @signal_name: The D-Bus signal name to emit which is in the
+ * introspection_xml.
*
* Emit the D-Bus signal.
*/
@@ -850,9 +869,9 @@ _ic_process_key_event_reply_cb (GObject *source,
* org.freedesktop.IBus.InputContext interface.
*/
static void
-_ic_process_key_event (BusInputContext *context,
- GVariant *parameters,
- GDBusMethodInvocation *invocation)
+_ic_process_key_event (BusInputContext *context,
+ GVariant *parameters,
+ GDBusMethodInvocation *invocation)
{
guint keyval = IBUS_KEY_VoidSymbol;
guint keycode = 0;
@@ -925,7 +944,8 @@ _ic_process_key_event (BusInputContext *context,
/**
* _ic_set_cursor_location:
*
- * Implement the "SetCursorLocation" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "SetCursorLocation" method call of the
+ * org.freedesktop.IBus.InputContext interface.
*/
static void
_ic_set_cursor_location (BusInputContext *context,
@@ -1008,7 +1028,8 @@ _ic_process_hand_writing_event (BusInputContext *context,
/* do nothing if it is a fake input context */
if (context->has_focus &&
context->engine && context->fake == FALSE) {
- bus_engine_proxy_process_hand_writing_event (context->engine, parameters);
+ bus_engine_proxy_process_hand_writing_event (context->engine,
+ parameters);
}
g_dbus_method_invocation_return_value (invocation, NULL);
}
@@ -1032,7 +1053,8 @@ _ic_cancel_hand_writing (BusInputContext *context,
/**
* _ic_focus_in:
*
- * Implement the "FocusIn" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "FocusIn" method call of the org.freedesktop.IBus.InputContext
+ * interface.
*/
static void
_ic_focus_in (BusInputContext *context,
@@ -1044,15 +1066,17 @@ _ic_focus_in (BusInputContext *context,
g_dbus_method_invocation_return_value (invocation, NULL);
}
else {
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "The input context does not support focus.");
+ g_dbus_method_invocation_return_error (
+ invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+ "The input context does not support focus.");
}
}
/**
* _ic_focus_out:
*
- * Implement the "FocusOut" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "FocusOut" method call of the org.freedesktop.IBus.InputContext
+ * interface.
*/
static void
_ic_focus_out (BusInputContext *context,
@@ -1064,15 +1088,17 @@ _ic_focus_out (BusInputContext *context,
g_dbus_method_invocation_return_value (invocation, NULL);
}
else {
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "The input context does not support focus.");
+ g_dbus_method_invocation_return_error (
+ invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+ "The input context does not support focus.");
}
}
/**
* _ic_reset:
*
- * Implement the "Reset" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "Reset" method call of the org.freedesktop.IBus.InputContext
+ * interface.
*/
static void
_ic_reset (BusInputContext *context,
@@ -1094,7 +1120,8 @@ _ic_reset (BusInputContext *context,
/**
* _ic_set_capabilities:
*
- * Implement the "SetCapabilities" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "SetCapabilities" method call of the
+ * org.freedesktop.IBus.InputContext interface.
*/
static void
_ic_set_capabilities (BusInputContext *context,
@@ -1112,7 +1139,8 @@ _ic_set_capabilities (BusInputContext *context,
/**
* _ic_property_activate:
*
- * Implement the "PropertyActivate" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "PropertyActivate" method call of the
+ * org.freedesktop.IBus.InputContext interface.
*/
static void
_ic_property_activate (BusInputContext *context,
@@ -1124,7 +1152,9 @@ _ic_property_activate (BusInputContext *context,
g_variant_get (parameters, "(&su)", &prop_name, &prop_state);
if (context->engine) {
- bus_engine_proxy_property_activate (context->engine, prop_name, prop_state);
+ bus_engine_proxy_property_activate (context->engine,
+ prop_name,
+ prop_state);
}
#ifdef OS_CHROMEOS
@@ -1132,9 +1162,12 @@ _ic_property_activate (BusInputContext *context,
* so pass PropertyActivate signal to the focused context.
*/
else if (context->fake) {
- BusInputContext *focused_context = bus_ibus_impl_get_focused_input_context (BUS_DEFAULT_IBUS);
+ BusInputContext *focused_context =
+ bus_ibus_impl_get_focused_input_context (BUS_DEFAULT_IBUS);
if (focused_context && focused_context->engine)
- bus_engine_proxy_property_activate (focused_context->engine, prop_name, prop_state);
+ bus_engine_proxy_property_activate (focused_context->engine,
+ prop_name,
+ prop_state);
}
#endif
@@ -1164,7 +1197,8 @@ _ic_set_engine_done (BusInputContext *context,
/**
* _ic_set_engine:
*
- * Implement the "SetEngine" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "SetEngine" method call of the
+ * org.freedesktop.IBus.InputContext interface.
*/
static void
_ic_set_engine (BusInputContext *context,
@@ -1205,7 +1239,8 @@ _ic_set_engine (BusInputContext *context,
/**
* _ic_get_engine:
*
- * Implement the "GetEngine" method call of the org.freedesktop.IBus.InputContext interface.
+ * Implement the "GetEngine" method call of
+ * the org.freedesktop.IBus.InputContext interface.
*/
static void
_ic_get_engine (BusInputContext *context,
@@ -1218,7 +1253,9 @@ _ic_get_engine (BusInputContext *context,
g_dbus_method_invocation_return_value (invocation,
- g_variant_new ("(v)", ibus_serializable_serialize ((IBusSerializable *)desc)));
+ g_variant_new ("(v)",
+ ibus_serializable_serialize (
+ (IBusSerializable *)desc)));
}
static void
@@ -1270,7 +1307,8 @@ bus_input_context_service_authorized_method (IBusService *service,
/**
* bus_input_context_service_method_call:
*
- * Handle a D-Bus method call whose destination and interface name are both "org.freedesktop.IBus.InputContext"
+ * Handle a D-Bus method call whose destination and interface name are both
+ * "org.freedesktop.IBus.InputContext"
*/
static void
bus_input_context_service_method_call (IBusService *service,
@@ -1283,21 +1321,23 @@ bus_input_context_service_method_call (IBusService *service,
GDBusMethodInvocation *invocation)
{
if (g_strcmp0 (interface_name, IBUS_INTERFACE_INPUT_CONTEXT) != 0) {
- IBUS_SERVICE_CLASS (bus_input_context_parent_class)->service_method_call (
- service,
- connection,
- sender,
- object_path,
- interface_name,
- method_name,
- parameters,
- invocation);
+ IBUS_SERVICE_CLASS (bus_input_context_parent_class)->
+ service_method_call (service,
+ connection,
+ sender,
+ object_path,
+ interface_name,
+ method_name,
+ parameters,
+ invocation);
return;
}
static const struct {
const gchar *method_name;
- void (* method_callback) (BusInputContext *, GVariant *, GDBusMethodInvocation *);
+ void (* method_callback) (BusInputContext *,
+ GVariant *,
+ GDBusMethodInvocation *);
} methods [] = {
{ "ProcessKeyEvent", _ic_process_key_event },
{ "SetCursorLocation", _ic_set_cursor_location },
@@ -1322,7 +1362,9 @@ bus_input_context_service_method_call (IBusService *service,
for (i = 0; i < G_N_ELEMENTS (methods); i++) {
if (g_strcmp0 (method_name, methods[i].method_name) == 0) {
- methods[i].method_callback ((BusInputContext *)service, parameters, invocation);
+ methods[i].method_callback ((BusInputContext *)service,
+ parameters,
+ invocation);
return;
}
}
@@ -1465,15 +1507,23 @@ bus_input_context_focus_in (BusInputContext *context)
ibus_service_get_object_path ((IBusService *)context);
bus_engine_proxy_focus_in (context->engine, path, context->client);
bus_engine_proxy_enable (context->engine);
- bus_engine_proxy_set_capabilities (context->engine, context->capabilities);
- bus_engine_proxy_set_cursor_location (context->engine, context->x, context->y, context->w, context->h);
- bus_engine_proxy_set_content_type (context->engine, context->purpose, context->hints);
+ bus_engine_proxy_set_capabilities (context->engine,
+ context->capabilities);
+ bus_engine_proxy_set_cursor_location (context->engine,
+ context->x,
+ context->y,
+ context->w,
+ context->h);
+ bus_engine_proxy_set_content_type (context->engine,
+ context->purpose,
+ context->hints);
}
if (context->capabilities & IBUS_CAP_FOCUS) {
g_signal_emit (context, context_signals[FOCUS_IN], 0);
if (context->engine) {
- /* if necessary, emit glib signals to the context object to update panel status. see the comment for PREEDIT_CONDITION
+ /* if necessary, emit glib signals to the context object to update
+ * panel status. see the comment for PREEDIT_CONDITION
* for details. */
if (context->preedit_visible && !PREEDIT_CONDITION) {
g_signal_emit (context,
@@ -1483,14 +1533,16 @@ bus_input_context_focus_in (BusInputContext *context)
context->preedit_cursor_pos,
context->preedit_visible);
}
- if (context->auxiliary_visible && (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
+ if (context->auxiliary_visible &&
+ (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == 0) {
g_signal_emit (context,
context_signals[UPDATE_AUXILIARY_TEXT],
0,
context->auxiliary_text,
context->auxiliary_visible);
}
- if (context->lookup_table_visible && (context->capabilities & IBUS_CAP_LOOKUP_TABLE) == 0) {
+ if (context->lookup_table_visible &&
+ (context->capabilities & IBUS_CAP_LOOKUP_TABLE) == 0) {
g_signal_emit (context,
context_signals[UPDATE_LOOKUP_TABLE],
0,
@@ -1630,14 +1682,17 @@ bus_input_context_property_activate (BusInputContext *context,
g_assert (BUS_IS_INPUT_CONTEXT (context));
if (context->engine) {
- bus_engine_proxy_property_activate (context->engine, prop_name, prop_state);
+ bus_engine_proxy_property_activate (context->engine,
+ prop_name,
+ prop_state);
}
}
/**
* bus_input_context_show_preedit_text:
*
- * Show a preedit text. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Show a preedit text. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_show_preedit_text (BusInputContext *context,
@@ -1678,7 +1733,8 @@ bus_input_context_show_preedit_text (BusInputContext *context,
/**
* bus_input_context_hide_preedit_text:
*
- * Hide a preedit text. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Hide a preedit text. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_hide_preedit_text (BusInputContext *context,
@@ -1717,7 +1773,8 @@ bus_input_context_hide_preedit_text (BusInputContext *context,
/**
* bus_input_context_update_auxiliary_text:
*
- * Update an aux text. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Update an aux text. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_update_auxiliary_text (BusInputContext *context,
@@ -1730,11 +1787,13 @@ bus_input_context_update_auxiliary_text (BusInputContext *context,
g_object_unref (context->auxiliary_text);
}
- context->auxiliary_text = (IBusText *) g_object_ref_sink (text ? text : text_empty);
+ context->auxiliary_text = (IBusText *)g_object_ref_sink (
+ text ? text : text_empty);
context->auxiliary_visible = visible;
if (context->capabilities & IBUS_CAP_AUXILIARY_TEXT) {
- GVariant *variant = ibus_serializable_serialize ((IBusSerializable *)text);
+ GVariant *variant =
+ ibus_serializable_serialize ((IBusSerializable *)text);
bus_input_context_emit_signal (context,
"UpdateAuxiliaryText",
g_variant_new ("(vb)", variant, visible),
@@ -1752,7 +1811,8 @@ bus_input_context_update_auxiliary_text (BusInputContext *context,
/**
* bus_input_context_show_auxiliary_text:
*
- * Show an aux text. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Show an aux text. Send D-Bus signal to update status of client or send glib
+ * signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_show_auxiliary_text (BusInputContext *context)
@@ -1765,7 +1825,8 @@ bus_input_context_show_auxiliary_text (BusInputContext *context)
context->auxiliary_visible = TRUE;
- if ((context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == IBUS_CAP_AUXILIARY_TEXT) {
+ if ((context->capabilities & IBUS_CAP_AUXILIARY_TEXT)
+ == IBUS_CAP_AUXILIARY_TEXT) {
bus_input_context_emit_signal (context,
"ShowAuxiliaryText",
NULL,
@@ -1781,7 +1842,8 @@ bus_input_context_show_auxiliary_text (BusInputContext *context)
/**
* bus_input_context_hide_auxiliary_text:
*
- * Hide an aux text. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Hide an aux text. Send D-Bus signal to update status of client or send glib
+ * signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_hide_auxiliary_text (BusInputContext *context)
@@ -1794,7 +1856,8 @@ bus_input_context_hide_auxiliary_text (BusInputContext *context)
context->auxiliary_visible = FALSE;
- if ((context->capabilities & IBUS_CAP_AUXILIARY_TEXT) == IBUS_CAP_AUXILIARY_TEXT) {
+ if ((context->capabilities & IBUS_CAP_AUXILIARY_TEXT)
+ == IBUS_CAP_AUXILIARY_TEXT) {
bus_input_context_emit_signal (context,
"HideAuxiliaryText",
NULL,
@@ -1829,11 +1892,13 @@ bus_input_context_update_lookup_table (BusInputContext *context,
g_object_unref (context->lookup_table);
}
- context->lookup_table = (IBusLookupTable *) g_object_ref_sink (table ? table : lookup_table_empty);
+ context->lookup_table = (IBusLookupTable *)g_object_ref_sink (
+ table ? table : lookup_table_empty);
context->lookup_table_visible = visible;
if (context->capabilities & IBUS_CAP_LOOKUP_TABLE) {
- GVariant *variant = ibus_serializable_serialize ((IBusSerializable *)table);
+ GVariant *variant =
+ ibus_serializable_serialize ((IBusSerializable *)table);
bus_input_context_emit_signal (context,
"UpdateLookupTable",
g_variant_new ("(vb)", variant, visible),
@@ -1851,7 +1916,8 @@ bus_input_context_update_lookup_table (BusInputContext *context,
/**
* bus_input_context_show_lookup_table:
*
- * Show the lookup table. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Show the lookup table. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_show_lookup_table (BusInputContext *context)
@@ -1864,7 +1930,8 @@ bus_input_context_show_lookup_table (BusInputContext *context)
context->lookup_table_visible = TRUE;
- if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
+ if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE)
+ == IBUS_CAP_LOOKUP_TABLE) {
bus_input_context_emit_signal (context,
"ShowLookupTable",
NULL,
@@ -1880,7 +1947,8 @@ bus_input_context_show_lookup_table (BusInputContext *context)
/**
* bus_input_context_hide_lookup_table:
*
- * Hide the lookup table. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Hide the lookup table. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_hide_lookup_table (BusInputContext *context)
@@ -1893,7 +1961,8 @@ bus_input_context_hide_lookup_table (BusInputContext *context)
context->lookup_table_visible = FALSE;
- if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
+ if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE)
+ == IBUS_CAP_LOOKUP_TABLE) {
bus_input_context_emit_signal (context,
"HideLookupTable",
NULL,
@@ -1909,7 +1978,8 @@ bus_input_context_hide_lookup_table (BusInputContext *context)
/**
* bus_input_context_page_up_lookup_table:
*
- * Change cursor position. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Change cursor position. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_page_up_lookup_table (BusInputContext *context)
@@ -1920,7 +1990,8 @@ bus_input_context_page_up_lookup_table (BusInputContext *context)
return;
}
- if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
+ if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE)
+ == IBUS_CAP_LOOKUP_TABLE) {
bus_input_context_emit_signal (context,
"PageUpLookupTable",
NULL,
@@ -1936,7 +2007,8 @@ bus_input_context_page_up_lookup_table (BusInputContext *context)
/**
* bus_input_context_page_down_lookup_table:
*
- * Change cursor position. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Change cursor position. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_page_down_lookup_table (BusInputContext *context)
@@ -1947,7 +2019,8 @@ bus_input_context_page_down_lookup_table (BusInputContext *context)
return;
}
- if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
+ if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE)
+ == IBUS_CAP_LOOKUP_TABLE) {
bus_input_context_emit_signal (context,
"PageDownLookupTable",
NULL,
@@ -1963,7 +2036,8 @@ bus_input_context_page_down_lookup_table (BusInputContext *context)
/**
* bus_input_context_cursor_up_lookup_table:
*
- * Change cursor position. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Change cursor position. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_cursor_up_lookup_table (BusInputContext *context)
@@ -1974,7 +2048,8 @@ bus_input_context_cursor_up_lookup_table (BusInputContext *context)
return;
}
- if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
+ if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE)
+ == IBUS_CAP_LOOKUP_TABLE) {
bus_input_context_emit_signal (context,
"CursorUpLookupTable",
NULL,
@@ -1990,7 +2065,8 @@ bus_input_context_cursor_up_lookup_table (BusInputContext *context)
/**
* bus_input_context_cursor_down_lookup_table:
*
- * Change cursor position. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Change cursor position. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_cursor_down_lookup_table (BusInputContext *context)
@@ -2001,7 +2077,8 @@ bus_input_context_cursor_down_lookup_table (BusInputContext *context)
return;
}
- if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE) == IBUS_CAP_LOOKUP_TABLE) {
+ if ((context->capabilities & IBUS_CAP_LOOKUP_TABLE)
+ == IBUS_CAP_LOOKUP_TABLE) {
bus_input_context_emit_signal (context,
"CursorDownLookupTable",
NULL,
@@ -2017,7 +2094,8 @@ bus_input_context_cursor_down_lookup_table (BusInputContext *context)
/**
* bus_input_context_register_properties:
*
- * Register properties. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Register properties. Send D-Bus signal to update status of client or send
+ * glib signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_register_properties (BusInputContext *context,
@@ -2027,7 +2105,8 @@ bus_input_context_register_properties (BusInputContext *context,
g_assert (IBUS_IS_PROP_LIST (props));
if (context->capabilities & IBUS_CAP_PROPERTY) {
- GVariant *variant = ibus_serializable_serialize ((IBusSerializable *)props);
+ GVariant *variant =
+ ibus_serializable_serialize ((IBusSerializable *)props);
bus_input_context_emit_signal (context,
"RegisterProperties",
g_variant_new ("(v)", variant),
@@ -2044,7 +2123,8 @@ bus_input_context_register_properties (BusInputContext *context,
/**
* bus_input_context_update_property:
*
- * Update property. Send D-Bus signal to update status of client or send glib signal to the panel, depending on capabilities of the client.
+ * Update property. Send D-Bus signal to update status of client or send glib
+ * signal to the panel, depending on capabilities of the client.
*/
static void
bus_input_context_update_property (BusInputContext *context,
@@ -2054,7 +2134,8 @@ bus_input_context_update_property (BusInputContext *context,
g_assert (IBUS_IS_PROPERTY (prop));
if (context->capabilities & IBUS_CAP_PROPERTY) {
- GVariant *variant = ibus_serializable_serialize ((IBusSerializable *)prop);
+ GVariant *variant =
+ ibus_serializable_serialize ((IBusSerializable *)prop);
bus_input_context_emit_signal (context,
"UpdateProperty",
g_variant_new ("(v)", variant),
@@ -2089,7 +2170,8 @@ _engine_destroy_cb (BusEngineProxy *engine,
/**
* _engine_commit_text_cb:
*
- * A function to be called when "commit-text" glib signal is sent to the engine object.
+ * A function to be called when "commit-text" glib signal is sent to the engine
+ * object.
*/
static void
_engine_commit_text_cb (BusEngineProxy *engine,
@@ -2108,7 +2190,8 @@ _engine_commit_text_cb (BusEngineProxy *engine,
/**
* _engine_forward_key_event_cb:
*
- * A function to be called when "forward-key-event" glib signal is sent to the engine object.
+ * A function to be called when "forward-key-event" glib signal is sent to the
+ * engine object.
*/
static void
_engine_forward_key_event_cb (BusEngineProxy *engine,
@@ -2124,14 +2207,16 @@ _engine_forward_key_event_cb (BusEngineProxy *engine,
bus_input_context_emit_signal (context,
"ForwardKeyEvent",
- g_variant_new ("(uuu)", keyval, keycode, state),
+ g_variant_new ("(uuu)",
+ keyval, keycode, state),
NULL);
}
/**
* _engine_delete_surrounding_text_cb:
*
- * A function to be called when "delete-surrounding-text" glib signal is sent to the engine object.
+ * A function to be called when "delete-surrounding-text" glib signal is sent
+ * to the engine object.
*/
static void
_engine_delete_surrounding_text_cb (BusEngineProxy *engine,
@@ -2146,14 +2231,16 @@ _engine_delete_surrounding_text_cb (BusEngineProxy *engine,
bus_input_context_emit_signal (context,
"DeleteSurroundingText",
- g_variant_new ("(iu)", offset_from_cursor, nchars),
+ g_variant_new ("(iu)",
+ offset_from_cursor, nchars),
NULL);
}
/**
* _engine_require_surrounding_text_cb:
*
- * A function to be called when "require-surrounding-text" glib signal is sent to the engine object.
+ * A function to be called when "require-surrounding-text" glib signal is sent
+ * to the engine object.
*/
static void
_engine_require_surrounding_text_cb (BusEngineProxy *engine,
@@ -2173,7 +2260,8 @@ _engine_require_surrounding_text_cb (BusEngineProxy *engine,
/**
* _engine_update_preedit_text_cb:
*
- * A function to be called when "update-preedit-text" glib signal is sent to the engine object.
+ * A function to be called when "update-preedit-text" glib signal is sent to
+ * the engine object.
*/
static void
_engine_update_preedit_text_cb (BusEngineProxy *engine,
@@ -2197,7 +2285,8 @@ _engine_update_preedit_text_cb (BusEngineProxy *engine,
/**
* _engine_update_auxiliary_text_cb:
*
- * A function to be called when "update-auxiliary-text" glib signal is sent to the engine object.
+ * A function to be called when "update-auxiliary-text" glib signal is sent to
+ * the engine object.
*/
static void
_engine_update_auxiliary_text_cb (BusEngineProxy *engine,
@@ -2217,7 +2306,8 @@ _engine_update_auxiliary_text_cb (BusEngineProxy *engine,
/**
* _engine_update_lookup_table_cb:
*
- * A function to be called when "update-lookup-table" glib signal is sent to the engine object.
+ * A function to be called when "update-lookup-table" glib signal is sent to
+ * the engine object.
*/
static void
_engine_update_lookup_table_cb (BusEngineProxy *engine,
@@ -2237,7 +2327,8 @@ _engine_update_lookup_table_cb (BusEngineProxy *engine,
/**
* _engine_register_properties_cb:
*
- * A function to be called when "register-properties" glib signal is sent to the engine object.
+ * A function to be called when "register-properties" glib signal is sent to
+ * the engine object.
*/
static void
_engine_register_properties_cb (BusEngineProxy *engine,
@@ -2256,7 +2347,8 @@ _engine_register_properties_cb (BusEngineProxy *engine,
/**
* _engine_update_property_cb:
*
- * A function to be called when "update-property" glib signal is sent to the engine object.
+ * A function to be called when "update-property" glib signal is sent to the
+ * engine object.
*/
static void
_engine_update_property_cb (BusEngineProxy *engine,
@@ -2346,10 +2438,11 @@ bus_input_context_new (BusConnection *connection,
BusInputContext *context = NULL;
if (connection) {
- context = (BusInputContext *) g_object_new (BUS_TYPE_INPUT_CONTEXT,
- "object-path", path,
- "connection", bus_connection_get_dbus_connection (connection),
- NULL);
+ context = (BusInputContext *) g_object_new (
+ BUS_TYPE_INPUT_CONTEXT,
+ "object-path", path,
+ "connection", bus_connection_get_dbus_connection (connection),
+ NULL);
}
else {
context = (BusInputContext *) g_object_new (BUS_TYPE_INPUT_CONTEXT,
@@ -2439,28 +2532,37 @@ bus_input_context_disable (BusInputContext *context)
}
}
-/* A list of signals (and their handler functions) that could be emit by the engine proxy object. */
+/* A list of signals (and their handler functions) that could be emit by the
+ * engine proxy object.
+ */
const static struct {
const gchar *name;
GCallback callback;
} engine_signals [] = {
{ "commit-text", G_CALLBACK (_engine_commit_text_cb) },
{ "forward-key-event", G_CALLBACK (_engine_forward_key_event_cb) },
- { "delete-surrounding-text", G_CALLBACK (_engine_delete_surrounding_text_cb) },
- { "require-surrounding-text", G_CALLBACK (_engine_require_surrounding_text_cb) },
+ { "delete-surrounding-text",
+ G_CALLBACK (_engine_delete_surrounding_text_cb) },
+ { "require-surrounding-text",
+ G_CALLBACK (_engine_require_surrounding_text_cb) },
{ "update-preedit-text", G_CALLBACK (_engine_update_preedit_text_cb) },
{ "show-preedit-text", G_CALLBACK (_engine_show_preedit_text_cb) },
{ "hide-preedit-text", G_CALLBACK (_engine_hide_preedit_text_cb) },
- { "update-auxiliary-text", G_CALLBACK (_engine_update_auxiliary_text_cb) },
+ { "update-auxiliary-text",
+ G_CALLBACK (_engine_update_auxiliary_text_cb) },
{ "show-auxiliary-text", G_CALLBACK (_engine_show_auxiliary_text_cb) },
{ "hide-auxiliary-text", G_CALLBACK (_engine_hide_auxiliary_text_cb) },
{ "update-lookup-table", G_CALLBACK (_engine_update_lookup_table_cb) },
{ "show-lookup-table", G_CALLBACK (_engine_show_lookup_table_cb) },
{ "hide-lookup-table", G_CALLBACK (_engine_hide_lookup_table_cb) },
- { "page-up-lookup-table", G_CALLBACK (_engine_page_up_lookup_table_cb) },
- { "page-down-lookup-table", G_CALLBACK (_engine_page_down_lookup_table_cb) },
- { "cursor-up-lookup-table", G_CALLBACK (_engine_cursor_up_lookup_table_cb) },
- { "cursor-down-lookup-table", G_CALLBACK (_engine_cursor_down_lookup_table_cb) },
+ { "page-up-lookup-table",
+ G_CALLBACK (_engine_page_up_lookup_table_cb) },
+ { "page-down-lookup-table",
+ G_CALLBACK (_engine_page_down_lookup_table_cb) },
+ { "cursor-up-lookup-table",
+ G_CALLBACK (_engine_cursor_up_lookup_table_cb) },
+ { "cursor-down-lookup-table",
+ G_CALLBACK (_engine_cursor_down_lookup_table_cb) },
{ "register-properties", G_CALLBACK (_engine_register_properties_cb) },
{ "update-property", G_CALLBACK (_engine_update_property_cb) },
{ "panel-extension", G_CALLBACK (_engine_panel_extension_cb) },
@@ -2531,9 +2633,16 @@ bus_input_context_set_engine (BusInputContext *context,
ibus_service_get_object_path ((IBusService *)context);
bus_engine_proxy_focus_in (context->engine, path, context->client);
bus_engine_proxy_enable (context->engine);
- bus_engine_proxy_set_capabilities (context->engine, context->capabilities);
- bus_engine_proxy_set_cursor_location (context->engine, context->x, context->y, context->w, context->h);
- bus_engine_proxy_set_content_type (context->engine, context->purpose, context->hints);
+ bus_engine_proxy_set_capabilities (context->engine,
+ context->capabilities);
+ bus_engine_proxy_set_cursor_location (context->engine,
+ context->x,
+ context->y,
+ context->w,
+ context->h);
+ bus_engine_proxy_set_content_type (context->engine,
+ context->purpose,
+ context->hints);
}
}
g_signal_emit (context,
@@ -2779,7 +2888,8 @@ bus_input_context_set_capabilities (BusInputContext *context,
{
g_assert (BUS_IS_INPUT_CONTEXT (context));
- /* If the context does not support IBUS_CAP_FOCUS, then the client application have to handle all information such as
+ /* If the context does not support IBUS_CAP_FOCUS, then the client
+ * application have to handle all information such as
* preedit and auxiliary text. */
if ((capabilities & IBUS_CAP_FOCUS) == 0) {
capabilities |= (IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_AUXILIARY_TEXT | IBUS_CAP_LOOKUP_TABLE | IBUS_CAP_PROPERTY);
--
2.41.0
From 3670faf74a7b4594ceda3b4a8c01515840cc1991 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 12 Jul 2023 07:50:22 +0900
Subject: [PATCH 2/3] src: Fix sync ibus_input_context_process_key_event()
The synchronous "ProcessKeyEvent" D-Bus method cannot receive
"CommitText" and "ForwardKeyEvent" D-Bus signals during calling the method.
To resolve the issue, now
ibus_input_context_set_post_process_key_event() and
ibus_input_context_post_process_key_event() are added newly.
ibus_input_context_post_process_key_event() retries "CommitText" and
"ForwardKeyEvent" D-Bus signals during calling the "ProcessKeyEvent" D-Bus
method and ibus-daemon does not handle those signals.
"Since: 1.5.00" is added in header files to available APIs before 1.5.29
is released. Will think later how to convert the version comments together
when the new version 1.5.29 is committed.
BUG=https://github.com/ibus/ibus/issues/2486
---
bus/inputcontext.c | 252 ++++++++++++++++++++++++++++++++----
client/gtk2/ibusimcontext.c | 225 ++++++++++++++++++++++----------
src/ibusinputcontext.c | 162 +++++++++++++++++++++--
src/ibusinputcontext.h | 36 +++++-
4 files changed, 567 insertions(+), 108 deletions(-)
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
index 8aded5d8..4d1fb041 100644
--- a/bus/inputcontext.c
+++ b/bus/inputcontext.c
@@ -31,6 +31,8 @@
#include "marshalers.h"
#include "types.h"
+#define MAX_SYNC_DATA 30
+
struct _SetEngineByDescData {
/* context related to the data */
BusInputContext *context;
@@ -46,6 +48,11 @@ struct _SetEngineByDescData {
};
typedef struct _SetEngineByDescData SetEngineByDescData;
+typedef struct _SyncForwardingData {
+ gchar key;
+ IBusText *text;
+} SyncForwardingData;
+
struct _BusInputContext {
IBusService parent;
@@ -99,6 +106,9 @@ struct _BusInputContext {
BusPanelProxy *emoji_extension;
gboolean is_extension_lookup_table;
+ GQueue *queue_during_process_key_event;
+ gboolean use_post_process_key_event;
+ gboolean processing_key_event;
};
struct _BusInputContextClass {
@@ -156,6 +166,15 @@ static void bus_input_context_service_method_call
const gchar *method_name,
GVariant *parameters,
GDBusMethodInvocation *invocation);
+static GVariant *
+ bus_input_context_service_get_property
+ (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error);
static gboolean bus_input_context_service_set_property
(IBusService *service,
GDBusConnection *connection,
@@ -215,8 +234,21 @@ static const gchar introspection_xml[] =
"<node>\n"
" <interface name='org.freedesktop.IBus.InputContext'>\n"
/* properties */
+ " <property name='PostProcessKeyEvent' type='(a(yv))' access='read'>\n"
+ " <annotation name='org.gtk.GDBus.Since'\n"
+ " value='1.5.29' />\n"
+ " <annotation name='org.gtk.GDBus.DocString'\n"
+ " value='Stability: Unstable' />\n"
+ " </property>\n"
" <property name='ContentType' type='(uu)' access='write' />\n"
" <property name='ClientCommitPreedit' type='(b)' access='write' />\n"
+ " <property name='EffectivePostProcessKeyEvent' type='(b)' \n"
+ " access='write'>\n"
+ " <annotation name='org.gtk.GDBus.Since'\n"
+ " value='1.5.29' />\n"
+ " <annotation name='org.gtk.GDBus.DocString'\n"
+ " value='Stability: Unstable' />\n"
+ " </property>\n"
/* methods */
" <method name='ProcessKeyEvent'>\n"
" <arg direction='in' type='u' name='keyval' />\n"
@@ -353,6 +385,8 @@ bus_input_context_class_init (BusInputContextClass *class)
/* override the parent class's implementation. */
IBUS_SERVICE_CLASS (class)->service_method_call =
bus_input_context_service_method_call;
+ IBUS_SERVICE_CLASS (class)->service_get_property =
+ bus_input_context_service_get_property;
IBUS_SERVICE_CLASS (class)->service_set_property =
bus_input_context_service_set_property;
/* register the xml so that bus_ibus_impl_service_method_call will be
@@ -782,6 +816,11 @@ bus_input_context_property_changed (BusInputContext *context,
}
+typedef struct _PanelProcessKeyEventData {
+ GDBusMethodInvocation *invocation;
+ BusInputContext *context;
+} PanelProcessKeyEventData;
+
/**
* _panel_process_key_event_cb:
*
@@ -789,14 +828,21 @@ bus_input_context_property_changed (BusInputContext *context,
* bus_panel_proxy_process_key_event() is finished.
*/
static void
-_panel_process_key_event_cb (GObject *source,
- GAsyncResult *res,
- GDBusMethodInvocation *invocation)
+_panel_process_key_event_cb (GObject *source,
+ GAsyncResult *res,
+ PanelProcessKeyEventData *data)
{
GError *error = NULL;
GVariant *value = g_dbus_proxy_call_finish ((GDBusProxy *)source,
res,
&error);
+ GDBusMethodInvocation *invocation;
+ BusInputContext *context;
+
+ g_assert (data);
+ invocation = data->invocation;
+ context = data->context;
+ g_slice_free (PanelProcessKeyEventData, data);
if (value != NULL) {
g_dbus_method_invocation_return_value (invocation, value);
g_variant_unref (value);
@@ -805,6 +851,7 @@ _panel_process_key_event_cb (GObject *source,
g_dbus_method_invocation_return_gerror (invocation, error);
g_error_free (error);
}
+ context->processing_key_event = FALSE;
}
typedef struct _ProcessKeyEventData ProcessKeyEventData;
@@ -841,21 +888,27 @@ _ic_process_key_event_reply_cb (GObject *source,
gboolean retval = FALSE;
g_variant_get (value, "(b)", &retval);
if (context->emoji_extension && !retval) {
+ PanelProcessKeyEventData *pdata =
+ g_slice_new (PanelProcessKeyEventData);
+ pdata->invocation = invocation;
+ pdata->context = context;
bus_panel_proxy_process_key_event (context->emoji_extension,
keyval,
keycode,
modifiers,
(GAsyncReadyCallback)
_panel_process_key_event_cb,
- invocation);
+ pdata);
} else {
g_dbus_method_invocation_return_value (invocation, value);
+ context->processing_key_event = FALSE;
}
g_variant_unref (value);
}
else {
g_dbus_method_invocation_return_gerror (invocation, error);
g_error_free (error);
+ context->processing_key_event = FALSE;
}
g_object_unref (context);
@@ -877,6 +930,8 @@ _ic_process_key_event (BusInputContext *context,
guint keycode = 0;
guint modifiers = 0;
+ if (context->use_post_process_key_event)
+ context->processing_key_event = TRUE;
g_variant_get (parameters, "(uuu)", &keyval, &keycode, &modifiers);
if (G_UNLIKELY (!context->has_focus)) {
/* workaround: set focus if context does not have focus */
@@ -1372,17 +1427,109 @@ bus_input_context_service_method_call (IBusService *service,
g_return_if_reached ();
}
-static void
+/**
+ * _ic_get_post_process_key_event:
+ *
+ * Implement the "PostProcessKeyEvent" get property of the
+ * org.freedesktop.IBus.InputContext interface because currently the Gio
+ * D-Bus method calls don't support multiple nested tuples likes
+ * G_VARIANT_TYPE ("((ba(yv)))")) in "ProcessKeyEvent" D-Bus method
+ * So these post events are separated from the return value "b" of
+ * the "ProcessKeyEvent" D-Bus method call.
+ */
+static GVariant *
+_ic_get_post_process_key_event (BusInputContext *context,
+ GDBusConnection *connection,
+ GError **error)
+{
+ const char *error_message = NULL;
+ GVariantBuilder array;
+ SyncForwardingData *data;
+
+ do {
+ if (!BUS_IS_INPUT_CONTEXT (context)) {
+ error_message = "BusInputContext is freed";
+ break;
+ }
+ if (context->processing_key_event) {
+ error_message = "Another ProcessKeyEvent is called.";
+ break;
+ }
+ g_variant_builder_init (&array, G_VARIANT_TYPE ("a(yv)"));
+ while ((data =
+ g_queue_pop_head (context->queue_during_process_key_event))) {
+ GVariant *variant = ibus_serializable_serialize_object (
+ IBUS_SERIALIZABLE (data->text));
+ g_variant_builder_add (&array, "(yv)", data->key, variant);
+ g_object_unref (data->text);
+ g_slice_free (SyncForwardingData, data);
+ }
+ } while (FALSE);
+ if (error_message) {
+ g_set_error (error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "%s", error_message);
+ return NULL;
+ }
+ return g_variant_builder_end (&array);
+}
+
+static GVariant *
+bus_input_context_service_get_property (IBusService *service,
+ GDBusConnection *connection,
+ const gchar *sender,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *property_name,
+ GError **error)
+{
+ int i;
+ static const struct {
+ const char *property_name;
+ GVariant * (* property_callback) (BusInputContext *,
+ GDBusConnection *,
+ GError **);
+ } properties [] = {
+ { "PostProcessKeyEvent", _ic_get_post_process_key_event },
+ };
+
+ if (error)
+ *error = NULL;
+ if (g_strcmp0 (interface_name, IBUS_INTERFACE_INPUT_CONTEXT) != 0) {
+ return IBUS_SERVICE_CLASS (bus_input_context_parent_class)->
+ service_get_property (
+ service, connection, sender, object_path,
+ interface_name, property_name,
+ error);
+ }
+ for (i = 0; i < G_N_ELEMENTS (properties); i++) {
+ if (g_strcmp0 (properties[i].property_name, property_name) == 0) {
+ return properties[i].property_callback ((BusInputContext *)service,
+ connection,
+ error);
+ }
+ }
+
+ g_set_error (error,
+ G_DBUS_ERROR,
+ G_DBUS_ERROR_FAILED,
+ "service_get_property received an unknown property: %s",
+ property_name ? property_name : "(null)");
+ g_return_val_if_reached (NULL);
+}
+
+static gboolean
_ic_set_content_type (BusInputContext *context,
- GVariant *value)
+ GVariant *value,
+ GError **error)
{
guint purpose = 0;
guint hints = 0;
+ gboolean retval = TRUE;
g_variant_get (value, "(uu)", &purpose, &hints);
if (purpose != context->purpose || hints != context->hints) {
- GError *error;
- gboolean retval;
context->purpose = purpose;
context->hints = hints;
@@ -1400,24 +1547,30 @@ _ic_set_content_type (BusInputContext *context,
context->hints);
}
- error = NULL;
retval = bus_input_context_property_changed (context,
"ContentType",
value,
- &error);
- if (!retval) {
- g_warning ("Failed to emit PropertiesChanged signal: %s",
- error->message);
- g_error_free (error);
- }
+ error);
}
+ return retval;
}
-static void
+static gboolean
_ic_set_client_commit_preedit (BusInputContext *context,
- GVariant *value)
+ GVariant *value,
+ GError **error)
{
g_variant_get (value, "(b)", &context->client_commit_preedit);
+ return TRUE;
+}
+
+static gboolean
+_ic_set_use_post_process_key_event (BusInputContext *context,
+ GVariant *value,
+ GError **error)
+{
+ g_variant_get (value, "(b)", &context->use_post_process_key_event);
+ return TRUE;
}
static gboolean
@@ -1430,6 +1583,18 @@ bus_input_context_service_set_property (IBusService *service,
GVariant *value,
GError **error)
{
+ int i;
+ static const struct {
+ const char *property_name;
+ gboolean (* property_callback) (BusInputContext *,
+ GVariant *,
+ GError **);
+ } properties [] = {
+ { "ContentType", _ic_set_content_type },
+ { "ClientCommitPreedit", _ic_set_client_commit_preedit },
+ { "EffectivePostProcessKeyEvent", _ic_set_use_post_process_key_event },
+ };
+
if (error)
*error = NULL;
if (g_strcmp0 (interface_name, IBUS_INTERFACE_INPUT_CONTEXT) != 0) {
@@ -1460,14 +1625,12 @@ bus_input_context_service_set_property (IBusService *service,
" ");
return FALSE;
}
-
- if (g_strcmp0 (property_name, "ContentType") == 0) {
- _ic_set_content_type (BUS_INPUT_CONTEXT (service), value);
- return TRUE;
- }
- if (g_strcmp0 (property_name, "ClientCommitPreedit") == 0) {
- _ic_set_client_commit_preedit (BUS_INPUT_CONTEXT (service), value);
- return TRUE;
+ for (i = 0; i < G_N_ELEMENTS (properties); i++) {
+ if (g_strcmp0 (properties[i].property_name, property_name) == 0) {
+ return properties[i].property_callback ((BusInputContext *) service,
+ value,
+ error);
+ }
}
g_set_error (error,
@@ -2204,7 +2367,23 @@ _engine_forward_key_event_cb (BusEngineProxy *engine,
g_assert (BUS_IS_INPUT_CONTEXT (context));
g_assert (context->engine == engine);
-
+ g_assert (context->queue_during_process_key_event);
+
+ if (context->processing_key_event && g_queue_get_length (
+ context->queue_during_process_key_event) <= MAX_SYNC_DATA) {
+ SyncForwardingData *data;
+ IBusText *text = ibus_text_new_from_printf ("%u,%u,%u",
+ keyval, keycode, state);
+ if (g_queue_get_length (context->queue_during_process_key_event)
+ == MAX_SYNC_DATA) {
+ g_warning ("Exceed max number of post process_key_event data");
+ }
+ data = g_slice_new (SyncForwardingData);
+ data->key = 'f';
+ data->text = text;
+ g_queue_push_tail (context->queue_during_process_key_event, data);
+ return;
+ }
bus_input_context_emit_signal (context,
"ForwardKeyEvent",
g_variant_new ("(uuu)",
@@ -2455,6 +2634,7 @@ bus_input_context_new (BusConnection *connection,
/* it is a fake input context, just need process hotkey */
context->fake = (strncmp (client, "fake", 4) == 0);
+ context->queue_during_process_key_event = g_queue_new ();
if (connection) {
g_object_ref_sink (connection);
@@ -2938,11 +3118,17 @@ bus_input_context_set_content_type (BusInputContext *context,
guint hints)
{
GVariant *value;
+ GError *error = NULL;
g_assert (BUS_IS_INPUT_CONTEXT (context));
value = g_variant_ref_sink (g_variant_new ("(uu)", purpose, hints));
- _ic_set_content_type (context, value);
+ _ic_set_content_type (context, value, &error);
+ if (error) {
+ g_warning ("Failed to emit PropertiesChanged signal: %s",
+ error->message);
+ g_error_free (error);
+ }
g_variant_unref (value);
}
@@ -2952,12 +3138,24 @@ bus_input_context_commit_text_use_extension (BusInputContext *context,
gboolean use_extension)
{
g_assert (BUS_IS_INPUT_CONTEXT (context));
+ g_assert (context->queue_during_process_key_event);
if (text == text_empty || text == NULL)
return;
if (use_extension && context->emoji_extension) {
bus_panel_proxy_commit_text_received (context->emoji_extension, text);
+ } else if (context->processing_key_event && g_queue_get_length (
+ context->queue_during_process_key_event) <= MAX_SYNC_DATA) {
+ SyncForwardingData *data;
+ if (g_queue_get_length (context->queue_during_process_key_event)
+ == MAX_SYNC_DATA) {
+ g_warning ("Exceed max number of sync process_key_event data");
+ }
+ data = g_slice_new (SyncForwardingData);
+ data->key = 'c';
+ data->text = g_object_ref (text);
+ g_queue_push_tail (context->queue_during_process_key_event, data);
} else {
GVariant *variant = ibus_serializable_serialize (
(IBusSerializable *)text);
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index ea8270bb..7ccc129d 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
@@ -111,7 +111,7 @@ static guint _signal_delete_surrounding_id = 0;
static guint _signal_retrieve_surrounding_id = 0;
#if GTK_CHECK_VERSION (3, 98, 4)
-static char _use_sync_mode = 2;
+static char _use_sync_mode = 1;
#else
static const gchar *_no_snooper_apps = NO_SNOOPER_APPS;
static gboolean _use_key_snooper = ENABLE_SNOOPER;
@@ -386,6 +386,7 @@ typedef struct {
gboolean retval;
} ProcessKeyEventReplyData;
+
static void
_process_key_event_done (GObject *object,
GAsyncResult *res,
@@ -435,6 +436,7 @@ _process_key_event_done (GObject *object,
#endif
}
+
static void
_process_key_event_reply_done (GObject *object,
GAsyncResult *res,
@@ -457,6 +459,7 @@ _process_key_event_reply_done (GObject *object,
g_source_remove (data->count_cb_id);
}
+
static gboolean
_process_key_event_count_cb (gpointer user_data)
{
@@ -472,6 +475,101 @@ _process_key_event_count_cb (gpointer user_data)
return G_SOURCE_CONTINUE;
}
+
+static gboolean
+_process_key_event_sync (IBusInputContext *context,
+ guint keyval,
+ guint keycode,
+ guint state)
+{
+ gboolean retval;
+
+ g_assert (IBUS_IS_INPUT_CONTEXT (context));
+ retval = ibus_input_context_process_key_event (context,
+ keyval,
+ keycode - 8,
+ state);
+ ibus_input_context_post_process_key_event (context);
+ return retval;
+}
+
+
+static gboolean
+_process_key_event_async (IBusInputContext *context,
+ guint keyval,
+ guint keycode,
+ guint state,
+ GdkEvent *event,
+ IBusIMContext *ibusimcontext)
+{
+ ProcessKeyEventData *data = g_slice_new0 (ProcessKeyEventData);
+
+ g_assert (event);
+ 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);
+#else
+ data->event = gdk_event_copy (event);
+#endif
+ data->ibusimcontext = ibusimcontext;
+ ibus_input_context_process_key_event_async (context,
+ keyval,
+ keycode - 8,
+ state,
+ -1,
+ NULL,
+ _process_key_event_done,
+ data);
+
+ return TRUE;
+}
+
+
+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)
@@ -505,70 +603,20 @@ _process_key_event (IBusInputContext *context,
switch (_use_sync_mode) {
case 1: {
- retval = ibus_input_context_process_key_event (context,
- keyval,
- keycode - 8,
- state);
+ retval = _process_key_event_sync (context, keyval, keycode, state);
break;
}
case 2: {
- GSource *source = g_timeout_source_new (1);
- ProcessKeyEventReplyData *data = NULL;
-
- if (source)
- data = g_slice_new0 (ProcessKeyEventReplyData);
- if (!data) {
- g_warning ("Cannot wait for the reply of the process key event.");
- retval = ibus_input_context_process_key_event (context,
- keyval,
- keycode - 8,
- state);
- if (source)
- g_source_destroy (source);
- break;
- }
- 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);
- if (source->ref_count > 0) {
- /* g_source_get_id() could causes a SEGV */
- g_info ("Broken GSource.ref_count and maybe a timing issue in %p.",
- source);
- }
- retval = data->retval;
- g_slice_free (ProcessKeyEventReplyData, data);
+ retval = _process_key_event_hybrid_async (context,
+ keyval, keycode, state);
break;
}
default: {
- ProcessKeyEventData *data = g_slice_new0 (ProcessKeyEventData);
-#if GTK_CHECK_VERSION (3, 98, 4)
- data->event = gdk_event_ref (event);
-#else
- data->event = gdk_event_copy ((GdkEvent *)event);
-#endif
- data->ibusimcontext = ibusimcontext;
- ibus_input_context_process_key_event_async (context,
- keyval,
- keycode - 8,
- state,
- -1,
- NULL,
- _process_key_event_done,
- data);
-
- retval = TRUE;
+ retval = _process_key_event_async (context,
+ keyval, keycode, state,
+ (GdkEvent *)event,
+ ibusimcontext);
+ break;
}
}
@@ -877,7 +925,55 @@ ibus_im_context_class_init (IBusIMContextClass *class)
g_assert (_signal_retrieve_surrounding_id != 0);
#if GTK_CHECK_VERSION (3, 98, 4)
- _use_sync_mode = _get_char_env ("IBUS_ENABLE_SYNC_MODE", 2);
+ /* IBus GtkIMModule, QtIMModlue, ibus-x11, ibus-wayland are called as
+ * IBus clients.
+ * Each GTK application, each QT application, Xorg server, Wayland
+ * comppsitor are called as IBus event owners here.
+ *
+ * The IBus client processes the key events between the IBus event owner
+ * and the IBus daemon and the procedure step is to:
+ *
+ * receive the key event from the IBus event owner and forward the
+ * event to the IBus daemon with the "ProcessKeyEvent" D-Bus method at
+ * first,
+ *
+ * receive the return value from the IBus daemon with the "ProessKeyEvent"
+ * D-Bus method and forward the value to the IBus event owner secondly and
+ * the return value includes if the key event is processed normally or not.
+ *
+ * The procedure behavior can be changed by the "IBUS_ENABLE_SYNC_MODE"
+ * environment variable with the synchronous procedure or asynchronous
+ * one and value is:
+ *
+ * 1: Synchronous process key event:
+ * Wait for the return of the IBus "ProcessKeyEvent" D-Bus method
+ * synchronously and forward the return value to the IBus event owner
+ * synchronously.
+ * 0: Asynchronous process key event:
+ * Return to the IBus event owner as the key event is processed normally
+ * at first as soon as the IBus client receives the event from the
+ * IBus event owner and also forward the event to the IBus daemon with
+ * the "ProcessKeyEvent" D-Bus method and wait for the return value of
+ * the D-Bus method *asynchronously*.
+ * If the return value indicates the key event is disposed by IBus,
+ * 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
+ * the IBus synchronous process has a problem that the IBus
+ * "ProcessKeyEvent" D-Bus method cannot send the commit-text and
+ * forwar-key-event D-Bus signals until the D-Bus method is finished.
+ *
+ * Relative issues: #1713, #2486
+ */
+ _use_sync_mode = _get_char_env ("IBUS_ENABLE_SYNC_MODE", 1);
#else
_use_key_snooper = !_get_boolean_env ("IBUS_DISABLE_SNOOPER",
!(ENABLE_SNOOPER));
@@ -1004,8 +1100,6 @@ ibus_im_context_init (GObject *obj)
#else
ibusimcontext->caps = IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_FOCUS;
#endif
- if (_use_sync_mode == 1)
- ibusimcontext->caps |= IBUS_CAP_SYNC_PROCESS_KEY_V2;
ibusimcontext->events_queue = g_queue_new ();
@@ -2265,6 +2359,8 @@ _create_input_context_done (IBusBus *bus,
else {
gboolean requested_surrounding_text = FALSE;
ibus_input_context_set_client_commit_preedit (context, TRUE);
+ if (_use_sync_mode == 1)
+ ibus_input_context_set_post_process_key_event (context, TRUE);
ibusimcontext->ibuscontext = context;
g_signal_connect (ibusimcontext->ibuscontext,
@@ -2489,9 +2585,8 @@ _create_fake_input_context_done (IBusBus *bus,
G_CALLBACK (_ibus_fake_context_destroy_cb),
NULL);
- guint32 caps = IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_FOCUS | IBUS_CAP_SURROUNDING_TEXT;
- if (_use_sync_mode == 1)
- caps |= IBUS_CAP_SYNC_PROCESS_KEY_V2;
+ guint32 caps = IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_FOCUS
+ | IBUS_CAP_SURROUNDING_TEXT;
ibus_input_context_set_capabilities (_fake_context, caps);
/* focus in/out the fake context */
diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c
index 28ae04ad..def23b25 100644
--- a/src/ibusinputcontext.c
+++ b/src/ibusinputcontext.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) 2018-2022 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (C) 2018-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2008-2019 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
@@ -1190,14 +1190,14 @@ ibus_input_context_set_content_type (IBusInputContext *context,
g_assert (IBUS_IS_INPUT_CONTEXT (context));
cached_content_type =
- g_dbus_proxy_get_cached_property ((GDBusProxy *) context,
+ g_dbus_proxy_get_cached_property ((GDBusProxy *)context,
"ContentType");
content_type = g_variant_new ("(uu)", purpose, hints);
g_variant_ref_sink (content_type);
- if (cached_content_type == NULL ||
+ if (!cached_content_type ||
!g_variant_equal (content_type, cached_content_type)) {
- g_dbus_proxy_call ((GDBusProxy *) context,
+ g_dbus_proxy_call ((GDBusProxy *)context,
"org.freedesktop.DBus.Properties.Set",
g_variant_new ("(ssv)",
IBUS_INTERFACE_INPUT_CONTEXT,
@@ -1209,9 +1209,13 @@ ibus_input_context_set_content_type (IBusInputContext *context,
NULL, /* callback */
NULL /* user_data */
);
+ /* Need to update the cache by manual since there is a timing issue. */
+ g_dbus_proxy_set_cached_property ((GDBusProxy *)context,
+ "ContentType",
+ content_type);
}
- if (cached_content_type != NULL)
+ if (cached_content_type)
g_variant_unref (cached_content_type);
g_variant_unref (content_type);
}
@@ -1324,19 +1328,20 @@ void
ibus_input_context_set_client_commit_preedit (IBusInputContext *context,
gboolean client_commit)
{
- GVariant *cached_content_type;
+ GVariant *cached_var_client_commit;
GVariant *var_client_commit;
g_assert (IBUS_IS_INPUT_CONTEXT (context));
- cached_content_type =
- g_dbus_proxy_get_cached_property ((GDBusProxy *) context,
+ cached_var_client_commit =
+ g_dbus_proxy_get_cached_property ((GDBusProxy *)context,
"ClientCommitPreedit");
var_client_commit = g_variant_new ("(b)", client_commit);
g_variant_ref_sink (var_client_commit);
- if (cached_content_type == NULL) {
- g_dbus_proxy_call ((GDBusProxy *) context,
+ if (!cached_var_client_commit ||
+ !g_variant_equal (var_client_commit, cached_var_client_commit)) {
+ g_dbus_proxy_call ((GDBusProxy *)context,
"org.freedesktop.DBus.Properties.Set",
g_variant_new ("(ssv)",
IBUS_INTERFACE_INPUT_CONTEXT,
@@ -1348,13 +1353,146 @@ ibus_input_context_set_client_commit_preedit (IBusInputContext *context,
NULL, /* callback */
NULL /* user_data */
);
+ /* Need to update the cache by manual since there is a timing issue. */
+ g_dbus_proxy_set_cached_property ((GDBusProxy *)context,
+ "ClientCommitPreedit",
+ var_client_commit);
}
- if (cached_content_type != NULL)
- g_variant_unref (cached_content_type);
+ if (cached_var_client_commit)
+ g_variant_unref (cached_var_client_commit);
g_variant_unref (var_client_commit);
}
+void
+ibus_input_context_set_post_process_key_event (IBusInputContext *context,
+ gboolean enable)
+{
+ GVariant *cached_var_post;
+ GVariant *var_post;
+
+ g_assert (IBUS_IS_INPUT_CONTEXT (context));
+
+ cached_var_post =
+ g_dbus_proxy_get_cached_property ((GDBusProxy *)context,
+ "EffectivePostProcessKeyEvent");
+ var_post = g_variant_new ("(b)", enable);
+ g_variant_ref_sink (var_post);
+ if (!cached_var_post ||
+ !g_variant_equal (var_post, cached_var_post)) {
+ g_dbus_proxy_call ((GDBusProxy *)context,
+ "org.freedesktop.DBus.Properties.Set",
+ g_variant_new ("(ssv)",
+ IBUS_INTERFACE_INPUT_CONTEXT,
+ "EffectivePostProcessKeyEvent",
+ var_post),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL, /* cancellable */
+ NULL, /* callback */
+ NULL /* user_data */
+ );
+ /* Need to update the cache by manual since there is a timing issue. */
+ g_dbus_proxy_set_cached_property ((GDBusProxy *)context,
+ "EffectivePostProcessKeyEvent",
+ var_post);
+ }
+
+ if (cached_var_post)
+ g_variant_unref (cached_var_post);
+ g_variant_unref (var_post);
+}
+
+void
+ibus_input_context_post_process_key_event (IBusInputContext *context)
+{
+ GVariant *cached_var_post;
+ gboolean enable = FALSE;
+ GVariant *result;
+ GError *error = NULL;
+ GVariant *variant = NULL;
+ GVariantIter iter;
+ gsize size;
+ char type = 0;
+ GVariant *vtext = NULL;
+
+ g_assert (IBUS_IS_INPUT_CONTEXT (context));
+
+ cached_var_post =
+ g_dbus_proxy_get_cached_property ((GDBusProxy *)context,
+ "EffectivePostProcessKeyEvent");
+ if (cached_var_post)
+ g_variant_get (cached_var_post, "(b)", &enable);
+ if (!enable) {
+ g_warning ("%s: ibus_input_context_set_post_process_key_event() "
+ "needs to be called before.",
+ G_STRFUNC);
+ if (cached_var_post)
+ g_variant_unref (cached_var_post);
+ return;
+ }
+ g_variant_unref (cached_var_post);
+ result = g_dbus_proxy_call_sync (
+ (GDBusProxy *)context,
+ "org.freedesktop.DBus.Properties.Get",
+ g_variant_new ("(ss)",
+ IBUS_INTERFACE_INPUT_CONTEXT,
+ "PostProcessKeyEvent"),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (error) {
+ g_warning ("%s: %s", G_STRFUNC, error->message);
+ g_error_free (error);
+ return;
+ }
+
+ g_variant_get (result, "(v)", &variant);
+ g_assert (variant);
+ g_variant_iter_init (&iter, variant);
+ size = g_variant_iter_n_children (&iter);
+ while (size >0 && g_variant_iter_loop (&iter, "(yv)", &type, &vtext)) {
+ IBusText *text =
+ (IBusText *)ibus_serializable_deserialize_object (vtext);
+ if (!IBUS_IS_TEXT (text)) {
+ g_warning ("%s: %s", G_STRFUNC, "text is not IBusText");
+ break;
+ }
+ switch (type) {
+ case 'c':
+ g_signal_emit (context, context_signals[COMMIT_TEXT], 0, text);
+ break;
+ case 'f': {
+ gchar **array = NULL;
+ guint keyval, keycode, state;
+ array = g_strsplit (text->text, ",", -1);
+ keyval = g_ascii_strtoull (array[0], NULL, 10);
+ keycode = g_ascii_strtoull (array[1], NULL, 10);
+ state = g_ascii_strtoull (array[2], NULL, 10);
+ g_strfreev (array);
+ g_signal_emit (context,
+ context_signals[FORWARD_KEY_EVENT],
+ 0,
+ keyval,
+ keycode,
+ state | IBUS_FORWARD_MASK);
+ break;
+ }
+ default:
+ g_warning ("%s: Type '%c' is not supported.", G_STRFUNC, type);
+ }
+ if (g_object_is_floating (text)) {
+ g_object_ref_sink (text);
+ g_object_unref (text);
+ }
+ g_clear_pointer (&vtext, g_variant_unref);
+ }
+
+ g_variant_unref (variant);
+ g_variant_unref (result);
+}
+
#define DEFINE_FUNC(name, Name) \
void \
ibus_input_context_##name (IBusInputContext *context) \
diff --git a/src/ibusinputcontext.h b/src/ibusinputcontext.h
index 09992148..ca604670 100644
--- a/src/ibusinputcontext.h
+++ b/src/ibusinputcontext.h
@@ -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) 2018 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (C) 2018-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2008-2018 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
@@ -298,7 +298,6 @@ gboolean ibus_input_context_process_key_event
guint32 keycode,
guint32 state);
-
/**
* ibus_input_context_set_cursor_location:
* @context: An IBusInputContext.
@@ -519,9 +518,38 @@ void ibus_input_context_set_content_type
*
* See also ibus_engine_update_preedit_text_with_mode().
*/
-void ibus_input_context_set_client_commit_preedit (
- IBusInputContext *context,
+void ibus_input_context_set_client_commit_preedit
+ (IBusInputContext *context,
gboolean client_commit);
+/**
+ * ibus_input_context_set_post_process_key_event:
+ * @context: An #IBusInputContext.
+ * @enable: Can use ibus_input_context_post_process_key_event() to retrieve
+ * commit-text and forwar-key-event signals during
+ * calling ibus_input_context_process_key_event() if it's %TRUE.
+ *
+ * Since: 1.5.00
+ * Stability: Unstable
+ */
+void ibus_input_context_set_post_process_key_event
+ (IBusInputContext *context,
+ gboolean enable);
+/**
+ * ibus_input_context_post_process_key_event:
+ * @context: An #IBusInputContext.
+ *
+ * Call this API after ibus_input_context_process_key_event() returns
+ * to retrieve commit-text and forwar-key-event signals during
+ * calling ibus_input_context_process_key_event().
+ *
+ * See also ibus_input_context_set_post_process_key_event().
+ *
+ * Since: 1.5.00
+ * Stability: Unstable
+ */
+void ibus_input_context_post_process_key_event
+ (IBusInputContext *context);
+
G_END_DECLS
#endif
--
2.41.0
From e495f8068380856c01fd22ceebb9398072fd65d8 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 12 Jul 2023 07:52:21 +0900
Subject: [PATCH 3/3] client/x11: Fix sync
ibus_input_context_process_key_event()
Fix the synchronous "ProcessKeyEvent" D-Bus method in ibus-x11 too.
Fixes: https://github.com/ibus/ibus/commit/3670faf
BUG=https://github.com/ibus/ibus/issues/2486
---
client/x11/main.c | 234 ++++++++++++++++++++++++++--------------------
1 file changed, 134 insertions(+), 100 deletions(-)
diff --git a/client/x11/main.c b/client/x11/main.c
index 83d95cb7..b7eb5961 100644
--- a/client/x11/main.c
+++ b/client/x11/main.c
@@ -126,7 +126,7 @@ static gint g_debug_level = 0;
static IBusBus *_bus = NULL;
-static char _use_sync_mode = 2;
+static char _use_sync_mode = 1;
static void
_xim_preedit_start (XIMS xims, const X11IC *x11ic)
@@ -380,9 +380,9 @@ xim_create_ic (XIMS xims, IMChangeICStruct *call_data)
if (x11ic->input_style & XIMPreeditCallbacks)
capabilities |= IBUS_CAP_PREEDIT_TEXT;
- if (_use_sync_mode == 1)
- capabilities |= IBUS_CAP_SYNC_PROCESS_KEY_V2;
ibus_input_context_set_capabilities (x11ic->context, capabilities);
+ if (_use_sync_mode == 1)
+ ibus_input_context_set_post_process_key_event (x11ic->context, TRUE);
g_hash_table_insert (_x11_ic_table,
GINT_TO_POINTER (x11ic->icid), (gpointer)x11ic);
@@ -427,6 +427,7 @@ xim_destroy_ic (XIMS xims, IMChangeICStruct *call_data)
return 1;
}
+
static int
xim_set_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
{
@@ -445,6 +446,7 @@ xim_set_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
return 1;
}
+
static int
xim_unset_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
{
@@ -463,6 +465,7 @@ xim_unset_ic_focus (XIMS xims, IMChangeFocusStruct *call_data)
}
+
static void
_xim_forward_key_event_done (X11IC *x11ic,
XEvent *event,
@@ -498,6 +501,7 @@ typedef struct {
XEvent event;
} ProcessKeyEventReplyData;
+
static void
_process_key_event_done (GObject *object,
GAsyncResult *res,
@@ -529,6 +533,7 @@ _process_key_event_done (GObject *object,
g_slice_free (ProcessKeyEventReplyData, data);
}
+
static void
_process_key_event_reply_done (GObject *object,
GAsyncResult *res,
@@ -566,6 +571,7 @@ _process_key_event_reply_done (GObject *object,
g_source_remove (data->count_cb_id);
}
+
static gboolean
_process_key_event_count_cb (gpointer user_data)
{
@@ -580,19 +586,131 @@ _process_key_event_count_cb (gpointer user_data)
return G_SOURCE_CONTINUE;
}
+
+static int
+_process_key_event_sync (X11IC *x11ic,
+ IMForwardEventStruct *call_data,
+ GdkEventKey *event)
+{
+ gboolean retval;
+
+ g_assert (x11ic);
+ g_assert (call_data);
+ g_assert (event);
+ retval = ibus_input_context_process_key_event (
+ x11ic->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);
+ return 1;
+}
+
+
+static int
+_process_key_event_async (X11IC *x11ic,
+ IMForwardEventStruct *call_data,
+ GdkEventKey *event)
+{
+ ProcessKeyEventReplyData *data;
+
+ g_assert (x11ic);
+ g_assert (call_data);
+ g_assert (event);
+ if (!(data = g_slice_new0 (ProcessKeyEventReplyData))) {
+ 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,
+ event->keyval,
+ event->hardware_keycode - 8,
+ event->state,
+ -1,
+ NULL,
+ _process_key_event_done,
+ data);
+ return 1;
+}
+
+
+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)
{
X11IC *x11ic;
XKeyEvent *xevent;
GdkEventKey event;
- gboolean retval;
LOG (1, "XIM_FORWARD_EVENT ic=%d connect_id=%d",
- call_data->icid, call_data->connect_id);
+ 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);
xevent = (XKeyEvent*) &(call_data->event);
@@ -608,99 +726,15 @@ xim_forward_event (XIMS xims, IMForwardEventStruct *call_data)
}
switch (_use_sync_mode) {
- case 1: {
- retval = ibus_input_context_process_key_event (
- x11ic->context,
- event.keyval,
- event.hardware_keycode - 8,
- event.state);
- _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;
-
- if (source)
- data = g_slice_new0 (ProcessKeyEventReplyData);
- if (!data) {
- g_warning ("Cannot wait for the reply of the process key event.");
- retval = ibus_input_context_process_key_event (
- x11ic->context,
- event.keyval,
- event.hardware_keycode - 8,
- event.state);
- if (source)
- g_source_destroy (source);
- } else {
- 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,
- 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);
- if (source->ref_count > 0) {
- /* g_source_get_id() could causes a SEGV */
- g_info ("Broken GSource.ref_count and maybe a timing "
- "issue in %p.", source);
- }
- 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, retval);
- retval = 1;
- break;
- }
- default: {
- ProcessKeyEventReplyData *data;
-
- 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,
- event.keyval,
- event.hardware_keycode - 8,
- event.state,
- -1,
- NULL,
- _process_key_event_done,
- data);
- retval = 1;
- }
+ 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);
}
- return retval;
+ g_assert_not_reached ();
+ return 0;
}
@@ -1186,7 +1220,7 @@ _init_ibus (void)
G_CALLBACK (_bus_disconnected_cb), NULL);
/* https://github.com/ibus/ibus/issues/1713 */
- _use_sync_mode = _get_char_env ("IBUS_ENABLE_SYNC_MODE", 2);
+ _use_sync_mode = _get_char_env ("IBUS_ENABLE_SYNC_MODE", 1);
}
static void
--
2.41.0