Comment #12 on issue 1264 by [email protected]: Bug with Korean mode
https://code.google.com/p/ibus/issues/detail?id=1264

That's all right.
I solved the problem using workaround because it is very difficult to re-design ibus with sync mode.

I made patches using ibus-1.4.1, ibus-hangul-1.4.1 on Debian Wheezy
NOTE: This workaround affects other ibus-*.
If someone does not want to commit pre-edit string, you may have the option to commit or not to commit by preference configuration.

Changes are:

client/gtk3/ibusimcontext.c in ibus-1.4.1

  removed key snooper
  added commit procedure in reset() in client/gtk3/ibusimcontext.c

engine.c in ibus-hangul-1.4.1

  removed commit procedure in reset() in engine.c

I believe that these patches also solve https://code.google.com/p/ibus/issues/detail?id=1420

diff --git a/client/gtk3/ibusimcontext.c b/client/gtk3/ibusimcontext.c
index 72db581..26bcc8d 100644
--- a/client/gtk3/ibusimcontext.c
+++ b/client/gtk3/ibusimcontext.c
@@ -80,7 +80,9 @@ static guint    _signal_delete_surrounding_id = 0;
 static guint    _signal_retrieve_surrounding_id = 0;

 static const gchar *_no_snooper_apps = NO_SNOOPER_APPS;
-static gboolean _use_key_snooper = ENABLE_SNOOPER;
+/* static gboolean _use_key_snooper = ENABLE_SNOOPER; */
+static gboolean _use_key_snooper = FALSE;
+
 static guint    _key_snooper_id = 0;

 static gboolean _use_sync_mode = FALSE;
@@ -478,9 +480,11 @@ ibus_im_context_class_init (IBusIMContextClass *class)
     _signal_retrieve_surrounding_id =
g_signal_lookup ("retrieve-surrounding", G_TYPE_FROM_CLASS (class));
     g_assert (_signal_retrieve_surrounding_id != 0);
-
+/*
     _use_key_snooper = !_get_boolean_env ("IBUS_DISABLE_SNOOPER",
                                           !(ENABLE_SNOOPER));
+*/
+    _use_key_snooper = FALSE;
     _use_sync_mode = _get_boolean_env ("IBUS_ENABLE_SYNC_MODE", FALSE);

     /* env IBUS_DISABLE_SNOOPER does not exist */
@@ -516,18 +520,22 @@ ibus_im_context_class_init (IBusIMContextClass *class)


     /* always install snooper */
+/*
     if (_key_snooper_id == 0)
         _key_snooper_id = gtk_key_snooper_install (_key_snooper_cb, NULL);
+*/
 }

 static void
 ibus_im_context_class_fini (IBusIMContextClass *class)
 {
+/*
     if (_key_snooper_id != 0) {
         IDEBUG ("snooper is terminated.");
         gtk_key_snooper_remove (_key_snooper_id);
         _key_snooper_id = 0;
     }
+*/
 }

/* Copied from gtk+2.0-2.20.1/modules/input/imcedilla.c to fix crosbug.com/11421.
@@ -824,6 +832,24 @@ ibus_im_context_reset (GtkIMContext *context)
     IBusIMContext *ibusimcontext = IBUS_IM_CONTEXT (context);

     if (ibusimcontext->ibuscontext) {
+ if (ibusimcontext->preedit_string && g_strcmp0 (ibusimcontext->preedit_string, "")) {
+                       gchar *str = g_strdup (ibusimcontext->preedit_string);
+                       /* clear preedit_string */
+                       g_free (ibusimcontext->preedit_string);
+                       ibusimcontext->preedit_string = NULL;
+                       /* clear preedit_cursor_pos */
+            ibusimcontext->preedit_cursor_pos = 0;
+                       /* clear preedit_attrs */
+                       if (ibusimcontext->preedit_attrs) {
+                               pango_attr_list_unref 
(ibusimcontext->preedit_attrs);
+                               ibusimcontext->preedit_attrs = NULL;
+                       }
+                       /* preedit changed */
+                       g_signal_emit (ibusimcontext, 
_signal_preedit_changed_id, 0);
+                       /* commit text */
+                       g_signal_emit (ibusimcontext, _signal_commit_id, 0, 
str);
+                       /* g_free (preedit_string); */
+               }
         ibus_input_context_reset (ibusimcontext->ibuscontext);
     }
     gtk_im_context_reset (ibusimcontext->slave);


diff --git a/src/engine.c b/src/engine.c
index 602f073..4af256b 100644
--- a/src/engine.c
+++ b/src/engine.c
@@ -1136,7 +1136,29 @@ ibus_hangul_engine_reset (IBusEngine *engine)
 {
     IBusHangulEngine *hangul = (IBusHangulEngine *) engine;

-    ibus_hangul_engine_flush (hangul);
+    /* const gunichar *str; */
+    /* IBusText *text; */
+
+    ibus_hangul_engine_hide_lookup_table (hangul);
+
+    /* str = */ hangul_ic_flush (hangul->context);
+
+    /* ustring_append_ucs4 (hangul->preedit, str, -1); */
+
+    if (ustring_length (hangul->preedit) != 0) {
+        /* clear preedit text before commit */
+        ibus_hangul_engine_clear_preedit_text (hangul);
+
+               /* str = ustring_begin (hangul->preedit); */
+               /* text = ibus_text_new_from_ucs4 (str); */
+
+               /* ibus_engine_commit_text ((IBusEngine *) hangul, text); */
+
+               ustring_clear(hangul->preedit);
+    }
+
+    ibus_hangul_engine_update_preedit_text (hangul);
+
     parent_class->reset (engine);
 }

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
You received this message because you are subscribed to the Google
Groups "ibus-devel" group.
iBus project web page: http://code.google.com/p/ibus/
iBus dev group: http://groups.google.com/group/ibus-devel?hl=en
--- You received this message because you are subscribed to the Google Groups "ibus-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

回复