[NTUSER] Relax condition for IntImmProcessKey (#6500)

* [NTUSER] Loose condition for IntImmProcessKey

* key up

* improve

* improve 2

* improve 3
This commit is contained in:
Katayama Hirofumi MZ 2024-02-16 21:31:13 +09:00 committed by GitHub
parent e0b67a2990
commit 398201dca4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 17 deletions

View file

@ -565,15 +565,14 @@ DWORD FASTCALL UserBuildHimcList(PTHREADINFO pti, DWORD dwCount, HIMC *phList)
return dwRealCount; return dwRealCount;
} }
// Win: xxxImmProcessKey
UINT FASTCALL UINT FASTCALL
IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg, IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
UINT uVirtualKey, ret = 0; UINT uVirtualKey, ret;
DWORD dwHotKeyId; DWORD dwHotKeyId;
PKL pKL; PKL pKL;
PIMC pIMC = NULL; PIMC pIMC;
PIMEHOTKEY pImeHotKey; PIMEHOTKEY pImeHotKey;
HKL hKL; HKL hKL;
HWND hWnd; HWND hWnd;
@ -592,6 +591,7 @@ IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg,
return 0; return 0;
} }
pIMC = NULL;
hWnd = UserHMGetHandle(pWnd); hWnd = UserHMGetHandle(pWnd);
pKL = pWnd->head.pti->KeyboardLayout; pKL = pWnd->head.pti->KeyboardLayout;
if (!pKL) if (!pKL)
@ -638,7 +638,7 @@ IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg,
if (!pIMC) if (!pIMC)
return 0; return 0;
if ((lParam & 0x80000000) && if ((lParam & (KF_UP << 16)) &&
(pKL->piiex->ImeInfo.fdwProperty & IME_PROP_IGNORE_UPKEYS)) (pKL->piiex->ImeInfo.fdwProperty & IME_PROP_IGNORE_UPKEYS))
{ {
return 0; return 0;

View file

@ -1769,17 +1769,16 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
USER_REFERENCE_ENTRY Ref; USER_REFERENCE_ENTRY Ref;
PWND pWnd; PWND pWnd;
UINT ImmRet; UINT ImmRet;
BOOL Ret = TRUE; BOOL Ret = TRUE, bKeyUpDown = FALSE;
PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
const UINT uMsg = Msg->message;
if (Msg->message == VK_PACKET) if (uMsg == VK_PACKET)
{
pti->wchInjected = HIWORD(Msg->wParam); pti->wchInjected = HIWORD(Msg->wParam);
}
if (Msg->message == WM_KEYDOWN || Msg->message == WM_SYSKEYDOWN || if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN || uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP)
Msg->message == WM_KEYUP || Msg->message == WM_SYSKEYUP)
{ {
bKeyUpDown = TRUE;
switch (Msg->wParam) switch (Msg->wParam)
{ {
case VK_LSHIFT: case VK_RSHIFT: case VK_LSHIFT: case VK_RSHIFT:
@ -1797,7 +1796,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
pWnd = ValidateHwndNoErr(Msg->hwnd); pWnd = ValidateHwndNoErr(Msg->hwnd);
if (pWnd) UserRefObjectCo(pWnd, &Ref); if (pWnd) UserRefObjectCo(pWnd, &Ref);
Event.message = Msg->message; Event.message = uMsg;
Event.hwnd = Msg->hwnd; Event.hwnd = Msg->hwnd;
Event.time = Msg->time; Event.time = Msg->time;
Event.paramL = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8); Event.paramL = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8);
@ -1807,7 +1806,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
if (*RemoveMessages) if (*RemoveMessages)
{ {
if ((Msg->message == WM_KEYDOWN) && if ((uMsg == WM_KEYDOWN) &&
(Msg->hwnd != IntGetDesktopWindow())) (Msg->hwnd != IntGetDesktopWindow()))
{ {
/* Handle F1 key by sending out WM_HELP message */ /* Handle F1 key by sending out WM_HELP message */
@ -1822,7 +1821,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
co_IntSendMessage(Msg->hwnd, WM_APPCOMMAND, (WPARAM)Msg->hwnd, MAKELPARAM(0, (FAPPCOMMAND_KEY | (Msg->wParam - VK_BROWSER_BACK + 1)))); co_IntSendMessage(Msg->hwnd, WM_APPCOMMAND, (WPARAM)Msg->hwnd, MAKELPARAM(0, (FAPPCOMMAND_KEY | (Msg->wParam - VK_BROWSER_BACK + 1))));
} }
} }
else if (Msg->message == WM_KEYUP) else if (uMsg == WM_KEYUP)
{ {
/* Handle VK_APPS key by posting a WM_CONTEXTMENU message */ /* Handle VK_APPS key by posting a WM_CONTEXTMENU message */
if (Msg->wParam == VK_APPS && pti->MessageQueue->MenuOwner == NULL) if (Msg->wParam == VK_APPS && pti->MessageQueue->MenuOwner == NULL)
@ -1831,7 +1830,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
} }
//// Key Down! //// Key Down!
if ( *RemoveMessages && Msg->message == WM_SYSKEYDOWN ) if (*RemoveMessages && uMsg == WM_SYSKEYDOWN)
{ {
if ( HIWORD(Msg->lParam) & KF_ALTDOWN ) if ( HIWORD(Msg->lParam) & KF_ALTDOWN )
{ {
@ -1869,9 +1868,10 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
Ret = FALSE; Ret = FALSE;
} }
if ( pWnd && Ret && *RemoveMessages && Msg->message == WM_KEYDOWN && !(pti->TIF_flags & TIF_DISABLEIME)) if (pWnd && Ret && *RemoveMessages && bKeyUpDown && !(pti->TIF_flags & TIF_DISABLEIME))
{ {
if ( (ImmRet = IntImmProcessKey(pti->MessageQueue, pWnd, Msg->message, Msg->wParam, Msg->lParam)) ) ImmRet = IntImmProcessKey(pti->MessageQueue, pWnd, uMsg, Msg->wParam, Msg->lParam);
if (ImmRet)
{ {
if ( ImmRet & (IPHK_HOTKEY|IPHK_SKIPTHISKEY) ) if ( ImmRet & (IPHK_HOTKEY|IPHK_SKIPTHISKEY) )
{ {