From babad7839ba6d72609c717d647bb2928724b4cc3 Mon Sep 17 00:00:00 2001 From: Izumi Tsutsui Date: Tue, 6 Sep 2022 17:08:43 +0900 Subject: [PATCH] tools: Check libdl for dlclose() properly in configure BUG=https://github.com/ibus/ibus/pull/2442 --- configure.ac | 4 ++++ tools/Makefile.am | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 0868d6c9..2344523a 100644 --- a/configure.ac +++ b/configure.ac @@ -147,6 +147,10 @@ AC_CHECK_HEADERS([sys/prctl.h]) # Check functions. AC_CHECK_FUNCS(daemon) +# Check dlclose() in libc.so. +AC_CHECK_LIB(c, dlclose, LIBDL="", [AC_CHECK_LIB(dl, dlclose, LIBDL="-ldl")]) +AC_SUBST(LIBDL) + # Check packages. # Check glib2. AM_PATH_GLIB_2_0 diff --git a/tools/Makefile.am b/tools/Makefile.am index b82395da..e300f9f3 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -63,7 +63,7 @@ AM_LDADD = \ @GTHREAD2_LIBS@ \ $(libibus) \ $(libibusimmodule) \ - -ldl \ + $(LIBDL) \ $(NULL) AM_VALAFLAGS = \ -- 2.37.3 From 39b69073ad34ab89a3e5aa012ff740c84f69eb8f Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Fri, 16 Sep 2022 14:30:35 +0900 Subject: [PATCH] client/gtk2: Stop many warnings of surrounding text Surrounding text is requested by ibus_im_context_filter_keypress() and the no supported warning could be output many times. Now the warning is output one time by input context but brower applicaations do not use GtkWidget for the input context so the warning is output by instance but not input context. BUG=https://github.com/ibus/ibus/issues/2418 --- client/gtk2/ibusimcontext.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index bc14df00..3fc9c0f2 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -567,6 +567,7 @@ _process_key_event (IBusInputContext *context, static void _request_surrounding_text (IBusIMContext *context) { + static gboolean warned = FALSE; if (context && (context->caps & IBUS_CAP_SURROUNDING_TEXT) != 0 && context->ibuscontext != NULL && @@ -580,8 +581,11 @@ _request_surrounding_text (IBusIMContext *context) * fail with the first typing on firefox but it succeeds with * the second typing. */ - g_warning ("%s has no capability of surrounding-text feature", - g_get_prgname ()); + if (!warned) { + g_warning ("%s has no capability of surrounding-text feature", + g_get_prgname ()); + warned = TRUE; + } } } } -- 2.37.3 From 50f8d8b79bc8eac1bae80116fe669d7314a44663 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Fri, 16 Sep 2022 14:34:54 +0900 Subject: [PATCH] client/gtk2: Update capabilities if "retrieve-surrounding" is failed Some engine developers wish to update the capabilities if emitting "retrieve-surrounding" signal is failed so that engines disable the surrounding text feature but I had deleted the logic with #2054 since the second typing could be succeeded. Asking all applications the second typing would not be a good condition and the special issue should be fixed in firefox. Fixes: https://github.com/ibus/ibus/commit/7b3b8c8b0c BUG=https://github.com/ibus/ibus/issues/2054 BUG=https://github.com/ibus/ibus/issues/2354 --- client/gtk2/ibusimcontext.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index 3fc9c0f2..eaf7eb90 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -577,10 +577,14 @@ _request_surrounding_text (IBusIMContext *context) g_signal_emit (context, _signal_retrieve_surrounding_id, 0, &return_value); if (!return_value) { - /* #2054 firefox::IMContextWrapper::GetCurrentParagraph() could - * fail with the first typing on firefox but it succeeds with - * the second typing. + /* 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 ()); -- 2.37.3 From 7bbcce66e1ca694b7a62553327161290bf4ee283 Mon Sep 17 00:00:00 2001 From: fujiwarat Date: Mon, 19 Sep 2022 11:52:14 +0900 Subject: [PATCH] client/gtk2: Update surrounding text properties by focus in ibus_input_context_set_surrounding_text() should be succeeded if input contexts are different so that ibus engines can update surrounding text properties with focus in event. When an input context is created newly, RequireSurroundingText D-Bus signal could not be received yet and set_surrounding_text() is failed. Now "require-surrounding-text" signal is added to IBusInputContext and clients can call set_surrounding_text() later. BUG=https://github.com/ibus/ibus/issues/2423 --- client/gtk2/ibusimcontext.c | 25 +++++++++++++++++++++++++ src/ibusinputcontext.c | 29 ++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c index eaf7eb90..6e338157 100644 --- a/client/gtk2/ibusimcontext.c +++ b/client/gtk2/ibusimcontext.c @@ -70,6 +70,7 @@ struct _IBusIMContext { #endif IBusInputContext *ibuscontext; + IBusInputContext *ibuscontext_needs_surrounding; /* preedit status */ gchar *preedit_string; @@ -985,6 +986,7 @@ 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 @@ -2183,6 +2185,18 @@ _ibus_context_hide_preedit_text_cb (IBusInputContext *ibuscontext, g_signal_emit (ibusimcontext, _signal_preedit_end_id, 0); } +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; + } +} + static void _ibus_context_destroy_cb (IBusInputContext *ibuscontext, IBusIMContext *ibusimcontext) @@ -2249,6 +2263,11 @@ _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); @@ -2265,6 +2284,12 @@ _create_input_context_done (IBusBus *bus, ibus_input_context_focus_in (ibusimcontext->ibuscontext); _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 (!g_queue_is_empty (ibusimcontext->events_queue)) { diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c index 7981de38..28ae04ad 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 - * Copyright (C) 2018-2019 Takao Fujiwara + * Copyright (C) 2018-2022 Takao Fujiwara * Copyright (C) 2008-2019 Red Hat, Inc. * * This library is free software; you can redistribute it and/or @@ -55,6 +55,7 @@ enum { CURSOR_DOWN_LOOKUP_TABLE, REGISTER_PROPERTIES, UPDATE_PROPERTY, + REQUIRE_SURROUNDING_TEXT, LAST_SIGNAL, }; @@ -488,6 +489,21 @@ ibus_input_context_class_init (IBusInputContextClass *class) 1, IBUS_TYPE_PROPERTY); + /** + * IBusInputContext::require-surrounding-text: + * @context: An IBusInputContext. + * + * Emitted to receive the RequireSurroundingText signal from the daemon. + */ + context_signals[REQUIRE_SURROUNDING_TEXT] = + g_signal_new (I_("require-surrounding-text"), + G_TYPE_FROM_CLASS (class), + G_SIGNAL_RUN_LAST, + 0, + NULL, NULL, + _ibus_marshal_VOID__VOID, + G_TYPE_NONE, 0); + text_empty = ibus_text_new_from_static_string (""); g_object_ref_sink (text_empty); } @@ -735,6 +751,7 @@ ibus_input_context_g_signal (GDBusProxy *proxy, if (g_strcmp0 (signal_name, "RequireSurroundingText") == 0) { priv->needs_surrounding_text = TRUE; + g_signal_emit (context, context_signals[REQUIRE_SURROUNDING_TEXT], 0); return; } @@ -1116,9 +1133,19 @@ ibus_input_context_set_surrounding_text (IBusInputContext *context, priv = IBUS_INPUT_CONTEXT_GET_PRIVATE (context); + /* This API should send "SetSurroundingText" D-Bus method when + * input contexts are switched between tabs in a text application + * so that engines can receive the updated surrounding texts after + * focus-in events happen. + * + * GNOME shell uses a single input context and the address of the input + * contexts are always same. So check the address of texts if the input + * contexts on applications are switched. + */ if (cursor_pos != priv->surrounding_cursor_pos || anchor_pos != priv->selection_anchor_pos || priv->surrounding_text == NULL || + text != priv->surrounding_text || g_strcmp0 (text->text, priv->surrounding_text->text) != 0) { if (priv->surrounding_text) g_object_unref (priv->surrounding_text); -- 2.37.3