[ibus] Fixed Bug 639253 - ibus_engine_delete_surrounding_text with offset.
Takao Fujiwara
fujiwara at fedoraproject.org
Mon Nov 22 03:46:07 UTC 2010
commit f7291cc56ab09e9ccde77c9f036bd2dd3eb59ee8
Author: Takao Fujiwara <tfujiwar at redhat.com>
Date: Mon Nov 22 12:45:59 2010 +0900
Fixed Bug 639253 - ibus_engine_delete_surrounding_text with offset.
ibus-435880-surrounding-text.patch | 164 ++++++++++++++++++++++++++----------
ibus.spec | 7 +-
2 files changed, 124 insertions(+), 47 deletions(-)
---
diff --git a/ibus-435880-surrounding-text.patch b/ibus-435880-surrounding-text.patch
index dc47332..a1fcaa0 100644
--- a/ibus-435880-surrounding-text.patch
+++ b/ibus-435880-surrounding-text.patch
@@ -1,6 +1,6 @@
-From 2a368335194eccd22d605d93532ce6e914089599 Mon Sep 17 00:00:00 2001
+From d396da77a9174df65f42e5ebe5bb723cf3fd47ef Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno at unixuser.org>
-Date: Thu, 4 Nov 2010 17:40:35 +0900
+Date: Mon, 22 Nov 2010 11:49:47 +0900
Subject: [PATCH] Support surrounding-text retrieval.
This change adds a new API function ibus_engine_get_surrounding_text().
@@ -22,22 +22,23 @@ Also,
- destroy
resets the current surrounding-text.
---
- bus/engineproxy.c | 42 +++++++++++++++
- bus/engineproxy.h | 4 ++
- bus/inputcontext.c | 32 +++++++++++
- client/gtk2/ibusimcontext.c | 80 ++++++++++++++++++++++++++---
+ bus/engineproxy.c | 43 +++++++++++++
+ bus/engineproxy.h | 4 +
+ bus/inputcontext.c | 32 +++++++++
+ client/gtk2/ibusimcontext.c | 93 ++++++++++++++++++++++++---
+ configure.ac | 15 +++++
ibus/engine.py | 6 ++
ibus/interface/iengine.py | 3 +
ibus/interface/iinputcontext.py | 3 +
- src/ibusengine.c | 110 +++++++++++++++++++++++++++++++++++++++
- src/ibusengine.h | 21 +++++++-
- src/ibusinputcontext.c | 61 +++++++++++++++++++++
- src/ibusinputcontext.h | 11 ++++
+ src/ibusengine.c | 134 +++++++++++++++++++++++++++++++++++++++
+ src/ibusengine.h | 21 ++++++-
+ src/ibusinputcontext.c | 61 ++++++++++++++++++
+ src/ibusinputcontext.h | 11 +++
src/ibusmarshalers.list | 1 +
- 12 files changed, 366 insertions(+), 8 deletions(-)
+ 13 files changed, 415 insertions(+), 12 deletions(-)
diff --git a/bus/engineproxy.c b/bus/engineproxy.c
-index f0ddd28..e04661a 100644
+index eb9412c..2955f71 100644
--- a/bus/engineproxy.c
+++ b/bus/engineproxy.c
@@ -42,6 +42,10 @@ struct _BusEngineProxy {
@@ -60,7 +61,7 @@ index f0ddd28..e04661a 100644
/* functions prototype */
static void bus_engine_proxy_real_destroy (IBusProxy *proxy);
-@@ -287,11 +293,15 @@ bus_engine_proxy_class_init (BusEngineProxyClass *class)
+@@ -287,11 +293,15 @@ bus_engine_proxy_class_init (BusEnginePr
1,
IBUS_TYPE_PROPERTY);
@@ -76,7 +77,7 @@ index f0ddd28..e04661a 100644
}
static void
-@@ -318,6 +328,11 @@ bus_engine_proxy_real_destroy (IBusProxy *proxy)
+@@ -318,6 +328,11 @@ bus_engine_proxy_real_destroy (IBusProxy
engine->keymap = NULL;
}
@@ -88,7 +89,7 @@ index f0ddd28..e04661a 100644
IBUS_PROXY_CLASS(bus_engine_proxy_parent_class)->destroy ((IBusProxy *)engine);
}
-@@ -641,6 +656,33 @@ void bus_engine_proxy_property_hide (BusEngineProxy *engine,
+@@ -641,6 +656,33 @@ void bus_engine_proxy_property_hide (Bus
NULL);
}
@@ -123,10 +124,10 @@ index f0ddd28..e04661a 100644
void \
bus_engine_proxy_##name (BusEngineProxy *engine) \
diff --git a/bus/engineproxy.h b/bus/engineproxy.h
-index 83c72da..da887eb 100644
+index c11bf2a..38bc996 100644
--- a/bus/engineproxy.h
+++ b/bus/engineproxy.h
-@@ -89,5 +89,9 @@ void bus_engine_proxy_property_show (BusEngineProxy *engi
+@@ -92,5 +92,9 @@ void bus_engine_proxy_property_show (BusEngineProxy *engi
void bus_engine_proxy_property_hide (BusEngineProxy *engine,
const gchar *prop_name);
gboolean bus_engine_proxy_is_enabled (BusEngineProxy *engine);
@@ -137,10 +138,10 @@ index 83c72da..da887eb 100644
G_END_DECLS
#endif
diff --git a/bus/inputcontext.c b/bus/inputcontext.c
-index 56fc27f..09cc2ba 100644
+index b006ed4..7e425c7 100644
--- a/bus/inputcontext.c
+++ b/bus/inputcontext.c
-@@ -235,6 +235,11 @@ static const gchar introspection_xml[] =
+@@ -241,6 +241,11 @@ static const gchar introspection_xml[] =
" <method name='GetEngine'>"
" <arg direction='out' type='v' name='desc' />"
" </method>"
@@ -152,7 +153,7 @@ index 56fc27f..09cc2ba 100644
/* signals */
" <signal name='CommitText'>"
" <arg type='v' name='text' />"
-@@ -906,6 +911,32 @@ _ic_get_engine (BusInputContext *context,
+@@ -903,6 +908,32 @@ _ic_get_engine (BusInputContext *context,
}
static void
@@ -185,7 +186,7 @@ index 56fc27f..09cc2ba 100644
bus_input_context_service_method_call (IBusService *service,
GDBusConnection *connection,
const gchar *sender,
-@@ -944,6 +975,7 @@ bus_input_context_service_method_call (IBusService *service,
+@@ -941,6 +972,7 @@ bus_input_context_service_method_call (IBusService *service,
{ "IsEnabled", _ic_is_enabled },
{ "SetEngine", _ic_set_engine },
{ "GetEngine", _ic_get_engine },
@@ -194,10 +195,10 @@ index 56fc27f..09cc2ba 100644
gint i;
diff --git a/client/gtk2/ibusimcontext.c b/client/gtk2/ibusimcontext.c
-index 6570473..ca8db35 100644
+index 63d66c9..04ba818 100644
--- a/client/gtk2/ibusimcontext.c
+++ b/client/gtk2/ibusimcontext.c
-@@ -113,6 +113,12 @@ static void ibus_im_context_set_cursor_location
+@@ -113,6 +113,12 @@ static void ibus_im_context_set_curs
static void ibus_im_context_set_use_preedit
(GtkIMContext *context,
gboolean use_preedit);
@@ -210,33 +211,39 @@ index 6570473..ca8db35 100644
/* static methods*/
static void _create_input_context (IBusIMContext *context);
-@@ -131,15 +137,16 @@ static void _slave_preedit_start_cb (GtkIMContext *slave,
+@@ -131,16 +137,16 @@ static void _slave_preedit_start_cb
IBusIMContext *context);
static void _slave_preedit_end_cb (GtkIMContext *slave,
IBusIMContext *context);
-static void _slave_retrieve_surrounding_cb
+static gboolean _slave_retrieve_surrounding_cb
(GtkIMContext *slave,
- IBusIMContext *context);
+- IBusIMContext *context);
-static void _slave_delete_surrounding_cb
++ IBusIMContext *context);
+static gboolean _slave_delete_surrounding_cb
(GtkIMContext *slave,
- gint offset_from_cursor,
- guint nchars,
- IBusIMContext *context);
+- gint offset_from_cursor,
+- guint nchars,
+- IBusIMContext *context);
++ gint offset_from_cursor,
++ guint nchars,
++ IBusIMContext *context);
static void _create_fake_input_context (void);
+-
+static void _request_surrounding_text (IBusIMContext *context);
-
-@@ -206,6 +213,16 @@ ibus_im_context_new (void)
+ static GType _ibus_type_im_context = 0;
+@@ -206,6 +212,17 @@ ibus_im_context_new (void)
return IBUS_IM_CONTEXT (obj);
}
+static void
+_request_surrounding_text (IBusIMContext *context)
+{
-+ if (context->enable) {
++ if (context->enable &&
++ (context->caps & IBUS_CAP_SURROUNDING_TEXT)) {
+ gboolean return_value;
+ g_signal_emit (context, _signal_retrieve_surrounding_id, 0,
+ &return_value);
@@ -255,7 +262,7 @@ index 6570473..ca8db35 100644
switch (event->type) {
case GDK_KEY_RELEASE:
retval = ibus_input_context_process_key_event (ibuscontext,
-@@ -291,6 +310,7 @@ ibus_im_context_class_init (IBusIMContextClass *class)
+@@ -291,6 +310,7 @@ ibus_im_context_class_init (IBusIMCo
im_context_class->set_client_window = ibus_im_context_set_client_window;
im_context_class->set_cursor_location = ibus_im_context_set_cursor_location;
im_context_class->set_use_preedit = ibus_im_context_set_use_preedit;
@@ -263,7 +270,19 @@ index 6570473..ca8db35 100644
gobject_class->finalize = ibus_im_context_finalize;
_signal_commit_id =
-@@ -488,6 +508,8 @@ ibus_im_context_filter_keypress (GtkIMContext *context,
+@@ -396,7 +416,11 @@ ibus_im_context_init (GObject *obj)
+
+ ibusimcontext->ibuscontext = NULL;
+ ibusimcontext->has_focus = FALSE;
++#ifdef ENABLE_SURROUNDING
+ ibusimcontext->caps = IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_FOCUS | IBUS_CAP_SURROUNDING_TEXT;
++#else
++ ibusimcontext->caps = IBUS_CAP_PREEDIT_TEXT | IBUS_CAP_FOCUS;
++#endif
+
+
+ // Create slave im context
+@@ -488,6 +512,8 @@ ibus_im_context_filter_keypress (GtkIMCo
if (ibusimcontext->client_window == NULL && event->window != NULL)
gtk_im_context_set_client_window ((GtkIMContext *)ibusimcontext, event->window);
@@ -272,7 +291,7 @@ index 6570473..ca8db35 100644
switch (event->type) {
case GDK_KEY_RELEASE:
retval = ibus_input_context_process_key_event (ibusimcontext->ibuscontext,
-@@ -552,6 +574,8 @@ ibus_im_context_focus_in (GtkIMContext *context)
+@@ -552,6 +578,8 @@ ibus_im_context_focus_in (GtkIMContext *
g_object_weak_ref ((GObject *) context, _weak_notify_cb, NULL);
_focus_im_context = context;
}
@@ -281,7 +300,7 @@ index 6570473..ca8db35 100644
}
static void
-@@ -728,6 +752,39 @@ ibus_im_context_set_use_preedit (GtkIMContext *context, gboolean use_preedit)
+@@ -723,6 +751,39 @@ ibus_im_context_set_use_preedit (GtkIMCo
}
static void
@@ -321,7 +340,7 @@ index 6570473..ca8db35 100644
_bus_connected_cb (IBusBus *bus,
IBusIMContext *ibusimcontext)
{
-@@ -746,6 +803,8 @@ _ibus_context_commit_text_cb (IBusInputContext *ibuscontext,
+@@ -741,6 +802,8 @@ _ibus_context_commit_text_cb (IBusInputC
IDEBUG ("%s", __FUNCTION__);
g_signal_emit (ibusimcontext, _signal_commit_id, 0, text->text);
@@ -330,7 +349,7 @@ index 6570473..ca8db35 100644
}
static gboolean
-@@ -1018,6 +1077,8 @@ _ibus_context_show_preedit_text_cb (IBusInputContext *ibuscontext,
+@@ -1013,6 +1076,8 @@ _ibus_context_show_preedit_text_cb (IBus
ibusimcontext->preedit_visible = TRUE;
g_signal_emit (ibusimcontext, _signal_preedit_start_id, 0);
g_signal_emit (ibusimcontext, _signal_preedit_changed_id, 0);
@@ -339,7 +358,7 @@ index 6570473..ca8db35 100644
}
static void
-@@ -1183,17 +1244,21 @@ _slave_preedit_end_cb (GtkIMContext *slave,
+@@ -1178,17 +1243,21 @@ _slave_preedit_end_cb (GtkIMContext *sl
g_signal_emit (ibusimcontext, _signal_preedit_end_id, 0);
}
@@ -365,7 +384,7 @@ index 6570473..ca8db35 100644
_slave_delete_surrounding_cb (GtkIMContext *slave,
gint offset_from_cursor,
guint nchars,
-@@ -1202,9 +1267,10 @@ _slave_delete_surrounding_cb (GtkIMContext *slave,
+@@ -1197,9 +1266,10 @@ _slave_delete_surrounding_cb (GtkIMConte
gboolean return_value;
if (ibusimcontext->enable && ibusimcontext->ibuscontext) {
@@ -377,6 +396,37 @@ index 6570473..ca8db35 100644
}
#ifdef OS_CHROMEOS
+diff --git a/configure.ac b/configure.ac
+index ea0d32b..60776df 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -405,6 +405,19 @@ AC_ARG_WITH(no-snooper-apps,
+ AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS",
+ [Does not enbale keyboard snooper in those applications])
+
++# option for enable surrounding-text
++AC_ARG_ENABLE(surrounding-text,
++ AS_HELP_STRING([--enable-surrounding-text],
++ [Enable surrounding-text support]),
++ [enable_surrounding_text=$enableval],
++ [enable_surrounding_text=no]
++)
++if test x"$enable_surrounding_text" = x"yes"; then
++ AC_DEFINE(ENABLE_SURROUNDING, TRUE, [Enable surrounding-text support])
++else
++ enable_surrounding_text="no (disabled, use --enable-surrounding-text to enable)"
++fi
++
+ # check iso-codes
+ PKG_CHECK_MODULES(ISOCODES, [
+ iso-codes
+@@ -477,5 +490,6 @@ Build options:
+ Build document $enable_gtk_doc
+ Enable key snooper $enable_key_snooper
+ No snooper regexes "$NO_SNOOPER_APPS"
++ Enable surrounding-text $enable_surrounding_text
+ ])
+
diff --git a/ibus/engine.py b/ibus/engine.py
index b1df2fe..ec42fa4 100644
--- a/ibus/engine.py
@@ -430,7 +480,7 @@ index 89f6dbd..2db1c9b 100644
def FocusIn(self): pass
diff --git a/src/ibusengine.c b/src/ibusengine.c
-index ae07393..87ea7c2 100644
+index ae07393..777d404 100644
--- a/src/ibusengine.c
+++ b/src/ibusengine.c
@@ -45,6 +45,7 @@ enum {
@@ -581,7 +631,7 @@ index ae07393..87ea7c2 100644
ibus_engine_emit_signal (IBusEngine *engine,
const gchar *signal_name,
GVariant *parameters)
-@@ -1133,14 +1215,42 @@ void ibus_engine_delete_surrounding_text (IBusEngine *engine,
+@@ -1133,14 +1215,66 @@ void ibus_engine_delete_surrounding_text (IBusEngine *engine,
gint offset_from_cursor,
guint nchars)
{
@@ -591,11 +641,35 @@ index ae07393..87ea7c2 100644
+ priv = IBUS_ENGINE_GET_PRIVATE (engine);
+
-+ /* Clear the current surrounding-text buffer. */
++ /* Update surrounding-text cache. This is necessary since some
++ engines call ibus_engine_get_surrounding_text() immediately
++ after ibus_engine_delete_surrounding_text(). */
+ if (priv->surrounding_text) {
++ IBusText *text;
++ glong cursor_pos, len;
++
++ cursor_pos = priv->surrounding_cursor_pos + offset_from_cursor;
++ len = ibus_text_get_length (priv->surrounding_text);
++ if (cursor_pos >= 0 && len - cursor_pos >= nchars) {
++ gunichar *ucs;
++
++ ucs = g_utf8_to_ucs4_fast (priv->surrounding_text->text,
++ -1,
++ NULL);
++ memmove (&ucs[cursor_pos],
++ &ucs[cursor_pos + nchars],
++ sizeof(gunichar) * (len - cursor_pos - nchars));
++ ucs[len - nchars] = 0;
++ text = ibus_text_new_from_ucs4 (ucs);
++ g_free (ucs);
++ priv->surrounding_cursor_pos = cursor_pos;
++ } else {
++ text = text_empty;
++ priv->surrounding_cursor_pos = 0;
++ }
++
+ g_object_unref (priv->surrounding_text);
-+ priv->surrounding_text = g_object_ref_sink (text_empty);
-+ priv->surrounding_cursor_pos = 0;
++ priv->surrounding_text = g_object_ref_sink (text);
+ }
+
ibus_engine_emit_signal (engine,
@@ -667,7 +741,7 @@ index 46d0a04..a5f5aea 100644
* @engine: An IBusEngine.
* @returns: Name of IBusEngine.
diff --git a/src/ibusinputcontext.c b/src/ibusinputcontext.c
-index f2977fc..55de905 100644
+index fc26a7c..4f08401 100644
--- a/src/ibusinputcontext.c
+++ b/src/ibusinputcontext.c
@@ -59,13 +59,20 @@ enum {
diff --git a/ibus.spec b/ibus.spec
index b1ff3ea..bae5bec 100644
--- a/ibus.spec
+++ b/ibus.spec
@@ -12,7 +12,7 @@
Name: ibus
Version: 1.3.99.20101028
-Release: 5%{?dist}
+Release: 6%{?dist}
Summary: Intelligent Input Bus for Linux OS
License: LGPLv2+
Group: System Environment/Libraries
@@ -169,6 +169,7 @@ automake -a -c -f
--enable-xim \
--disable-gtk-doc \
--with-no-snooper-apps='gnome-do,Do.*,firefox.*,.*chrome.*,.*chromium.*' \
+ --enable-surrounding-text \
--enable-introspection
# make -C po update-gmo
@@ -310,7 +311,7 @@ fi
%{_datadir}/gtk-doc/html/*
%changelog
-* Thu Nov 18 2010 Takao Fujiwara <tfujiwar at redhat.com> - 1.3.99.20101028-5
+* Mon Nov 22 2010 Takao Fujiwara <tfujiwar at redhat.com> - 1.3.99.20101028-6
- Added ibus-652157-x11-ppc64.patch
Fixed Bug 652157 - Window position of ibus-x11 in ppc64
- Added ibus-530711-preload-sys.patch
@@ -322,6 +323,8 @@ fi
- Applied no-snooper for 'gnome-do,Do.*,firefox.*,.*chrome.*,.*chromium.*'
- Updated ibus-541492-xkb.patch
Fixed Bug 653806 - ibus-xkb SEGV
+- Updated ibus-435880-surrounding-text.patch
+ Fixed Bug 639253 - ibus_engine_delete_surrounding_text with offset.
* Fri Oct 29 2010 Takao Fujiwara <tfujiwar at redhat.com> - 1.3.99.20101028-1
- Updated to 1.3.99.20101028
More information about the scm-commits
mailing list