src/windows/native/sun/windows/awt_Component.cpp

Print this page

        

@@ -1470,13 +1470,11 @@
           // fix 4128317 : use GetClientRect for full 32-bit int precision and
           // to avoid negative client area dimensions overflowing 16-bit params - robi
           ::GetClientRect( GetHWnd(), &r );
           mr = WmSize(static_cast<UINT>(wParam), r.right - r.left, r.bottom - r.top);
           //mr = WmSize(wParam, LOWORD(lParam), HIWORD(lParam));
-          if (ImmGetContext() != NULL) {
               SetCompositionWindow(r);
-          }
           break;
       }
       case WM_SIZING:
           mr = WmSizing();
           break;

@@ -1531,11 +1529,14 @@
               mr = WmActivate(nState, fMinimized, (HWND)lParam);
 
               // When the window is deactivated, send WM_IME_ENDCOMPOSITION
               // message to deactivate the composition window so that
               // it won't receive keyboard input focus.
-              if (ImmGetContext() != NULL) {
+              HIMC hIMC;
+              HWND hwnd = ImmGetHWnd();
+              if ((hIMC = ImmGetContext(hwnd)) != NULL) {
+                  ImmReleaseContext(hwnd, hIMC);
                   DefWindowProc(WM_IME_ENDCOMPOSITION, 0, 0);
               }
           }
           break;
       }

@@ -1714,15 +1715,13 @@
                        LOWORD(lParam), HIWORD(lParam), TRUE);
           break;
       case WM_IME_SETCONTEXT:
           // lParam is passed as pointer and it can be modified.
           mr = WmImeSetContext(static_cast<BOOL>(wParam), &lParam);
-          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
           break;
       case WM_IME_NOTIFY:
           mr = WmImeNotify(wParam, lParam);
-          CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
           break;
       case WM_IME_STARTCOMPOSITION:
           mr = WmImeStartComposition();
           CallProxyDefWindowProc(message, wParam, lParam, retValue, mr);
           break;

@@ -3719,16 +3718,18 @@
 }
 
 // support IME Composition messages
 void AwtComponent::SetCompositionWindow(RECT& r)
 {
-    HIMC hIMC = ImmGetContext();
+    HWND hwnd = ImmGetHWnd();
+    HIMC hIMC = ImmGetContext(hwnd);
     if (hIMC == NULL) {
         return;
     }
     COMPOSITIONFORM cf = {CFS_DEFAULT, {0, 0}, {0, 0, 0, 0}};
     ImmSetCompositionWindow(hIMC, &cf);
+    ImmReleaseContext(hwnd, hIMC);
 }
 
 void AwtComponent::OpenCandidateWindow(int x, int y)
 {
     UINT bits = 1;

@@ -3738,34 +3739,38 @@
     for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
         if ( m_bitsCandType & bits )
             SetCandidateWindow(iCandType, x-rc.left, y-rc.top);
     }
     if (m_bitsCandType != 0) {
-        HWND proxy = GetProxyFocusOwner();
         // REMIND: is there any chance GetProxyFocusOwner() returns NULL here?
-        ::DefWindowProc((proxy != NULL) ? proxy : GetHWnd(),
+        ::DefWindowProc(ImmGetHWnd(),
                         WM_IME_NOTIFY, IMN_OPENCANDIDATE, m_bitsCandType);
     }
 }
 
 void AwtComponent::SetCandidateWindow(int iCandType, int x, int y)
 {
-    HIMC hIMC = ImmGetContext();
+    HWND hwnd = ImmGetHWnd();
+    HIMC hIMC = ImmGetContext(hwnd);
     CANDIDATEFORM cf;
     cf.dwIndex = iCandType;
     cf.dwStyle = CFS_CANDIDATEPOS;
     cf.ptCurrentPos.x = x;
     cf.ptCurrentPos.y = y;
 
     ImmSetCandidateWindow(hIMC, &cf);
+
+    ImmReleaseContext(hwnd, hIMC);
 }
 
 MsgRouting AwtComponent::WmImeSetContext(BOOL fSet, LPARAM *lplParam)
 {
     // If the Windows input context is disabled, do not let Windows
     // display any UIs.
-    HIMC hIMC = ImmGetContext();
+    HWND hwnd = ImmGetHWnd();
+    HIMC hIMC = ImmGetContext(hwnd);
+    ImmReleaseContext(hwnd, hIMC);
     if (hIMC == NULL) {
         *lplParam = 0;
         return mrDoDefault;
     }
 

@@ -3820,15 +3825,17 @@
     BYTE*     valAttrW = NULL;
     int       cClauseW = 0;
     AwtInputTextInfor* textInfor = NULL;
 
     try {
-        HIMC hIMC = ImmGetContext();
+        HWND hwnd = ImmGetHWnd();
+        HIMC hIMC = ImmGetContext(hwnd);
         DASSERT(hIMC!=0);
 
         textInfor = new AwtInputTextInfor;
         textInfor->GetContextData(hIMC, flags);
+        ImmReleaseContext(hwnd, hIMC);
 
         jstring jtextString = textInfor->GetText();
         /* The conditions to send the input method event to AWT EDT are:
            1. Whenever there is a composition message sent regarding whether
            the composition text is NULL or not. See details at bug 6222692.

@@ -4008,20 +4015,18 @@
     // call m_InputMethod.sendInputMethod()
     jobject candPos = env->CallObjectMethod(m_InputMethod, inqCandPosMid);
     DASSERT(!safe_ExceptionOccurred(env));
 }
 
-HIMC AwtComponent::ImmGetContext()
+HWND AwtComponent::ImmGetHWnd()
 {
-    HWND proxy = GetProxyFocusOwner();
-    return ::ImmGetContext((proxy != NULL) ? proxy : GetHWnd());
+    return GetHWnd();
 }
 
 HIMC AwtComponent::ImmAssociateContext(HIMC himc)
 {
-    HWND proxy = GetProxyFocusOwner();
-    return ::ImmAssociateContext((proxy != NULL) ? proxy : GetHWnd(), himc);
+    return ::ImmAssociateContext(ImmGetHWnd(), himc);
 }
 
 HWND AwtComponent::GetProxyFocusOwner()
 {
     AwtWindow *window = GetContainer();