summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2023-01-25 15:10:50 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2023-01-25 15:10:50 +0900
commit2a235c8c33f1de56df4873fe3662d5beb1355715 (patch)
tree7453135b5db9e15980163765961b0a18b0782d3a
parentbd24be4582f67e278fc85e843d39b81629bf7d9b (diff)
downloadibus-2a235c8c33f1de56df4873fe3662d5beb1355715.tar.gz
Refactor surrounding text warning & free focus-id tables
- Free engine_focus_id_table in bus_ibus_impl_destroy - It would be better to check the function return value at the first calling than the static variable for the surrounding text warnings - Add API comments Fixes: https://github.com/ibus/ibus/commit/39b6907 Fixes: https://github.com/ibus/ibus/commit/7bbcce6 Fixes: https://github.com/ibus/ibus/commit/19ca106 Fixes: https://github.com/ibus/ibus/commit/92771d0
-rw-r--r--bus/ibusimpl.c155
-rw-r--r--client/gtk2/ibusimcontext.c76
-rw-r--r--src/ibuscomposetable.h13
-rw-r--r--src/ibusengine.c99
4 files changed, 196 insertions, 147 deletions
diff --git a/bus/ibusimpl.c b/bus/ibusimpl.c
index 6df86c3f..c2ae88df 100644
--- a/bus/ibusimpl.c
+++ b/bus/ibusimpl.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) 2011-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
+ * Copyright (C) 2011-2023 Takao Fujiwara <takao.fujiwara1@gmail.com>
* Copyright (C) 2008-2021 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
@@ -287,8 +287,10 @@ bus_ibus_impl_class_init (BusIBusImplClass *class)
/**
* _panel_destroy_cb:
*
- * A callback function which is called when (1) the connection to the panel process is terminated,
- * or (2) ibus_proxy_destroy (ibus->panel); is called. See src/ibusproxy.c for details.
+ * A callback function which is called when (1) the connection to the panel
+ * process is terminated,
+ * or (2) ibus_proxy_destroy (ibus->panel); is called. See src/ibusproxy.c for
+ * details.
*/
static void
_panel_destroy_cb (BusPanelProxy *panel,
@@ -360,9 +362,8 @@ bus_ibus_impl_set_panel_extension_keys (BusIBusImpl *ibus,
if (ibus->extension_register_keys)
g_variant_unref (ibus->extension_register_keys);
ibus->extension_register_keys = g_variant_ref_sink (parameters);
- if (ibus->focused_context != NULL) {
- engine = bus_input_context_get_engine (ibus->focused_context);
- }
+ if (ibus->focused_context)
+ engine = bus_input_context_get_engine (ibus->focused_context);
if (!engine)
return;
bus_engine_proxy_panel_extension_register_keys (engine, parameters);
@@ -429,8 +430,7 @@ _panel_update_auxiliary_text_received_cb (BusPanelProxy *panel,
if (!ibus->panel)
return;
- bus_panel_proxy_update_auxiliary_text (
- ibus->panel, text, visible);
+ bus_panel_proxy_update_auxiliary_text (ibus->panel, text, visible);
}
static void
@@ -443,8 +443,10 @@ _registry_changed_cb (IBusRegistry *registry,
/*
* _dbus_name_owner_changed_cb:
*
- * A callback function to be called when the name-owner-changed signal is sent to the dbus object.
- * This usually means a client (e.g. a panel/config/engine process or an application) is connected/disconnected to/from the bus.
+ * A callback function to be called when the name-owner-changed signal is sent
+ * to the dbus object.
+ * This usually means a client (e.g. a panel/config/engine process or an
+ * application) is connected/disconnected to/from the bus.
*/
static void
_dbus_name_owner_changed_cb (BusDBusImpl *dbus,
@@ -561,7 +563,8 @@ _dbus_name_owner_changed_cb (BusDBusImpl *dbus,
/**
* bus_ibus_impl_init:
*
- * The constructor of BusIBusImpl. Initialize all member variables of a BusIBusImpl object.
+ * The constructor of #BusIBusImpl. Initialize all member variables of a
+ * #BusIBusImpl object.
*/
static void
bus_ibus_impl_init (BusIBusImpl *ibus)
@@ -645,7 +648,8 @@ bus_ibus_impl_destroy (BusIBusImpl *ibus)
if (flag == FALSE) {
gpointer old;
old = signal (SIGTERM, SIG_IGN);
- /* send TERM signal to the whole process group (i.e. engines, panel, and config daemon.) */
+ /* send TERM signal to the whole process group (i.e.
+ * engines, panel, and config daemon.) */
kill (-getpid (), SIGTERM);
signal (SIGTERM, old);
flag = TRUE;
@@ -661,35 +665,29 @@ bus_ibus_impl_destroy (BusIBusImpl *ibus)
g_list_free_full (ibus->register_engine_list, g_object_unref);
ibus->register_engine_list = NULL;
- if (ibus->factory_dict != NULL) {
- g_hash_table_destroy (ibus->factory_dict);
- ibus->factory_dict = NULL;
- }
+ if (ibus->factory_dict)
+ g_clear_pointer (&ibus->factory_dict, g_hash_table_destroy);
- if (ibus->keymap != NULL) {
- g_object_unref (ibus->keymap);
- ibus->keymap = NULL;
- }
+ if (ibus->keymap)
+ g_clear_pointer (&ibus->keymap, g_object_unref);
- g_free (ibus->global_engine_name);
- ibus->global_engine_name = NULL;
+ g_clear_pointer (&ibus->global_engine_name, g_free);
+ g_clear_pointer (&ibus->global_previous_engine_name, g_free);
- g_free (ibus->global_previous_engine_name);
- ibus->global_previous_engine_name = NULL;
-
- if (ibus->fake_context) {
- g_object_unref (ibus->fake_context);
- ibus->fake_context = NULL;
- }
+ if (ibus->fake_context)
+ g_clear_pointer (&ibus->fake_context, g_object_unref);
bus_ibus_impl_registry_destroy (ibus);
+ if (ibus->engine_focus_id_table)
+ g_clear_pointer (&ibus->engine_focus_id_table, g_hash_table_destroy);
if (ibus->engine_active_surrounding_text_table != NULL) {
- g_hash_table_destroy (ibus->engine_active_surrounding_text_table);
- ibus->engine_active_surrounding_text_table = NULL;
+ g_clear_pointer (&ibus->engine_active_surrounding_text_table,
+ g_hash_table_destroy);
}
- IBUS_OBJECT_CLASS (bus_ibus_impl_parent_class)->destroy (IBUS_OBJECT (ibus));
+ IBUS_OBJECT_CLASS (bus_ibus_impl_parent_class)->destroy (
+ IBUS_OBJECT (ibus));
}
/**
@@ -749,7 +747,8 @@ _find_engine_desc_by_name (BusIBusImpl *ibus,
/**
* _context_request_engine_cb:
*
- * A callback function to be called when the "request-engine" signal is sent to the context.
+ * A callback function to be called when the "request-engine" signal is sent to
+ * the context.
*/
static IBusEngineDesc *
_context_request_engine_cb (BusInputContext *context,
@@ -788,12 +787,13 @@ bus_ibus_impl_set_context_engine_from_desc (BusIBusImpl *ibus,
BusInputContext *context,
IBusEngineDesc *desc)
{
- bus_input_context_set_engine_by_desc (context,
- desc,
- g_gdbus_timeout, /* timeout in msec. */
- NULL, /* we do not cancel the call. */
- NULL, /* use the default callback function. */
- NULL);
+ bus_input_context_set_engine_by_desc (
+ context,
+ desc,
+ g_gdbus_timeout, /* timeout in msec. */
+ NULL, /* we do not cancel the call. */
+ NULL, /* use the default callback function. */
+ NULL);
}
static void
@@ -827,7 +827,8 @@ bus_ibus_impl_set_focused_context (BusIBusImpl *ibus,
g_assert (BUS_IS_IBUS_IMPL (ibus));
g_assert (context == NULL || BUS_IS_INPUT_CONTEXT (context));
- g_assert (context == NULL || bus_input_context_get_capabilities (context) & IBUS_CAP_FOCUS);
+ g_assert (context == NULL ||
+ bus_input_context_get_capabilities (context) & IBUS_CAP_FOCUS);
/* Do noting if it is focused context. */
if (ibus->focused_context == context) {
@@ -938,8 +939,8 @@ bus_ibus_impl_set_global_engine_by_name (BusIBusImpl *ibus,
if (!ibus->use_global_engine)
return;
- BusInputContext *context =
- ibus->focused_context != NULL ? ibus->focused_context : ibus->fake_context;
+ BusInputContext *context = ibus->focused_context != NULL
+ ? ibus->focused_context : ibus->fake_context;
if (context == NULL) {
return;
@@ -1008,7 +1009,8 @@ bus_ibus_impl_check_global_engine (BusIBusImpl *ibus)
/**
* _context_engine_changed_cb:
*
- * A callback function to be called when the "engine-changed" signal is sent to the context.
+ * A callback function to be called when the "engine-changed" signal is sent to
+ * the context.
* Update global engine as well if necessary.
*/
static void
@@ -1023,7 +1025,8 @@ _context_engine_changed_cb (BusInputContext *context,
BusEngineProxy *engine = bus_input_context_get_engine (context);
if (engine != NULL) {
/* only set global engine if engine is not NULL */
- const gchar *name = ibus_engine_desc_get_name (bus_engine_proxy_get_desc (engine));
+ const gchar *name = ibus_engine_desc_get_name (
+ bus_engine_proxy_get_desc (engine));
if (g_strcmp0 (name, ibus->global_engine_name) == 0)
return;
g_free (ibus->global_previous_engine_name);
@@ -1037,8 +1040,10 @@ _context_engine_changed_cb (BusInputContext *context,
/**
* _context_focus_in_cb:
*
- * A callback function to be called when the "focus-in" signal is sent to the context.
- * If necessary, enables the global engine on the context and update ibus->focused_context.
+ * A callback function to be called when the "focus-in" signal is sent to the
+ * context.
+ * If necessary, enables the global engine on the context and update
+ * ibus->focused_context.
*/
static void
_context_focus_in_cb (BusInputContext *context,
@@ -1059,7 +1064,8 @@ _context_focus_in_cb (BusInputContext *context,
/**
* _context_focus_out_cb:
*
- * A callback function to be called when the "focus-out" signal is sent to the context.
+ * A callback function to be called when the "focus-out" signal is sent to the
+ * context.
*/
static void
_context_focus_out_cb (BusInputContext *context,
@@ -1069,7 +1075,8 @@ _context_focus_out_cb (BusInputContext *context,
g_assert (BUS_IS_INPUT_CONTEXT (context));
/* Do noting if context does not support focus.
- * Actually, the context should emit focus signals, if it does not support focus */
+ * Actually, the context should emit focus signals, if it does not support
+ * focus */
if ((bus_input_context_get_capabilities (context) & IBUS_CAP_FOCUS) == 0) {
return;
}
@@ -1127,7 +1134,8 @@ bus_ibus_impl_create_input_context (BusIBusImpl *ibus,
g_object_ref_sink (context);
ibus->contexts = g_list_append (ibus->contexts, context);
- /* Installs glib signal handlers so that the ibus object could be notified when e.g. an IBus.InputContext D-Bus method is called. */
+ /* Installs glib signal handlers so that the ibus object could be notified
+ * when e.g. an IBus.InputContext D-Bus method is called. */
static const struct {
gchar *name;
GCallback callback;
@@ -1149,7 +1157,8 @@ bus_ibus_impl_create_input_context (BusIBusImpl *ibus,
bus_input_context_enable (context);
- /* register the context object so that the object could handle IBus.InputContext method calls. */
+ /* register the context object so that the object could handle
+ * IBus.InputContext method calls. */
bus_dbus_impl_register_object (BUS_DEFAULT_DBUS,
(IBusService *) context);
g_object_ref (context);
@@ -1159,14 +1168,15 @@ bus_ibus_impl_create_input_context (BusIBusImpl *ibus,
/**
* _ibus_create_input_context:
*
- * Implement the "CreateInputContext" method call of the org.freedesktop.IBus interface.
+ * Implement the "CreateInputContext" method call of the org.freedesktop.IBus
+ * interface.
*/
static void
_ibus_create_input_context (BusIBusImpl *ibus,
GVariant *parameters,
GDBusMethodInvocation *invocation)
{
- const gchar *client_name = NULL; // e.g. "gtk-im"
+ const gchar *client_name = NULL; /* e.g. "gtk-im" */
g_variant_get (parameters, "(&s)", &client_name);
BusConnection *connection =
@@ -1176,9 +1186,11 @@ _ibus_create_input_context (BusIBusImpl *ibus,
connection,
client_name);
if (context) {
- const gchar *path = ibus_service_get_object_path ((IBusService *) context);
+ const gchar *path =
+ ibus_service_get_object_path ((IBusService *) context);
/* the format-string 'o' is for a D-Bus object path. */
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("(o)", path));
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(o)", path));
g_object_unref (context);
}
else {
@@ -1259,14 +1271,16 @@ _component_destroy_cb (BusComponent *component,
g_assert (BUS_IS_IBUS_IMPL (ibus));
g_assert (BUS_IS_COMPONENT (component));
- ibus->registered_components = g_list_remove (ibus->registered_components, component);
+ ibus->registered_components = g_list_remove (ibus->registered_components,
+ component);
/* remove engines from engine_list */
GList *engines = bus_component_get_engines (component);
GList *p;
for (p = engines; p != NULL; p = p->next) {
if (g_list_find (ibus->register_engine_list, p->data)) {
- ibus->register_engine_list = g_list_remove (ibus->register_engine_list, p->data);
+ ibus->register_engine_list =
+ g_list_remove (ibus->register_engine_list, p->data);
g_object_unref (p->data);
}
}
@@ -1389,7 +1403,8 @@ _ibus_list_engines_depre (BusIBusImpl *ibus,
/**
* _ibus_get_engines_by_names:
*
- * Implement the "GetEnginesByNames" method call of the org.freedesktop.IBus interface.
+ * Implement the "GetEnginesByNames" method call of the org.freedesktop.IBus
+ * interface.
*/
static void
_ibus_get_engines_by_names (BusIBusImpl *ibus,
@@ -1414,7 +1429,8 @@ _ibus_get_engines_by_names (BusIBusImpl *ibus,
"v",
ibus_serializable_serialize ((IBusSerializable *)desc));
}
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("(av)", &builder));
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(av)", &builder));
}
/**
@@ -1609,7 +1625,7 @@ _ibus_get_global_engine (BusIBusImpl *ibus,
GVariant *variant = ibus_serializable_serialize (
(IBusSerializable *) desc);
- // Set type "v" for introspection_xml.
+ /* Set type "v" for introspection_xml. */
retval = g_variant_new_variant (variant);
if (!retval) {
g_set_error (error,
@@ -1752,12 +1768,13 @@ _ibus_set_global_engine (BusIBusImpl *ibus,
SetGlobalEngineData *data = g_slice_new0 (SetGlobalEngineData);
data->ibus = g_object_ref (ibus);
data->invocation = invocation;
- bus_input_context_set_engine_by_desc (context,
- desc,
- g_gdbus_timeout, /* timeout in msec. */
- NULL, /* we do not cancel the call. */
- (GAsyncReadyCallback) _ibus_set_global_engine_ready_cb,
- data);
+ bus_input_context_set_engine_by_desc (
+ context,
+ desc,
+ g_gdbus_timeout, /* timeout in msec. */
+ NULL, /* we do not cancel the call. */
+ (GAsyncReadyCallback) _ibus_set_global_engine_ready_cb,
+ data);
}
/**
@@ -2109,19 +2126,17 @@ BusFactoryProxy *
bus_ibus_impl_lookup_factory (BusIBusImpl *ibus,
const gchar *path)
{
- g_assert (BUS_IS_IBUS_IMPL (ibus));
-
BusFactoryProxy *factory;
- factory = (BusFactoryProxy *) g_hash_table_lookup (ibus->factory_dict, path);
-
+ g_assert (BUS_IS_IBUS_IMPL (ibus));
+ factory = (BusFactoryProxy *) g_hash_table_lookup (ibus->factory_dict,
+ path);
return factory;
}
IBusKeymap *
bus_ibus_impl_get_keymap (BusIBusImpl *ibus)
{
-
g_assert (BUS_IS_IBUS_IMPL (ibus));
return ibus->keymap;
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
index 1f3723e6..ea8270bb 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.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) 2015-2022 Takao Fujiwara <takao.fujiwara1@gmail.com>
- * Copyright (C) 2008-2022 Red Hat, Inc.
+ * Copyright (C) 2015-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
@@ -70,7 +70,6 @@ struct _IBusIMContext {
#endif
IBusInputContext *ibuscontext;
- IBusInputContext *ibuscontext_needs_surrounding;
/* preedit status */
gchar *preedit_string;
@@ -214,7 +213,7 @@ static gboolean _slave_delete_surrounding_cb
gint offset_from_cursor,
guint nchars,
IBusIMContext *context);
-static void _request_surrounding_text (IBusIMContext *context);
+static gboolean _request_surrounding_text (IBusIMContext *context);
static void _create_fake_input_context (void);
static gboolean _set_content_type (IBusIMContext *context);
@@ -592,34 +591,19 @@ _process_key_event (IBusInputContext *context,
* context->caps has IBUS_CAP_SURROUNDING_TEXT and the current IBus
* engine needs surrounding-text.
*/
-static void
+static gboolean
_request_surrounding_text (IBusIMContext *context)
{
- static gboolean warned = FALSE;
+ gboolean return_value = TRUE;
if (context &&
(context->caps & IBUS_CAP_SURROUNDING_TEXT) != 0 &&
context->ibuscontext != NULL &&
ibus_input_context_needs_surrounding_text (context->ibuscontext)) {
- gboolean return_value;
IDEBUG ("requesting surrounding text");
g_signal_emit (context, _signal_retrieve_surrounding_id, 0,
&return_value);
- if (!return_value) {
- /* Engines can disable the surrounding text feature with
- * the updated capabilities.
- */
- if (context->caps & IBUS_CAP_SURROUNDING_TEXT) {
- context->caps &= ~IBUS_CAP_SURROUNDING_TEXT;
- ibus_input_context_set_capabilities (context->ibuscontext,
- context->caps);
- }
- if (!warned) {
- g_warning ("%s has no capability of surrounding-text feature",
- g_get_prgname ());
- warned = TRUE;
- }
- }
}
+ return return_value;
}
static gboolean
@@ -1013,7 +997,6 @@ ibus_im_context_init (GObject *obj)
ibusimcontext->cursor_area.height = 0;
ibusimcontext->ibuscontext = NULL;
- ibusimcontext->ibuscontext_needs_surrounding = NULL;
ibusimcontext->has_focus = FALSE;
ibusimcontext->time = GDK_CURRENT_TIME;
#ifdef ENABLE_SURROUNDING
@@ -2213,15 +2196,32 @@ _ibus_context_hide_preedit_text_cb (IBusInputContext *ibuscontext,
}
static void
+_ibus_warn_no_support_surrounding_text (IBusIMContext *context)
+{
+ /* Engines can disable the surrounding text feature with
+ * the updated capabilities.
+ */
+ if (context->caps & IBUS_CAP_SURROUNDING_TEXT) {
+ context->caps &= ~IBUS_CAP_SURROUNDING_TEXT;
+ ibus_input_context_set_capabilities (context->ibuscontext,
+ context->caps);
+ }
+ g_warning ("%s has no capability of surrounding-text feature",
+ g_get_prgname ());
+}
+
+static void
_ibus_context_require_surrounding_text_cb (IBusInputContext *ibuscontext,
IBusIMContext *ibusimcontext)
{
IDEBUG ("%s", __FUNCTION__);
g_assert (ibusimcontext->ibuscontext == ibuscontext);
- if (ibusimcontext->ibuscontext_needs_surrounding == ibuscontext) {
- _request_surrounding_text (ibusimcontext);
- ibusimcontext->ibuscontext_needs_surrounding = NULL;
- }
+ if (!_request_surrounding_text (ibusimcontext))
+ _ibus_warn_no_support_surrounding_text (ibusimcontext);
+ g_signal_handlers_disconnect_by_func (
+ ibusimcontext->ibuscontext,
+ G_CALLBACK (_ibus_context_require_surrounding_text_cb),
+ ibusimcontext);
}
static void
@@ -2263,6 +2263,7 @@ _create_input_context_done (IBusBus *bus,
g_error_free (error);
}
else {
+ gboolean requested_surrounding_text = FALSE;
ibus_input_context_set_client_commit_preedit (context, TRUE);
ibusimcontext->ibuscontext = context;
@@ -2290,16 +2291,12 @@ _create_input_context_done (IBusBus *bus,
"hide-preedit-text",
G_CALLBACK (_ibus_context_hide_preedit_text_cb),
ibusimcontext);
- g_signal_connect (
- ibusimcontext->ibuscontext,
- "require-surrounding-text",
- G_CALLBACK (_ibus_context_require_surrounding_text_cb),
- ibusimcontext);
g_signal_connect (ibusimcontext->ibuscontext, "destroy",
G_CALLBACK (_ibus_context_destroy_cb),
ibusimcontext);
- ibus_input_context_set_capabilities (ibusimcontext->ibuscontext, ibusimcontext->caps);
+ ibus_input_context_set_capabilities (ibusimcontext->ibuscontext,
+ ibusimcontext->caps);
if (ibusimcontext->has_focus) {
/* The time order is _create_input_context() ->
@@ -2313,11 +2310,18 @@ _create_input_context_done (IBusBus *bus,
_set_cursor_location_internal (ibusimcontext);
if (ibus_input_context_needs_surrounding_text (
ibusimcontext->ibuscontext)) {
- _request_surrounding_text (ibusimcontext);
- } else {
- ibusimcontext->ibuscontext_needs_surrounding = ibusimcontext->ibuscontext;
+ if (!_request_surrounding_text (ibusimcontext))
+ _ibus_warn_no_support_surrounding_text (ibusimcontext);
+ requested_surrounding_text = TRUE;
}
}
+ if (!requested_surrounding_text) {
+ g_signal_connect (
+ ibusimcontext->ibuscontext,
+ "require-surrounding-text",
+ G_CALLBACK (_ibus_context_require_surrounding_text_cb),
+ ibusimcontext);
+ }
if (!g_queue_is_empty (ibusimcontext->events_queue)) {
#if GTK_CHECK_VERSION (3, 98, 4)
diff --git a/src/ibuscomposetable.h b/src/ibuscomposetable.h
index be1463ae..32e337f7 100644
--- a/src/ibuscomposetable.h
+++ b/src/ibuscomposetable.h
@@ -46,6 +46,8 @@ struct _IBusComposeTable
struct _IBusComposeTableEx
{
IBusComposeTablePrivate *priv;
+ /* @data is const value to accept mmap data and the releasable allocation
+ * is assigned to @rawdata. */
const guint16 *data;
gint max_seq_len;
gint n_seqs;
@@ -54,6 +56,17 @@ struct _IBusComposeTableEx
};
+/**
+ * ibus_compose_table_new_with_file:
+ * @compose_file: The path of the compose file
+ * @compose_tables: (nullable): The list of other @IBusComposeTableEx
+ * and the generating @IBusComposeTableEx excludes the compose keys
+ * which are included in the other @IBusComposeTableEx.
+ *
+ * Generate @IBusComposeTableEx from the compose file.
+ *
+ * Returns: @IBusComposeTableEx
+ */
IBusComposeTableEx *
ibus_compose_table_new_with_file (const gchar *compose_file,
GSList
diff --git a/src/ibusengine.c b/src/ibusengine.c
index cc12ac5a..8aa27b66 100644
--- a/src/ibusengine.c
+++ b/src/ibusengine.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-2021 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
@@ -371,7 +371,7 @@ ibus_engine_class_init (IBusEngineClass *class)
/* install properties */
/**
- * IBusEngine:name:
+ * IBusEngine:engine-name:
*
* Name of this IBusEngine.
*/
@@ -385,6 +385,16 @@ ibus_engine_class_init (IBusEngineClass *class)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS));
+ /**
+ * IBusEngine:has-focus-id:
+ *
+ * Use #IBusEngine::focus_in_id()/focus_out_id() class method insteads of
+ * focus_in()/focus_out() class methods when this property is set to %TRUE.
+ * Otherwise, use #IBusEngine::focus_in()/focus_out class methods.
+ * This property can only be set at construct time.
+ *
+ * See also: IBusEngine::focus-in-id
+ */
g_object_class_install_property (gobject_class,
PROP_HAS_FOCUS_ID,
g_param_spec_boolean ("has-focus-id",
@@ -577,7 +587,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* in extended class to receive this signal.
*
* See also: ibus_input_context_reset().
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[RESET] =
g_signal_new (I_("reset"),
@@ -598,7 +609,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* in extended class to receive this signal.
*
* See also: ibus_bus_set_global_engine().
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[ENABLE] =
g_signal_new (I_("enable"),
@@ -619,7 +631,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* in extended class to receive this signal.
*
* See also: ibus_bus_set_global_engine().
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[DISABLE] =
g_signal_new (I_("disable"),
@@ -644,7 +657,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* in extended class to receive this signal.
*
* See also: ibus_input_context_set_cursor_location().
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[SET_CURSOR_LOCATION] =
g_signal_new (I_("set-cursor-location"),
@@ -670,7 +684,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* in extended class to receive this signal.
*
* See also: ibus_input_context_set_capabilities().
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[SET_CAPABILITIES] =
g_signal_new (I_("set-capabilities"),
@@ -691,7 +706,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::page_up
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[PAGE_UP] =
g_signal_new (I_("page-up"),
@@ -711,7 +727,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::page_down
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[PAGE_DOWN] =
g_signal_new (I_("page-down"),
@@ -731,7 +748,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::cursor_up
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[CURSOR_UP] =
g_signal_new (I_("cursor-up"),
@@ -751,7 +769,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::cursor_down
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[CURSOR_DOWN] =
g_signal_new (I_("cursor-down"),
@@ -774,7 +793,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::candidate_clicked
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[CANDIDATE_CLICKED] =
g_signal_new (I_("candidate-clicked"),
@@ -799,7 +819,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::property_activate
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[PROPERTY_ACTIVATE] =
g_signal_new (I_("property-activate"),
@@ -822,7 +843,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::property_side
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[PROPERTY_SHOW] =
g_signal_new (I_("property-show"),
@@ -844,7 +866,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::property_hide
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[PROPERTY_HIDE] =
g_signal_new (I_("property-hide"),
@@ -860,14 +883,16 @@ ibus_engine_class_init (IBusEngineClass *class)
/**
* IBusEngine::process-hand-writing-event:
* @engine: An IBusEngine.
- * @coordinates: An array of double (0.0 to 1.0) which represents a stroke (i.e. [x1, y1, x2, y2, x3, y3, ...]).
+ * @coordinates: An array of double (0.0 to 1.0) which represents a stroke
+ * (i.e. [x1, y1, x2, y2, x3, y3, ...]).
* @coordinates_len: The number of elements in the array.
*
* Emitted when a hand writing operation is cancelled.
* Implement the member function IBusEngineClass::cancel_hand_writing
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[PROCESS_HAND_WRITING_EVENT] =
g_signal_new (I_("process-hand-writing-event"),
@@ -890,7 +915,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* Implement the member function IBusEngineClass::cancel_hand_writing
* in extended class to receive this signal.
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[CANCEL_HAND_WRITING] =
g_signal_new (I_("cancel-hand-writing"),
@@ -916,7 +942,8 @@ ibus_engine_class_init (IBusEngineClass *class)
* If anchor_pos equals to cursor_pos, it means "there are no selection"
* or "does not support selection retrival".
*
- * <note><para>Argument @user_data is ignored in this function.</para></note>
+ * <note><para>Argument @user_data is ignored in this function.</para>
+ * </note>
*/
engine_signals[SET_SURROUNDING_TEXT] =
g_signal_new (I_("set-surrounding-text"),
@@ -1265,7 +1292,8 @@ ibus_engine_service_method_call (IBusService *service,
keycode,
state);
}
- g_dbus_method_invocation_return_value (invocation, g_variant_new ("(b)", retval));
+ g_dbus_method_invocation_return_value (invocation,
+ g_variant_new ("(b)", retval));
return;
}
if (g_strcmp0 (method_name, "PanelExtensionReceived") == 0) {
@@ -1449,8 +1477,10 @@ ibus_engine_service_method_call (IBusService *service,
coordinates = g_variant_get_fixed_array (g_variant_get_child_value (parameters, 0), &coordinates_len, sizeof (gdouble));
g_return_if_fail (coordinates != NULL);
- g_return_if_fail (coordinates_len >= 4); /* The array should contain at least one line. */
- g_return_if_fail (coordinates_len <= G_MAXUINT); /* to prevent overflow in the cast in g_signal_emit */
+ /* The array should contain at least one line. */
+ g_return_if_fail (coordinates_len >= 4);
+ /* to prevent overflow in the cast in g_signal_emit */
+ g_return_if_fail (coordinates_len <= G_MAXUINT);
g_return_if_fail ((coordinates_len & 1) == 0);
g_signal_emit (engine, engine_signals[PROCESS_HAND_WRITING_EVENT], 0,
@@ -1656,38 +1686,32 @@ ibus_engine_set_cursor_location (IBusEngine *engine,
gint w,
gint h)
{
- // g_debug ("set-cursor-location (%d, %d, %d, %d)", x, y, w, h);
}
static void
ibus_engine_set_capabilities (IBusEngine *engine,
guint caps)
{
- // g_debug ("set-capabilities (0x%04x)", caps);
}
static void
ibus_engine_page_up (IBusEngine *engine)
{
- // g_debug ("page-up");
}
static void
ibus_engine_page_down (IBusEngine *engine)
{
- // g_debug ("page-down");
}
static void
ibus_engine_cursor_up (IBusEngine *engine)
{
- // g_debug ("cursor-up");
}
static void
ibus_engine_cursor_down (IBusEngine *engine)
{
- // g_debug ("cursor-down");
}
static void
@@ -1696,7 +1720,6 @@ ibus_engine_candidate_clicked (IBusEngine *engine,
guint button,
guint state)
{
- // g_debug ("candidate-clicked");
}
static void
@@ -1704,19 +1727,16 @@ ibus_engine_property_activate (IBusEngine *engine,
const gchar *prop_name,
guint prop_state)
{
- // g_debug ("property-activate ('%s', %d)", prop_name, prop_state);
}
static void
ibus_engine_property_show (IBusEngine *engine, const gchar *prop_name)
{
- // g_debug ("property-show ('%s')", prop_name);
}
static void
ibus_engine_property_hide (IBusEngine *engine, const gchar *prop_name)
{
- // g_debug ("property-hide ('%s')", prop_name);
}
static void
@@ -1734,7 +1754,6 @@ ibus_engine_set_surrounding_text (IBusEngine *engine,
engine->priv->surrounding_text = (IBusText *) g_object_ref_sink (text ? text : text_empty);
engine->priv->surrounding_cursor_pos = cursor_pos;
engine->priv->selection_anchor_pos = anchor_pos;
- // g_debug ("set-surrounding-text ('%s', %d, %d)", text->text, cursor_pos, anchor_pos);
}
static void
@@ -1742,17 +1761,18 @@ ibus_engine_process_hand_writing_event (IBusEngine *engine,
const gdouble *coordinates,
guint coordinates_len)
{
- // guint i;
- // g_debug ("process-hand-writing-event (%u)", coordinates_len);
- // for (i = 0; i < coordinates_len; i++)
- // g_debug (" %lf", coordinates[i]);
+#if 0
+ guint i;
+ g_debug ("process-hand-writing-event (%u)", coordinates_len);
+ for (i = 0; i < coordinates_len; i++)
+ g_debug (" %lf", coordinates[i]);
+#endif
}
static void
ibus_engine_cancel_hand_writing (IBusEngine *engine,
guint n_strokes)
{
- // g_debug ("cancel-hand-writing (%u)", n_strokes);
}
static void
@@ -1760,7 +1780,6 @@ ibus_engine_set_content_type (IBusEngine *engine,
guint purpose,
guint hints)
{
- // g_debug ("set-content-type (%u %u)", purpose, hints);
}
static void
@@ -2085,8 +2104,6 @@ ibus_engine_get_surrounding_text (IBusEngine *engine,
ibus_engine_emit_signal (engine,
"RequireSurroundingText",
NULL);
-
- // g_debug ("get-surrounding-text ('%s', %d, %d)", (*text)->text, *cursor_pos, *anchor_pos);
}
void