https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e1f8b32c3d64da4d35070…
commit e1f8b32c3d64da4d35070fa87558e74e0fe48cf6
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Sun Nov 13 09:59:17 2022 +0900
Commit: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
CommitDate: Sun Nov 13 09:59:17 2022 +0900
[INCLUDE][USER32] Add WM_FINALDESTROY and improve ImeWndProcA/W
CORE-11700
---
sdk/include/reactos/undocuser.h | 1 +
win32ss/user/user32/misc/imm.c | 111 ++++++++++++++++++++++------------------
2 files changed, 61 insertions(+), 51 deletions(-)
diff --git a/sdk/include/reactos/undocuser.h b/sdk/include/reactos/undocuser.h
index d742e3a541c..b2bc7a8ccc9 100644
--- a/sdk/include/reactos/undocuser.h
+++ b/sdk/include/reactos/undocuser.h
@@ -36,6 +36,7 @@ extern "C" {
#define WM_COPYGLOBALDATA 0x00000049
#define WM_LOGONNOTIFY 0x0000004C
#define WM_KEYF1 0x0000004D
+#define WM_FINALDESTROY 0x00000070
#define WM_KLUDGEMINRECT 0x0000008B
#define WM_UAHDRAWMENU 0x00000091
#define WM_UAHDRAWITEM 0x00000092 // WM_DRAWITEM
diff --git a/win32ss/user/user32/misc/imm.c b/win32ss/user/user32/misc/imm.c
index 56112afc0ae..cd34d945a1e 100644
--- a/win32ss/user/user32/misc/imm.c
+++ b/win32ss/user/user32/misc/imm.c
@@ -939,42 +939,43 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
BOOL unicod
LRESULT ret;
pWnd = ValidateHwnd(hwnd);
- if (pWnd)
+ if (pWnd == NULL)
{
- if (IS_CICERO_MODE())
+ ERR("hwnd was %p\n", hwnd);
+ return 0;
+ }
+
+ if (!pWnd->fnid)
+ {
+ NtUserSetWindowFNID(hwnd, FNID_IME);
+ }
+ else if (pWnd->fnid != FNID_IME)
+ {
+ ERR("fnid was 0x%x\n", pWnd->fnid);
+ return 0;
+ }
+
+ pimeui = (PIMEUI)GetWindowLongPtrW(hwnd, 0);
+ if (pimeui == NULL)
+ {
+ pimeui = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMEUI));
+ if (pimeui == NULL)
{
- ret = IMM_FN(CtfImmDispatchDefImeMessage)(hwnd, msg, wParam, lParam);
- if (ret)
- return ret;
+ ERR("HeapAlloc failed\n");
+ NtUserSetWindowFNID(hwnd, FNID_DESTROY);
+ DestroyWindow(hwnd);
+ return 0;
}
- if (!pWnd->fnid)
- {
- if (msg != WM_NCCREATE)
- {
- if (unicode)
- return DefWindowProcW(hwnd, msg, wParam, lParam);
- return DefWindowProcA(hwnd, msg, wParam, lParam);
- }
- NtUserSetWindowFNID(hwnd, FNID_IME);
- pimeui = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IMEUI));
- pimeui->spwnd = pWnd;
- SetWindowLongPtrW(hwnd, 0, (LONG_PTR)pimeui);
- }
- else
- {
- if (pWnd->fnid != FNID_IME)
- {
- ERR("Wrong window class for Ime! fnId 0x%x\n",pWnd->fnid);
- return 0;
- }
- pimeui = (PIMEUI)GetWindowLongPtrW(hwnd, 0);
- if (pimeui == NULL)
- {
- ERR("Window is not set to IME!\n");
- return 0;
- }
- }
+ SetWindowLongPtrW(hwnd, 0, (LONG_PTR)pimeui);
+ pimeui->spwnd = pWnd;
+ }
+
+ if (IS_CICERO_MODE())
+ {
+ ret = IMM_FN(CtfImmDispatchDefImeMessage)(hwnd, msg, wParam, lParam);
+ if (ret)
+ return ret;
}
if (pimeui->nCntInIMEProc > 0)
@@ -1011,11 +1012,21 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam, BOOL unicod
break;
default:
- {
- if (unicode)
- return DefWindowProcW(hwnd, msg, wParam, lParam);
- return DefWindowProcA(hwnd, msg, wParam, lParam);
- }
+ goto Finish;
+ }
+ }
+
+ if ((pWnd->state2 & WNDS2_INDESTROY) || (pWnd->state &
WNDS_DESTROYED))
+ {
+ switch (msg)
+ {
+ case WM_DESTROY:
+ case WM_NCDESTROY:
+ case WM_FINALDESTROY:
+ break;
+
+ default:
+ return 0;
}
}
@@ -1026,9 +1037,11 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam, BOOL unicod
case WM_DESTROY:
User32DestroyImeUIWindow(pimeui);
- break;
+ return 0;
case WM_NCDESTROY:
+ case WM_FINALDESTROY:
+ pimeui->spwnd = NULL;
HeapFree(GetProcessHeap(), 0, pimeui);
NtUserSetWindowFNID(hwnd, FNID_DESTROY);
break;
@@ -1037,11 +1050,7 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam, BOOL unicod
return TRUE;
case WM_PAINT:
- break;
-
- case WM_COPYDATA:
- // TODO:
- break;
+ return 0;
case WM_IME_STARTCOMPOSITION:
case WM_IME_COMPOSITION:
@@ -1055,11 +1064,11 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam, BOOL unicod
return ImeWnd_OnImeNotify(pimeui, wParam, lParam);
case WM_IME_REQUEST:
- break;
+ return 0;
case WM_IME_SELECT:
ImeWnd_OnImeSelect(pimeui, wParam, lParam);
- break;
+ return (LRESULT)pimeui;
case WM_IME_SETCONTEXT:
return ImeWnd_OnImeSetContext(pimeui, wParam, lParam);
@@ -1068,14 +1077,14 @@ ImeWndProc_common(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam, BOOL unicod
return ImeWnd_OnImeSystem(pimeui, wParam, lParam);
default:
- {
- if (unicode)
- return DefWindowProcW(hwnd, msg, wParam, lParam);
- return DefWindowProcA(hwnd, msg, wParam, lParam);
- }
+ break;
}
- return 0;
+
+Finish:
+ if (unicode)
+ return DefWindowProcW(hwnd, msg, wParam, lParam);
+ return DefWindowProcA(hwnd, msg, wParam, lParam);
}
// Win: ImeWndProcA