11/*
2- * Copyright (c) 1997, 2018 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 1997, 2019 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
@@ -65,6 +65,7 @@ final class WInputMethod extends InputMethodAdapter
6565 private Locale currentLocale ;
6666 // indicate whether status window is hidden or not.
6767 private boolean statusWindowHidden = false ;
68+ private boolean hasCompositionString = false ;
6869
6970 // attribute definition in Win32 (in IMM.H)
7071 public static final byte ATTR_INPUT = 0x00 ;
@@ -246,6 +247,7 @@ else if (subset1 == InputSubset.FULLWIDTH_LATIN)
246247 } else if (locale .getLanguage ().equals (Locale .KOREAN .getLanguage ())) {
247248 if (subset1 == UnicodeBlock .BASIC_LATIN || subset1 == InputSubset .LATIN_DIGITS ) {
248249 setOpenStatus (context , false );
250+ setConversionStatus (context , IME_CMODE_ALPHANUMERIC );
249251 } else {
250252 if (subset1 == UnicodeBlock .CJK_UNIFIED_IDEOGRAPHS
251253 || subset1 == InputSubset .HANJA
@@ -263,11 +265,14 @@ else if (subset1 == InputSubset.FULLWIDTH_LATIN)
263265 } else if (locale .getLanguage ().equals (Locale .CHINESE .getLanguage ())) {
264266 if (subset1 == UnicodeBlock .BASIC_LATIN || subset1 == InputSubset .LATIN_DIGITS ) {
265267 setOpenStatus (context , false );
268+ newmode = getConversionStatus (context );
269+ newmode &= ~IME_CMODE_FULLSHAPE ;
270+ setConversionStatus (context , newmode );
266271 } else {
267272 if (subset1 == UnicodeBlock .CJK_UNIFIED_IDEOGRAPHS
268273 || subset1 == InputSubset .TRADITIONAL_HANZI
269274 || subset1 == InputSubset .SIMPLIFIED_HANZI )
270- newmode = IME_CMODE_NATIVE ;
275+ newmode = IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE ;
271276 else if (subset1 == InputSubset .FULLWIDTH_LATIN )
272277 newmode = IME_CMODE_FULLSHAPE ;
273278 else
@@ -318,6 +323,15 @@ public void activate() {
318323 setLocale (currentLocale , true );
319324 }
320325
326+ // Compare IM's composition string with Java's composition string
327+ if (hasCompositionString && !isCompositionStringAvailable (context )) {
328+ endCompositionNative (context , DISCARD_INPUT );
329+ sendInputMethodEvent (InputMethodEvent .INPUT_METHOD_TEXT_CHANGED ,
330+ EventQueue .getMostRecentEventTime (),
331+ null , null , null , null , null , 0 , 0 , 0 );
332+ hasCompositionString = false ;
333+ }
334+
321335 /* If the status window or Windows language bar is turned off due to
322336 native input method was switched to java input method, we
323337 have to turn it on otherwise it is gone for good until next time
@@ -345,6 +359,7 @@ public void deactivate(boolean isTemporary)
345359 isLastFocussedActiveClient = haveActiveClient ();
346360 }
347361 isActive = false ;
362+ hasCompositionString = isCompositionStringAvailable (context );
348363 }
349364
350365 /**
@@ -649,4 +664,5 @@ private WComponentPeer getNearestNativePeer(Component comp)
649664 static native Locale getNativeLocale ();
650665 static native boolean setNativeLocale (String localeName , boolean onActivate );
651666 private native void openCandidateWindow (WComponentPeer peer , int x , int y );
667+ private native boolean isCompositionStringAvailable (int context );
652668}
0 commit comments