1 /*
2 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
3794 }
3795
3796 // support IME Composition messages
3797 void AwtComponent::SetCompositionWindow(RECT& r)
3798 {
3799 HWND hwnd = ImmGetHWnd();
3800 HIMC hIMC = ImmGetContext(hwnd);
3801 if (hIMC == NULL) {
3802 return;
3803 }
3804 COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
3805 ImmSetCompositionWindow(hIMC, &cf);
3806 ImmReleaseContext(hwnd, hIMC);
3807 }
3808
3809 void AwtComponent::OpenCandidateWindow(int x, int y)
3810 {
3811 UINT bits = 1;
3812 POINT p = {0, 0}; // upper left corner of the client area
3813 HWND hWnd = GetHWnd();
3814 HWND hTop = GetTopLevelParentForWindow(hWnd);
3815 ::ClientToScreen(hTop, &p);
3816 if (!m_bitsCandType) {
3817 SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
3818 return;
3819 }
3820 for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
3821 if ( m_bitsCandType & bits )
3822 SetCandidateWindow(iCandType, x - p.x, y - p.y);
3823 }
3824 if (m_bitsCandType != 0) {
3825 // REMIND: is there any chance GetProxyFocusOwner() returns NULL here?
3826 ::DefWindowProc(ImmGetHWnd(),
3827 WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType);
3828 }
3829 }
3830
3831 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
3832 {
3833 HWND hwnd = ImmGetHWnd();
4066 DASSERT(sendIMEventMid);
4067 CHECK_NULL(sendIMEventMid);
4068 }
4069
4070 // call m_InputMethod.sendInputMethod()
4071 env->CallVoidMethod(m_InputMethod, sendIMEventMid, id, ::JVM_CurrentTimeMillis(NULL, 0),
4072 text, clauseBoundary, clauseReading, attrBoundary,
4073 attrValue, commitedTextLength, caretPos, visiblePos);
4074 if (safe_ExceptionOccurred(env)) env->ExceptionDescribe();
4075 DASSERT(!safe_ExceptionOccurred(env));
4076
4077 }
4078
4079
4080
4081 //
4082 // Inquires candidate position according to the composed text
4083 //
4084 void AwtComponent::InquireCandidatePosition()
4085 {
4086 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4087
4088 // get global reference of WInputMethod class (run only once)
4089 static jclass wInputMethodCls = NULL;
4090 if (wInputMethodCls == NULL) {
4091 jclass wInputMethodClsLocal = env->FindClass("sun/awt/windows/WInputMethod");
4092 DASSERT(wInputMethodClsLocal);
4093 CHECK_NULL(wInputMethodClsLocal);
4094 wInputMethodCls = (jclass)env->NewGlobalRef(wInputMethodClsLocal);
4095 env->DeleteLocalRef(wInputMethodClsLocal);
4096 }
4097
4098 // get method ID of sendInputMethodEvent() (run only once)
4099 static jmethodID inqCandPosMid = 0;
4100 if (inqCandPosMid == 0) {
4101 inqCandPosMid = env->GetMethodID(wInputMethodCls, "inquireCandidatePosition", "()V");
4102 DASSERT(!safe_ExceptionOccurred(env));
4103 DASSERT(inqCandPosMid);
4104 CHECK_NULL(inqCandPosMid);
4105 }
|
1 /*
2 * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
3794 }
3795
3796 // support IME Composition messages
3797 void AwtComponent::SetCompositionWindow(RECT& r)
3798 {
3799 HWND hwnd = ImmGetHWnd();
3800 HIMC hIMC = ImmGetContext(hwnd);
3801 if (hIMC == NULL) {
3802 return;
3803 }
3804 COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
3805 ImmSetCompositionWindow(hIMC, &cf);
3806 ImmReleaseContext(hwnd, hIMC);
3807 }
3808
3809 void AwtComponent::OpenCandidateWindow(int x, int y)
3810 {
3811 UINT bits = 1;
3812 POINT p = {0, 0}; // upper left corner of the client area
3813 HWND hWnd = GetHWnd();
3814 if (!::IsWindowVisible(hWnd)) {
3815 return;
3816 }
3817 HWND hTop = GetTopLevelParentForWindow(hWnd);
3818 ::ClientToScreen(hTop, &p);
3819 if (!m_bitsCandType) {
3820 SetCandidateWindow(m_bitsCandType, x - p.x, y - p.y);
3821 return;
3822 }
3823 for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
3824 if ( m_bitsCandType & bits )
3825 SetCandidateWindow(iCandType, x - p.x, y - p.y);
3826 }
3827 if (m_bitsCandType != 0) {
3828 // REMIND: is there any chance GetProxyFocusOwner() returns NULL here?
3829 ::DefWindowProc(ImmGetHWnd(),
3830 WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType);
3831 }
3832 }
3833
3834 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
3835 {
3836 HWND hwnd = ImmGetHWnd();
4069 DASSERT(sendIMEventMid);
4070 CHECK_NULL(sendIMEventMid);
4071 }
4072
4073 // call m_InputMethod.sendInputMethod()
4074 env->CallVoidMethod(m_InputMethod, sendIMEventMid, id, ::JVM_CurrentTimeMillis(NULL, 0),
4075 text, clauseBoundary, clauseReading, attrBoundary,
4076 attrValue, commitedTextLength, caretPos, visiblePos);
4077 if (safe_ExceptionOccurred(env)) env->ExceptionDescribe();
4078 DASSERT(!safe_ExceptionOccurred(env));
4079
4080 }
4081
4082
4083
4084 //
4085 // Inquires candidate position according to the composed text
4086 //
4087 void AwtComponent::InquireCandidatePosition()
4088 {
4089 if (!::IsWindowVisible(GetHWnd())) {
4090 return;
4091 }
4092 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4093
4094 // get global reference of WInputMethod class (run only once)
4095 static jclass wInputMethodCls = NULL;
4096 if (wInputMethodCls == NULL) {
4097 jclass wInputMethodClsLocal = env->FindClass("sun/awt/windows/WInputMethod");
4098 DASSERT(wInputMethodClsLocal);
4099 CHECK_NULL(wInputMethodClsLocal);
4100 wInputMethodCls = (jclass)env->NewGlobalRef(wInputMethodClsLocal);
4101 env->DeleteLocalRef(wInputMethodClsLocal);
4102 }
4103
4104 // get method ID of sendInputMethodEvent() (run only once)
4105 static jmethodID inqCandPosMid = 0;
4106 if (inqCandPosMid == 0) {
4107 inqCandPosMid = env->GetMethodID(wInputMethodCls, "inquireCandidatePosition", "()V");
4108 DASSERT(!safe_ExceptionOccurred(env));
4109 DASSERT(inqCandPosMid);
4110 CHECK_NULL(inqCandPosMid);
4111 }
|