From 7ebe8fa0fa56cacdb9c82ec43616f987ab04fcc1 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Tue, 14 Feb 2017 15:47:58 +0300 Subject: [PATCH] 8163979: [macosx] Chinese text shows as Latin w/ openVanilla input method Reviewed-by: prr, serb --- .../lwawt/macosx/CInputMethodDescriptor.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java index 3deba1e33f9..891972ff130 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethodDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2017, 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 @@ -57,15 +57,19 @@ public class CInputMethodDescriptor implements InputMethodDescriptor { } static Object[] getAvailableLocalesInternal() { - List workList = nativeGetAvailableLocales(); + List workList = nativeGetAvailableLocales(); + Locale currentLocale = CInputMethod.getNativeLocale(); - if (workList != null) { + if (workList == null || workList.isEmpty()) { + return new Object[] { + currentLocale != null ? currentLocale : Locale.getDefault() + }; + } else { + if (currentLocale != null && !workList.contains(currentLocale)) { + workList.add(currentLocale); + } return workList.toArray(); } - - return new Object[] { - Locale.getDefault() - }; } /** @@ -119,5 +123,5 @@ public class CInputMethodDescriptor implements InputMethodDescriptor { } private static native void nativeInit(); - private static native List nativeGetAvailableLocales(); + private static native List nativeGetAvailableLocales(); }