imm32: Change the default IME window to better reflect applications request

Aric Stewart aric at codeweavers.com
Mon Mar 26 14:51:40 CDT 2007


First part of this change was proposed by Byeong-Sik Jeon 
<wjsqudtlr at gmail.com>
Use a tooltip window instead to avoid stealing focus from the application.
Additionally respect parameters give to us by ImmSetCompositionWindow 
for placement of the composition window.
---
  dlls/imm32/imm.c |   43 +++++++++++++++++++++++++++++++++++++------
  1 files changed, 37 insertions(+), 6 deletions(-)
-------------- next part --------------
diff --git a/dlls/imm32/imm.c b/dlls/imm32/imm.c
index 02a362e..0aa28f0 100644
--- a/dlls/imm32/imm.c
+++ b/dlls/imm32/imm.c
@@ -763,8 +763,8 @@ HWND WINAPI ImmGetDefaultIMEWnd(HWND hWn
         static const WCHAR the_name[] = {'I','M','E','\0'};
 
         IMM_Register();
-        hwndDefault = CreateWindowExW( WS_EX_CLIENTEDGE, WC_IMECLASSNAME,
-                the_name, WS_POPUPWINDOW|WS_CAPTION, 0, 0, 120, 55, 0, 0,
+        hwndDefault = CreateWindowExW( WS_EX_TOOLWINDOW, WC_IMECLASSNAME,
+                the_name, WS_POPUP, 0, 0, 1, 1, 0, 0,
                 hImeInst, 0);
 
         TRACE("Default created (%p)\n",hwndDefault);
@@ -1556,6 +1556,7 @@ static void PaintDefaultIMEWnd(HWND hwnd
     RECT rect;
     HDC hdc = BeginPaint(hwnd,&ps);
     GetClientRect(hwnd,&rect);
+    FillRect(hdc, &rect, (HBRUSH)(COLOR_WINDOW + 1));
 
     if (root_context->dwCompStringLength && root_context->CompositionString)
     {
@@ -1566,8 +1567,6 @@ static void PaintDefaultIMEWnd(HWND hwnd
         if (root_context->textfont)
             oldfont = SelectObject(hdc,root_context->textfont);
 
-        TextOutW(hdc, 0,0,(LPWSTR)root_context->CompositionString,
-                 root_context->dwCompStringLength / sizeof(WCHAR));
 
         GetTextExtentPoint32W(hdc, (LPWSTR)root_context->CompositionString,
                               root_context->dwCompStringLength / sizeof(WCHAR),
@@ -1575,12 +1574,44 @@ static void PaintDefaultIMEWnd(HWND hwnd
         pt.x = size.cx;
         pt.y = size.cy;
         LPtoDP(hdc,&pt,1);
-        rect.left = pt.x;
+
+        if (root_context->CompForm.dwStyle == CFS_POINT ||
+            root_context->CompForm.dwStyle == CFS_FORCE_POSITION)
+        {
+            POINT cpt = root_context->CompForm.ptCurrentPos;
+            ClientToScreen(root_context->hwnd,&cpt);
+            rect.left = cpt.x;
+            rect.top = cpt.y;
+            rect.right = rect.left + pt.x + 20;
+            rect.bottom = rect.top + pt.y + 20;
+        }
+        else if (root_context->CompForm.dwStyle == CFS_RECT)
+        {
+            POINT cpt;
+            cpt.x = root_context->CompForm.rcArea.left;
+            cpt.y = root_context->CompForm.rcArea.top;
+            ClientToScreen(root_context->hwnd,&cpt);
+            rect.left = cpt.x;
+            rect.top = cpt.y;
+            cpt.x = root_context->CompForm.rcArea.right;
+            cpt.y = root_context->CompForm.rcArea.bottom;
+            ClientToScreen(root_context->hwnd,&cpt);
+            rect.right = cpt.x;
+            rect.bottom = cpt.y;
+        }
+        else
+        {
+            rect.right = rect.left + pt.x + 20;
+            rect.bottom = rect.top + pt.y + 20;
+        }
+        MoveWindow(hwnd, rect.left, rect.top, rect.right - rect.left ,
+                   rect.bottom - rect.top, FALSE);
+        TextOutW(hdc, 10,10,(LPWSTR)root_context->CompositionString,
+                 root_context->dwCompStringLength / sizeof(WCHAR));
 
         if (oldfont)
             SelectObject(hdc,oldfont);
     }
-    FillRect(hdc,&rect, (HBRUSH) (COLOR_WINDOW+1));
     EndPaint(hwnd,&ps);
 }
 


More information about the wine-patches mailing list