11/*
2- * Copyright (c) 1997, 2017 , 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
@@ -62,6 +62,7 @@ final class WInputMethod extends InputMethodAdapter
6262 private Locale currentLocale ;
6363 // indicate whether status window is hidden or not.
6464 private boolean statusWindowHidden = false ;
65+ private boolean hasCompositionString = false ;
6566
6667 // attribute definition in Win32 (in IMM.H)
6768 public final static byte ATTR_INPUT = 0x00 ;
@@ -241,6 +242,7 @@ else if (subset1 == InputSubset.FULLWIDTH_LATIN)
241242 } else if (locale .getLanguage ().equals (Locale .KOREAN .getLanguage ())) {
242243 if (subset1 == UnicodeBlock .BASIC_LATIN || subset1 == InputSubset .LATIN_DIGITS ) {
243244 setOpenStatus (context , false );
245+ setConversionStatus (context , IME_CMODE_ALPHANUMERIC );
244246 } else {
245247 if (subset1 == UnicodeBlock .CJK_UNIFIED_IDEOGRAPHS
246248 || subset1 == InputSubset .HANJA
@@ -258,11 +260,14 @@ else if (subset1 == InputSubset.FULLWIDTH_LATIN)
258260 } else if (locale .getLanguage ().equals (Locale .CHINESE .getLanguage ())) {
259261 if (subset1 == UnicodeBlock .BASIC_LATIN || subset1 == InputSubset .LATIN_DIGITS ) {
260262 setOpenStatus (context , false );
263+ newmode = getConversionStatus (context );
264+ newmode &= ~IME_CMODE_FULLSHAPE ;
265+ setConversionStatus (context , newmode );
261266 } else {
262267 if (subset1 == UnicodeBlock .CJK_UNIFIED_IDEOGRAPHS
263268 || subset1 == InputSubset .TRADITIONAL_HANZI
264269 || subset1 == InputSubset .SIMPLIFIED_HANZI )
265- newmode = IME_CMODE_NATIVE ;
270+ newmode = IME_CMODE_NATIVE | IME_CMODE_FULLSHAPE ;
266271 else if (subset1 == InputSubset .FULLWIDTH_LATIN )
267272 newmode = IME_CMODE_FULLSHAPE ;
268273 else
@@ -313,6 +318,15 @@ public void activate() {
313318 setLocale (currentLocale , true );
314319 }
315320
321+ // Compare IM's composition string with Java's composition string
322+ if (hasCompositionString && !isCompositionStringAvailable (context )) {
323+ endCompositionNative (context , DISCARD_INPUT );
324+ sendInputMethodEvent (InputMethodEvent .INPUT_METHOD_TEXT_CHANGED ,
325+ EventQueue .getMostRecentEventTime (),
326+ null , null , null , null , null , 0 , 0 , 0 );
327+ hasCompositionString = false ;
328+ }
329+
316330 /* If the status window or Windows language bar is turned off due to
317331 native input method was switched to java input method, we
318332 have to turn it on otherwise it is gone for good until next time
@@ -340,6 +354,7 @@ public void deactivate(boolean isTemporary)
340354 isLastFocussedActiveClient = haveActiveClient ();
341355 }
342356 isActive = false ;
357+ hasCompositionString = isCompositionStringAvailable (context );
343358 }
344359
345360 /**
@@ -644,4 +659,5 @@ private WComponentPeer getNearestNativePeer(Component comp)
644659 static native Locale getNativeLocale ();
645660 static native boolean setNativeLocale (String localeName , boolean onActivate );
646661 private native void openCandidateWindow (WComponentPeer peer , int x , int y );
662+ private native boolean isCompositionStringAvailable (int context );
647663}
0 commit comments