[INCLUDE][USER32] Add WM_FINALDESTROY and improve ImeWndProcA/W

CORE-11700
This commit is contained in:
Katayama Hirofumi MZ 2022-11-13 09:59:17 +09:00
parent c7e8b544bc
commit e1f8b32c3d
2 changed files with 61 additions and 51 deletions

View file

@ -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

View file

@ -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