https://git.reactos.org/?p=reactos.git;a=commitdiff;h=60be15ff5db10b1e54717…
commit 60be15ff5db10b1e54717b6c28579fd437afdf93
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Aug 16 08:00:47 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Aug 16 08:00:47 2022 +0900
[USER32] RealDefWindowProcA/W WM_IME_SYSTEM handling (#4607)
- Add WM_IME_SYSTEM message handling on RealDefWindowProcA and RealDefWindowProcW
functions.
- Improve WM_IME_... messages handling.
- s/IMMGWL_IMC/IMMGWLP_IMC/
- Don't set IMMGWLP_IMC value to the default IME window.
CORE-11700
---
win32ss/user/user32/misc/imm.c | 6 +--
win32ss/user/user32/windows/defwnd.c | 90 ++++++++++++++++++++----------------
2 files changed, 53 insertions(+), 43 deletions(-)
diff --git a/win32ss/user/user32/misc/imm.c b/win32ss/user/user32/misc/imm.c
index 2f1a1227b18..0433e3cff0c 100644
--- a/win32ss/user/user32/misc/imm.c
+++ b/win32ss/user/user32/misc/imm.c
@@ -331,7 +331,7 @@ static HWND User32CreateImeUIWindow(PIMEUI pimeui, HKL hKL)
}
if (hwndUI)
- NtUserSetWindowLong(hwndUI, IMMGWL_IMC, (LONG_PTR)pimeui->hIMC, FALSE);
+ NtUserSetWindowLong(hwndUI, IMMGWLP_IMC, (LONG_PTR)pimeui->hIMC, FALSE);
Quit:
IMM_FN(ImmUnlockImeDpi)(pImeDpi);
@@ -935,9 +935,8 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
BOOL unicod
return DefWindowProcA(hwnd, msg, wParam, lParam);
}
NtUserSetWindowFNID(hwnd, FNID_IME);
- pimeui = HeapAlloc( GetProcessHeap(), 0, sizeof(IMEUI) );
+ pimeui = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMEUI));
pimeui->spwnd = pWnd;
- SetWindowLongPtrW(hwnd, IMMGWLP_IMC, (LONG_PTR)pimeui);
}
else
{
@@ -1004,7 +1003,6 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
BOOL unicod
case WM_NCDESTROY:
HeapFree(GetProcessHeap(), 0, pimeui);
- SetWindowLongPtrW(hwnd, IMMGWLP_IMC, 0);
NtUserSetWindowFNID(hwnd, FNID_DESTROY);
break;
diff --git a/win32ss/user/user32/windows/defwnd.c b/win32ss/user/user32/windows/defwnd.c
index c6e97e5f704..688f2d48421 100644
--- a/win32ss/user/user32/windows/defwnd.c
+++ b/win32ss/user/user32/windows/defwnd.c
@@ -10,6 +10,7 @@
*/
#include <user32.h>
+#include <ddk/immdev.h>
WINE_DEFAULT_DEBUG_CHANNEL(user32);
@@ -830,7 +831,6 @@ RealDefWindowProcA(HWND hWnd,
switch (Msg)
{
case WM_NCCREATE:
- {
if ( Wnd &&
Wnd->style & (WS_HSCROLL | WS_VSCROLL) )
{
@@ -854,7 +854,6 @@ RealDefWindowProcA(HWND hWnd,
Result = 1;
}
break;
- }
case WM_GETTEXTLENGTH:
{
@@ -926,24 +925,18 @@ RealDefWindowProcA(HWND hWnd,
}
case WM_IME_KEYDOWN:
- {
Result = PostMessageA(hWnd, WM_KEYDOWN, wParam, lParam);
break;
- }
case WM_IME_KEYUP:
- {
Result = PostMessageA(hWnd, WM_KEYUP, wParam, lParam);
break;
- }
case WM_IME_CHAR:
- {
if (HIBYTE(wParam))
PostMessageA(hWnd, WM_CHAR, HIBYTE(wParam), lParam);
PostMessageA(hWnd, WM_CHAR, LOBYTE(wParam), lParam);
break;
- }
case WM_IME_COMPOSITION:
if (lParam & GCS_RESULTSTR)
@@ -987,26 +980,40 @@ RealDefWindowProcA(HWND hWnd,
case WM_IME_SELECT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
+ case WM_IME_SETCONTEXT:
+NormalImeMsgHandling:
{
HWND hwndIME;
+ if (GetWin32ClientInfo()->dwTIFlags & TIF_DISABLEIME)
+ {
+ TRACE("This thread's IME is disabled\n");
+ break;
+ }
+
hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
- if (hwndIME)
- Result = SendMessageA(hwndIME, Msg, wParam, lParam);
- break;
- }
+ if (!hwndIME)
+ {
+ ERR("hwndIME was NULL\n");
+ break;
+ }
- case WM_IME_SETCONTEXT:
- {
- HWND hwndIME;
+ if (hwndIME == hWnd)
+ {
+ ImeWndProc_common(hwndIME, Msg, wParam, lParam, FALSE);
+ break;
+ }
- hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
- if (hwndIME)
- Result = SendMessageA(hwndIME, Msg, wParam, lParam);
+ Result = SendMessageA(hwndIME, Msg, wParam, lParam);
break;
}
- /* fall through */
+ case WM_IME_SYSTEM:
+ if (wParam == 4)
+ break;
+
+ goto NormalImeMsgHandling;
+
default:
Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, FALSE);
}
@@ -1038,7 +1045,6 @@ RealDefWindowProcW(HWND hWnd,
switch (Msg)
{
case WM_NCCREATE:
- {
if ( Wnd &&
Wnd->style & (WS_HSCROLL | WS_VSCROLL) )
{
@@ -1064,7 +1070,6 @@ RealDefWindowProcW(HWND hWnd,
Result = 1;
}
break;
- }
case WM_GETTEXTLENGTH:
{
@@ -1117,33 +1122,25 @@ RealDefWindowProcW(HWND hWnd,
}
case WM_SETTEXT:
- {
DefSetText(hWnd, (PCWSTR)lParam, FALSE);
if ((GetWindowLongPtrW(hWnd, GWL_STYLE) & WS_CAPTION) == WS_CAPTION)
UserPaintCaption(Wnd, DC_TEXT);
Result = 1;
break;
- }
case WM_IME_CHAR:
- {
PostMessageW(hWnd, WM_CHAR, wParam, lParam);
Result = 0;
break;
- }
case WM_IME_KEYDOWN:
- {
Result = PostMessageW(hWnd, WM_KEYDOWN, wParam, lParam);
break;
- }
case WM_IME_KEYUP:
- {
Result = PostMessageW(hWnd, WM_KEYUP, wParam, lParam);
break;
- }
case WM_IME_COMPOSITION:
if (lParam & GCS_RESULTSTR)
@@ -1172,25 +1169,40 @@ RealDefWindowProcW(HWND hWnd,
case WM_IME_SELECT:
case WM_IME_NOTIFY:
case WM_IME_CONTROL:
+ case WM_IME_SETCONTEXT:
+NormalImeMsgHandling:
{
HWND hwndIME;
+ if (GetWin32ClientInfo()->dwTIFlags & TIF_DISABLEIME)
+ {
+ TRACE("This thread's IME is disabled\n");
+ break;
+ }
+
hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
- if (hwndIME)
- Result = SendMessageW(hwndIME, Msg, wParam, lParam);
- break;
- }
+ if (!hwndIME)
+ {
+ ERR("hwndIME was NULL\n");
+ break;
+ }
- case WM_IME_SETCONTEXT:
- {
- HWND hwndIME;
+ if (hwndIME == hWnd)
+ {
+ ImeWndProc_common(hwndIME, Msg, wParam, lParam, TRUE);
+ break;
+ }
- hwndIME = IMM_FN(ImmGetDefaultIMEWnd)(hWnd);
- if (hwndIME)
- Result = SendMessageW(hwndIME, Msg, wParam, lParam);
+ Result = SendMessageW(hwndIME, Msg, wParam, lParam);
break;
}
+ case WM_IME_SYSTEM:
+ if (wParam == 4)
+ break;
+
+ goto NormalImeMsgHandling;
+
default:
Result = User32DefWindowProc(hWnd, Msg, wParam, lParam, TRUE);
}