Add DeleteSurroundingText to PostProcessKeyEvent

This commit is contained in:
Takao Fujiwara 2023-10-23 19:49:52 +09:00
parent ec611b250c
commit 900c828556
2 changed files with 137 additions and 2 deletions

View File

@ -1280,3 +1280,135 @@ index ffc20de1..e3aae3d4 100644
--
2.41.0
From f176569cf774f87b23270257da68249dcda837c9 Mon Sep 17 00:00:00 2001
From: fujiwarat <takao.fujiwara1@gmail.com>
Date: Wed, 18 Oct 2023 16:57:28 +0900
Subject: [PATCH] src: Add DeleteSurroundingText to PostProcessKeyEvent
DeleteSurroundingText also can be delayed sending to IBus clients.
Now surrounding D-Bus methods are added to PostProcessKeyEvent.
Fixes: https://github.com/ibus/ibus/commit/38f09c6
BUG=https://github.com/ibus/ibus/issues/2570
---
bus/inputcontext.c | 33 +++++++++++++++++++++++++++++++--
src/ibusinputcontext.c | 23 +++++++++++++++++++++++
2 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
index aecc64f8..64430fe4 100644
--- a/bus/inputcontext.c
+++ b/bus/inputcontext.c
@@ -2382,7 +2382,7 @@ _engine_forward_key_event_cb (BusEngineProxy *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) {
+ context->queue_during_process_key_event) <= MAX_SYNC_DATA) {
SyncForwardingData *data;
IBusText *text = ibus_text_new_from_printf ("%u,%u,%u",
keyval, keycode, state);
@@ -2420,6 +2420,21 @@ _engine_delete_surrounding_text_cb (BusEngineProxy *engine,
g_assert (context->engine == engine);
+ 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 ("%d,%u",
+ offset_from_cursor, nchars);
+ 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 = 'd';
+ data->text = g_object_ref (text);
+ g_queue_push_tail (context->queue_during_process_key_event, data);
+ return;
+ }
bus_input_context_emit_signal (context,
"DeleteSurroundingText",
g_variant_new ("(iu)",
@@ -2442,6 +2457,20 @@ _engine_require_surrounding_text_cb (BusEngineProxy *engine,
g_assert (context->engine == engine);
+ 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_static_string ("");
+ 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 = 'r';
+ data->text = text;
+ g_queue_push_tail (context->queue_during_process_key_event, data);
+ return;
+ }
bus_input_context_emit_signal (context,
"RequireSurroundingText",
NULL,
@@ -3158,7 +3187,7 @@ bus_input_context_commit_text_use_extension (BusInputContext *context,
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) {
+ 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) {
diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c
index def23b25..c6a030fe 100644
--- a/src/ibusinputcontext.c
+++ b/src/ibusinputcontext.c
@@ -1406,6 +1406,7 @@ ibus_input_context_set_post_process_key_event (IBusInputContext *context,
void
ibus_input_context_post_process_key_event (IBusInputContext *context)
{
+ IBusInputContextPrivate *priv;
GVariant *cached_var_post;
gboolean enable = FALSE;
GVariant *result;
@@ -1418,6 +1419,7 @@ ibus_input_context_post_process_key_event (IBusInputContext *context)
g_assert (IBUS_IS_INPUT_CONTEXT (context));
+ priv = IBUS_INPUT_CONTEXT_GET_PRIVATE (IBUS_INPUT_CONTEXT (context));
cached_var_post =
g_dbus_proxy_get_cached_property ((GDBusProxy *)context,
"EffectivePostProcessKeyEvent");
@@ -1479,6 +1481,27 @@ ibus_input_context_post_process_key_event (IBusInputContext *context)
state | IBUS_FORWARD_MASK);
break;
}
+ case 'r': {
+ priv->needs_surrounding_text = TRUE;
+ g_signal_emit (context,
+ context_signals[REQUIRE_SURROUNDING_TEXT], 0);
+ break;
+ }
+ case 'd': {
+ gchar **array = NULL;
+ gint offset_from_cursor;
+ guint nchars;
+ array = g_strsplit (text->text, ",", -1);
+ offset_from_cursor = g_ascii_strtoll (array[0], NULL, 10);
+ nchars = g_ascii_strtoull (array[1], NULL, 10);
+ g_strfreev (array);
+ g_signal_emit (context,
+ context_signals[DELETE_SURROUNDING_TEXT],
+ 0,
+ offset_from_cursor,
+ nchars);
+ break;
+ }
default:
g_warning ("%s: Type '%c' is not supported.", G_STRFUNC, type);
}
--
2.41.0

View File

@ -58,7 +58,7 @@
Name: ibus
Version: 1.5.29~rc1
Release: 4%{?dist}
Release: 5%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPL-2.1-or-later
URL: https://github.com/ibus/%name/wiki
@ -579,7 +579,10 @@ dconf update || :
%{_datadir}/installed-tests/ibus
%changelog
* Sat Sep 30 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc1-3
* Mon Oct 23 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc1-5
- Add DeleteSurroundingText to PostProcessKeyEvent
* Sat Sep 30 2023 Takao Fujiwara <tfujiwar@redhat.com> - 1.5.29~rc1-4
- Enhance #2237486 Implement preedit color in Plasma Wayland
- Part-of #2240490 Eacute with CapsLock in Plasma Wayland only
- Revert dnf5 to dnf in autogen