Bug 699022 - Inform IM about cursor position when focus changes. r=masayuki
authorXidorn Quan <me@upsuper.org>
Thu, 13 Feb 2020 12:19:05 +0000
changeset 513869 05033a6494caad52ec4c9d6eb1d5cc8afcd0137a
parent 513868 b8d617792e610ec2c08cb6c6b13a72dcb7f60007
child 513870 69154c7cfa4932cfcdfb911d9a1157be08ce0021
push id37124
push usercsabou@mozilla.com
push dateFri, 14 Feb 2020 15:51:24 +0000
treeherdermozilla-central@f8ec5d8b4718 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs699022
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 699022 - Inform IM about cursor position when focus changes. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D62734
widget/gtk/IMContextWrapper.cpp
--- a/widget/gtk/IMContextWrapper.cpp
+++ b/widget/gtk/IMContextWrapper.cpp
@@ -1110,16 +1110,23 @@ void IMContextWrapper::OnFocusChangeInGe
       gGtkIMLog, LogLevel::Info,
       ("0x%p OnFocusChangeInGecko(aFocus=%s), "
        "mCompositionState=%s, mIsIMFocused=%s",
        this, ToChar(aFocus), GetCompositionStateName(), ToChar(mIsIMFocused)));
 
   // We shouldn't carry over the removed string to another editor.
   mSelectedStringRemovedByComposition.Truncate();
   mSelection.Clear();
+
+  // When the focus changes, we need to inform IM about the new cursor
+  // position. Chinese input methods generally rely on this because they
+  // usually don't start composition until a character is picked.
+  if (aFocus && EnsureToCacheSelection()) {
+    SetCursorPosition(GetActiveContext());
+  }
 }
 
 void IMContextWrapper::ResetIME() {
   MOZ_LOG(gGtkIMLog, LogLevel::Info,
           ("0x%p ResetIME(), mCompositionState=%s, mIsIMFocused=%s", this,
            GetCompositionStateName(), ToChar(mIsIMFocused)));
 
   GtkIMContext* activeContext = GetActiveContext();