< prev index next >

src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -63,10 +63,11 @@
     private boolean open; //default open status;
     private int cmode;    //default conversion mode;
     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;
     public static final byte ATTR_TARGET_CONVERTED      = 0x01;
     public static final byte ATTR_CONVERTED             = 0x02;

@@ -244,10 +245,11 @@
                 setConversionStatus(context, newmode);
             }
         } 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
                     || subset1 == UnicodeBlock.HANGUL_SYLLABLES
                     || subset1 == UnicodeBlock.HANGUL_JAMO

@@ -261,15 +263,18 @@
                 setConversionStatus(context, newmode);
             }
         } 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
                     return;
                 setOpenStatus(context, true);

@@ -316,10 +321,19 @@
         isActive = true;
         if (currentLocale != null) {
             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
            the user turns it on through Windows Control Panel. See details
            from bug 6252674.

@@ -343,10 +357,11 @@
         if (awtFocussedComponentPeer != null) {
             lastFocussedComponentPeer = awtFocussedComponentPeer;
             isLastFocussedActiveClient = haveActiveClient();
         }
         isActive = false;
+        hasCompositionString = isCompositionStringAvailable(context);
     }
 
     /**
      * Explicitly disable the native IME. Native IME is not disabled when
      * deactivate is called.

@@ -647,6 +662,7 @@
     private native void setStatusWindowVisible(WComponentPeer peer, boolean visible);
     private native String getNativeIMMDescription();
     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);
 }
< prev index next >