--- old/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java 2018-06-13 18:08:13.495896000 +0900 +++ new/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java 2018-06-13 18:08:13.136520400 +0900 @@ -65,6 +65,7 @@ private Locale currentLocale; // indicate whether status window is hidden or not. private boolean statusWindowHidden = false; + private boolean hasCompositionString = false; // attribute definition in Win32 (in IMM.H) public static final byte ATTR_INPUT = 0x00; @@ -246,6 +247,7 @@ } else if (locale.getLanguage().equals(Locale.KOREAN.getLanguage())) { if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) { setOpenStatus(context, false); + setConversionStatus(context, IME_CMODE_ALPHANUMERIC); } else { if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || subset1 == InputSubset.HANJA @@ -263,11 +265,14 @@ } else if (locale.getLanguage().equals(Locale.CHINESE.getLanguage())) { if (subset1 == UnicodeBlock.BASIC_LATIN || subset1 == InputSubset.LATIN_DIGITS) { setOpenStatus(context, false); + newmode = getConversionStatus(context); + newmode &= ~IME_CMODE_FULLSHAPE; + setConversionStatus(context, newmode); } else { if (subset1 == UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || subset1 == InputSubset.TRADITIONAL_HANZI || subset1 == InputSubset.SIMPLIFIED_HANZI) - newmode = IME_CMODE_NATIVE; + newmode = IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE; else if (subset1 == InputSubset.FULLWIDTH_LATIN) newmode = IME_CMODE_FULLSHAPE; else @@ -318,6 +323,15 @@ setLocale(currentLocale, true); } + // Compare IM's composition string with Java's composition string + if (hasCompositionString && !isCompositionStringAvailable(context)) { + endCompositionNative(context, DISCARD_INPUT); + sendInputMethodEvent(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, + EventQueue.getMostRecentEventTime(), + null, null, null, null, null, 0, 0, 0); + hasCompositionString = false; + } + /* If the status window or Windows language bar is turned off due to native input method was switched to java input method, we have to turn it on otherwise it is gone for good until next time @@ -345,6 +359,7 @@ isLastFocussedActiveClient = haveActiveClient(); } isActive = false; + hasCompositionString = isCompositionStringAvailable(context); } /** @@ -649,4 +664,5 @@ static native Locale getNativeLocale(); static native boolean setNativeLocale(String localeName, boolean onActivate); private native void openCandidateWindow(WComponentPeer peer, int x, int y); + private native boolean isCompositionStringAvailable(int context); } --- old/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp 2018-06-13 18:08:14.370894800 +0900 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp 2018-06-13 18:08:14.027150300 +0900 @@ -3872,6 +3872,11 @@ return; } COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}}; + LOGFONT lf; + HFONT hFont = (HFONT) GetStockObject(DEFAULT_GUI_FONT); + if (GetObject(hFont, sizeof(lf), (LPVOID)&lf) == sizeof(lf)) { + ImmSetCompositionFont(hIMC, &lf); + } ImmSetCompositionWindow(hIMC, &cf); ImmReleaseContext(hwnd, hIMC); } --- old/src/java.desktop/windows/native/libawt/windows/awt_InputMethod.cpp 2018-06-13 18:08:15.527150100 +0900 +++ new/src/java.desktop/windows/native/libawt/windows/awt_InputMethod.cpp 2018-06-13 18:08:15.183394600 +0900 @@ -528,6 +528,23 @@ CATCH_BAD_ALLOC_RET(NULL); } +/* + * Class: sun_awt_windows_WInputMethod + * Method: isCompositionStringAvailable + * Signature: (I)Z + */ +JNIEXPORT jboolean JNICALL Java_sun_awt_windows_WInputMethod_isCompositionStringAvailable + (JNIEnv *env, jobject self, jint context) +{ + LONG length; + length = ImmGetCompositionString((HIMC)IntToPtr(context), GCS_COMPSTR, NULL, 0); + if (length > 0) { + return JNI_TRUE; + } else { + return JNI_FALSE; + } +} + /** * Class: sun_awt_windows_WInputMethod * Method: getNativeIMMDescription