diff -Nur mozilla-bak/widget/src/gtk2/nsWindow.cpp mozilla/widget/src/gtk2/nsWindow.cpp --- mozilla-bak/widget/src/gtk2/nsWindow.cpp 2004-11-03 22:20:22.449265144 +0900 +++ mozilla/widget/src/gtk2/nsWindow.cpp 2004-11-03 22:26:24.243264096 +0900 @@ -215,6 +215,7 @@ nsWindow *aWindow); static void IM_set_text_range (const PRInt32 aLen, const gchar *aPreeditString, + const gint aCursorPos, const PangoAttrList *aFeedback, PRUint32 *aTextRangeListLengthResult, nsTextRangeArray *aTextRangeListResult); @@ -4204,12 +4205,28 @@ nsEventStatus status; DispatchEvent(&compEvent, status); + + gint x1, y1, x2, y2; + GtkWidget *widget = + get_gtk_widget_for_gdk_window(this->mDrawingarea->inner_window); + + gdk_window_get_origin(widget->window, &x1, &y1); + gdk_window_get_origin(this->mDrawingarea->inner_window, &x2, &y2); + + GdkRectangle area; + area.x = compEvent.theReply.mCursorPosition.x + (x2 - x1); + area.y = compEvent.theReply.mCursorPosition.y + (y2 - y1); + area.width = 0; + area.height = compEvent.theReply.mCursorPosition.height; + + gtk_im_context_set_cursor_location(IMEGetContext(), &area); } void nsWindow::IMEComposeText (const PRUnichar *aText, const PRInt32 aLen, const gchar *aPreeditString, + const gint aCursorPos, const PangoAttrList *aFeedback) { // Send our start composition event if we need to @@ -4223,7 +4240,7 @@ textEvent.theText = (PRUnichar*)aText; if (aPreeditString && aFeedback && (aLen > 0)) { - IM_set_text_range(aLen, aPreeditString, aFeedback, + IM_set_text_range(aLen, aPreeditString, aCursorPos, aFeedback, &(textEvent.rangeCount), &(textEvent.rangeArray)); } @@ -4235,6 +4252,21 @@ if (textEvent.rangeArray) { delete[] textEvent.rangeArray; } + + gint x1, y1, x2, y2; + GtkWidget *widget = + get_gtk_widget_for_gdk_window(this->mDrawingarea->inner_window); + + gdk_window_get_origin(widget->window, &x1, &y1); + gdk_window_get_origin(this->mDrawingarea->inner_window, &x2, &y2); + + GdkRectangle area; + area.x = textEvent.theReply.mCursorPosition.x + (x2 - x1); + area.y = textEvent.theReply.mCursorPosition.y + (y2 - y1); + area.width = 0; + area.height = textEvent.theReply.mCursorPosition.height; + + gtk_im_context_set_cursor_location(IMEGetContext(), &area); } void @@ -4325,6 +4357,7 @@ return; // Should use cursor_pos ? + // Of course!!! gtk_im_context_get_preedit_string(aContext, &preedit_string, &feedback_list, &cursor_pos); @@ -4333,7 +4366,7 @@ if (!preedit_string || !*preedit_string) { LOGIM(("preedit ended\n")); - window->IMEComposeText(NULL, 0, NULL, NULL); + window->IMEComposeText(NULL, 0, NULL, 0, NULL); window->IMEComposeEnd(); return; } @@ -4357,7 +4390,7 @@ if (uniStrLen) { window->IMEComposeText(NS_STATIC_CAST(const PRUnichar *, uniStr), - uniStrLen, preedit_string, feedback_list); + uniStrLen, preedit_string, cursor_pos, feedback_list); } g_free(preedit_string); @@ -4418,7 +4451,7 @@ if (uniStrLen) { window->IMEComposeText((const PRUnichar *)uniStr, - (PRInt32)uniStrLen, NULL, NULL); + (PRInt32)uniStrLen, NULL, 0, NULL); window->IMEComposeEnd(); } @@ -4437,6 +4470,7 @@ void IM_set_text_range(const PRInt32 aLen, const gchar *aPreeditString, + const gint aCursorPos, const PangoAttrList *aFeedback, PRUint32 *aTextRangeListLengthResult, nsTextRangeArray *aTextRangeListResult) @@ -4466,8 +4500,8 @@ // Set caret's postion SET_FEEDBACKTYPE(0, NS_TEXTRANGE_CARETPOSITION); - START_OFFSET(0) = aLen; - END_OFFSET(0) = aLen; + START_OFFSET(0) = aCursorPos; + END_OFFSET(0) = aCursorPos; int count = 0; PangoAttribute * aPangoAttr; diff -Nur mozilla-bak/widget/src/gtk2/nsWindow.h mozilla/widget/src/gtk2/nsWindow.h --- mozilla-bak/widget/src/gtk2/nsWindow.h 2004-11-03 22:20:19.107773128 +0900 +++ mozilla/widget/src/gtk2/nsWindow.h 2004-11-03 22:38:57.522748208 +0900 @@ -260,6 +260,7 @@ void IMEComposeText (const PRUnichar *aText, const PRInt32 aLen, const gchar *aPreeditString, + const gint aCursorPos, const PangoAttrList *aFeedback); void IMEComposeEnd (void); GtkIMContext* IMEGetContext (void);