changeset 5561:89e41f057bd9

RT-33880: Win: Input method window is positioned incorrectly Reviewed-by: anthony, art
author Petr Pchelko <petr.pchelko@oracle.com>
date Tue, 29 Oct 2013 17:17:42 +0400
parents ca4ad7f14aeb
children 52c8add4d3ba
files modules/graphics/src/main/native-glass/win/ViewContainer.cpp modules/graphics/src/main/native-glass/win/ViewContainer.h
diffstat 2 files changed, 10 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/win/ViewContainer.cpp	Tue Oct 29 08:15:51 2013 -0400
+++ b/modules/graphics/src/main/native-glass/win/ViewContainer.cpp	Tue Oct 29 17:17:42 2013 +0400
@@ -731,22 +731,22 @@
 {
     if (wParam == IMN_OPENCANDIDATE) {
         JNIEnv *env = GetEnv();
-        RECT curPos;
-        RECT winPos;
+        POINT curPos;
         UINT bits = 1;
         HIMC hIMC = ImmGetContext(hwnd);
         CANDIDATEFORM cf;
 
-        GetWindowRect(hwnd, &winPos);        
         GetCandidatePos(&curPos);
+        ::ScreenToClient(hwnd, &curPos);
 
         for (int iCandType=0; iCandType<32; iCandType++, bits<<=1) {
             if (lParam & bits) {
                 cf.dwIndex = iCandType;
                 cf.dwStyle = CFS_CANDIDATEPOS;
-                cf.ptCurrentPos.x = curPos.left - winPos.left;
-                cf.ptCurrentPos.y = curPos.top - winPos.top;
-                ImmSetCandidateWindow(hIMC, &cf);
+                // The constant offset is needed because Windows is moving the IM window
+                cf.ptCurrentPos.x = curPos.x - 6;
+                cf.ptCurrentPos.y = curPos.y - 15;
+                ::ImmSetCandidateWindow(hIMC, &cf);
             }
         }
         ImmReleaseContext(hwnd, hIMC);
@@ -803,7 +803,7 @@
 }
 
 // Gets the candidate position
-void ViewContainer::GetCandidatePos(RECT* curPos) 
+void ViewContainer::GetCandidatePos(LPPOINT curPos)
 {
     JNIEnv *env = GetEnv();
     double* nativePos; 
@@ -813,8 +813,8 @@
                         0);
     nativePos = env->GetDoubleArrayElements(pos, NULL);
 
-    curPos->left = (int)nativePos[0];
-    curPos->top  = (int)nativePos[1];
+    curPos->x = (int)nativePos[0];
+    curPos->y  = (int)nativePos[1];
 
     env->ReleaseDoubleArrayElements(pos, nativePos, 0);
 }
--- a/modules/graphics/src/main/native-glass/win/ViewContainer.h	Tue Oct 29 08:15:51 2013 -0400
+++ b/modules/graphics/src/main/native-glass/win/ViewContainer.h	Tue Oct 29 17:17:42 2013 +0400
@@ -52,7 +52,7 @@
             int cClause, int* rgClauseBoundary,
             int cAttrBlock, int* rgAttrBoundary, BYTE *rgAttrValue,
             int commitedTextLength, int caretPos, int visiblePos);
-        void GetCandidatePos(RECT* curPos);
+        void GetCandidatePos(LPPOINT curPos);
 
     protected:
         void HandleViewMenuEvent(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);