[gimp] app: do not commit IM preedit text after switching text layer.



commit a1f01970988775a691c98bb0d602e6684378bea0
Author: Jehan <jehan girinstud io>
Date:   Mon Jun 6 14:51:15 2016 +0200

    app: do not commit IM preedit text after switching text layer.
    
    Whereas some IME would just cancel any preediting on IM context reset,
    others would commit their preedit (for instance Ibus-Hangul).
    Unfortunately it is not necessarily immediate, even after
    gtk_im_context_reset() and gtk_im_context_focus_out(), so when switching
    text layer, any preedit text is committed on the new layer.
    Let's recreate the IM context on abort to make sure we don't share any
    input between text layers.

 app/tools/gimptexttool-editor.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index 4255b88..2de63fc 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -567,9 +567,29 @@ gimp_text_tool_abort_im_context (GimpTextTool *text_tool)
   gtk_im_context_focus_out (text_tool->im_context);
   gtk_im_context_set_client_window (text_tool->im_context, NULL);
 
+  g_object_unref (text_tool->im_context);
+  text_tool->im_context = gtk_im_multicontext_new ();
   gtk_im_context_set_client_window (text_tool->im_context,
                                     gtk_widget_get_window (shell->canvas));
   gtk_im_context_focus_in (text_tool->im_context);
+  g_signal_connect (text_tool->im_context, "preedit-start",
+                    G_CALLBACK (gimp_text_tool_im_preedit_start),
+                    text_tool);
+  g_signal_connect (text_tool->im_context, "preedit-end",
+                    G_CALLBACK (gimp_text_tool_im_preedit_end),
+                    text_tool);
+  g_signal_connect (text_tool->im_context, "preedit-changed",
+                    G_CALLBACK (gimp_text_tool_im_preedit_changed),
+                    text_tool);
+  g_signal_connect (text_tool->im_context, "commit",
+                    G_CALLBACK (gimp_text_tool_im_commit),
+                    text_tool);
+  g_signal_connect (text_tool->im_context, "retrieve-surrounding",
+                    G_CALLBACK (gimp_text_tool_im_retrieve_surrounding),
+                    text_tool);
+  g_signal_connect (text_tool->im_context, "delete-surrounding",
+                    G_CALLBACK (gimp_text_tool_im_delete_surrounding),
+                    text_tool);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]