[gimp] Bug 737583 - Fix static placement of Chinese IME window



commit 7ee69c3053ef2fa32deb82ca65f54e0f038f5ac6
Author: Michael Natterer <mitch gimp org>
Date:   Wed Oct 1 00:26:48 2014 +0200

    Bug 737583 - Fix static placement of Chinese IME window
    
    Call gtk_im_context_set_cursor_location() whenever we draw the text
    tool cursor or start a preedit sequence.

 app/tools/gimptexttool-editor.c |   39 +++++++++++++++++++++++++++++++++++++++
 app/tools/gimptexttool-editor.h |    1 +
 app/tools/gimptexttool.c        |    8 +++++++-
 3 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c
index fcdda04..7c49432 100644
--- a/app/tools/gimptexttool-editor.c
+++ b/app/tools/gimptexttool-editor.c
@@ -48,6 +48,7 @@
 
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
+#include "display/gimpdisplayshell-transform.h"
 
 #include "gimprectangletool.h"
 #include "gimptextoptions.h"
@@ -569,6 +570,42 @@ gimp_text_tool_editor_get_cursor_rect (GimpTextTool   *text_tool,
   cursor_rect->height = PANGO_PIXELS (cursor_rect->height);
 }
 
+void
+gimp_text_tool_editor_update_im_rect (GimpTextTool *text_tool)
+{
+  GimpDisplayShell *shell;
+  PangoRectangle    rect = { 0, };
+  gint              off_x, off_y;
+
+  g_return_if_fail (GIMP_IS_TEXT_TOOL (text_tool));
+
+  shell = gimp_display_get_shell (GIMP_TOOL (text_tool)->display);
+
+  if (text_tool->text)
+    gimp_text_tool_editor_get_cursor_rect (text_tool,
+                                           text_tool->overwrite_mode,
+                                           &rect);
+
+  g_object_get (text_tool, "x1", &off_x, "y1", &off_y, NULL);
+  rect.x += off_x;
+  rect.y += off_y;
+
+  gimp_display_shell_transform_xy (shell, rect.x, rect.y, &rect.x, &rect.y);
+
+  if (text_tool->preedit_overlay)
+    {
+      GtkRequisition requisition;
+
+      gtk_widget_size_request (text_tool->preedit_overlay, &requisition);
+
+      rect.width  = requisition.width;
+      rect.height = requisition.height;
+    }
+
+  gtk_im_context_set_cursor_location (text_tool->im_context,
+                                      (GdkRectangle *) &rect);
+}
+
 
 /*  private functions  */
 
@@ -1350,6 +1387,8 @@ gimp_text_tool_im_preedit_start (GtkIMContext *context,
   gtk_misc_set_padding (GTK_MISC (text_tool->preedit_label), 2, 2);
   gtk_container_add (GTK_CONTAINER (ebox), text_tool->preedit_label);
   gtk_widget_show (text_tool->preedit_label);
+
+  gimp_text_tool_editor_update_im_rect (text_tool);
 }
 
 static void
diff --git a/app/tools/gimptexttool-editor.h b/app/tools/gimptexttool-editor.h
index ded830c..48a6f70 100644
--- a/app/tools/gimptexttool-editor.h
+++ b/app/tools/gimptexttool-editor.h
@@ -49,6 +49,7 @@ void       gimp_text_tool_reset_im_context       (GimpTextTool        *text_tool
 void       gimp_text_tool_editor_get_cursor_rect (GimpTextTool        *text_tool,
                                                   gboolean             overwrite,
                                                   PangoRectangle      *cursor_rect);
+void       gimp_text_tool_editor_update_im_rect  (GimpTextTool        *text_tool);
 
 
 #endif /* __GIMP_TEXT_TOOL_EDITOR_H__ */
diff --git a/app/tools/gimptexttool.c b/app/tools/gimptexttool.c
index b27dc0f..cca66a0 100644
--- a/app/tools/gimptexttool.c
+++ b/app/tools/gimptexttool.c
@@ -774,7 +774,11 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool)
   if (! text_tool->text  ||
       ! text_tool->layer ||
       ! text_tool->layer->text)
-    return;
+    {
+      gimp_text_tool_editor_update_im_rect (text_tool);
+
+      return;
+    }
 
   gimp_text_tool_ensure_layout (text_tool);
 
@@ -807,6 +811,8 @@ gimp_text_tool_draw (GimpDrawTool *draw_tool)
                                              overwrite);
       gimp_canvas_item_set_highlight (item, TRUE);
     }
+
+  gimp_text_tool_editor_update_im_rect (text_tool);
 }
 
 static void


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