Skip to content

Commit 398201d

Browse files
authored
[NTUSER] Relax condition for IntImmProcessKey (reactos#6500)
* [NTUSER] Loose condition for IntImmProcessKey * key up * improve * improve 2 * improve 3
1 parent e0b67a2 commit 398201d

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

win32ss/user/ntuser/ime.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,14 @@ DWORD FASTCALL UserBuildHimcList(PTHREADINFO pti, DWORD dwCount, HIMC *phList)
565565
return dwRealCount;
566566
}
567567

568-
// Win: xxxImmProcessKey
569568
UINT FASTCALL
570569
IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg,
571570
WPARAM wParam, LPARAM lParam)
572571
{
573-
UINT uVirtualKey, ret = 0;
572+
UINT uVirtualKey, ret;
574573
DWORD dwHotKeyId;
575574
PKL pKL;
576-
PIMC pIMC = NULL;
575+
PIMC pIMC;
577576
PIMEHOTKEY pImeHotKey;
578577
HKL hKL;
579578
HWND hWnd;
@@ -592,6 +591,7 @@ IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg,
592591
return 0;
593592
}
594593

594+
pIMC = NULL;
595595
hWnd = UserHMGetHandle(pWnd);
596596
pKL = pWnd->head.pti->KeyboardLayout;
597597
if (!pKL)
@@ -638,7 +638,7 @@ IntImmProcessKey(PUSER_MESSAGE_QUEUE MessageQueue, PWND pWnd, UINT uMsg,
638638
if (!pIMC)
639639
return 0;
640640

641-
if ((lParam & 0x80000000) &&
641+
if ((lParam & (KF_UP << 16)) &&
642642
(pKL->piiex->ImeInfo.fdwProperty & IME_PROP_IGNORE_UPKEYS))
643643
{
644644
return 0;

win32ss/user/ntuser/msgqueue.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,17 +1769,16 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
17691769
USER_REFERENCE_ENTRY Ref;
17701770
PWND pWnd;
17711771
UINT ImmRet;
1772-
BOOL Ret = TRUE;
1772+
BOOL Ret = TRUE, bKeyUpDown = FALSE;
17731773
PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
1774+
const UINT uMsg = Msg->message;
17741775

1775-
if (Msg->message == VK_PACKET)
1776-
{
1777-
pti->wchInjected = HIWORD(Msg->wParam);
1778-
}
1776+
if (uMsg == VK_PACKET)
1777+
pti->wchInjected = HIWORD(Msg->wParam);
17791778

1780-
if (Msg->message == WM_KEYDOWN || Msg->message == WM_SYSKEYDOWN ||
1781-
Msg->message == WM_KEYUP || Msg->message == WM_SYSKEYUP)
1779+
if (uMsg == WM_KEYDOWN || uMsg == WM_SYSKEYDOWN || uMsg == WM_KEYUP || uMsg == WM_SYSKEYUP)
17821780
{
1781+
bKeyUpDown = TRUE;
17831782
switch (Msg->wParam)
17841783
{
17851784
case VK_LSHIFT: case VK_RSHIFT:
@@ -1797,7 +1796,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
17971796
pWnd = ValidateHwndNoErr(Msg->hwnd);
17981797
if (pWnd) UserRefObjectCo(pWnd, &Ref);
17991798

1800-
Event.message = Msg->message;
1799+
Event.message = uMsg;
18011800
Event.hwnd = Msg->hwnd;
18021801
Event.time = Msg->time;
18031802
Event.paramL = (Msg->wParam & 0xFF) | (HIWORD(Msg->lParam) << 8);
@@ -1807,7 +1806,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
18071806

18081807
if (*RemoveMessages)
18091808
{
1810-
if ((Msg->message == WM_KEYDOWN) &&
1809+
if ((uMsg == WM_KEYDOWN) &&
18111810
(Msg->hwnd != IntGetDesktopWindow()))
18121811
{
18131812
/* Handle F1 key by sending out WM_HELP message */
@@ -1822,7 +1821,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
18221821
co_IntSendMessage(Msg->hwnd, WM_APPCOMMAND, (WPARAM)Msg->hwnd, MAKELPARAM(0, (FAPPCOMMAND_KEY | (Msg->wParam - VK_BROWSER_BACK + 1))));
18231822
}
18241823
}
1825-
else if (Msg->message == WM_KEYUP)
1824+
else if (uMsg == WM_KEYUP)
18261825
{
18271826
/* Handle VK_APPS key by posting a WM_CONTEXTMENU message */
18281827
if (Msg->wParam == VK_APPS && pti->MessageQueue->MenuOwner == NULL)
@@ -1831,7 +1830,7 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
18311830
}
18321831

18331832
//// Key Down!
1834-
if ( *RemoveMessages && Msg->message == WM_SYSKEYDOWN )
1833+
if (*RemoveMessages && uMsg == WM_SYSKEYDOWN)
18351834
{
18361835
if ( HIWORD(Msg->lParam) & KF_ALTDOWN )
18371836
{
@@ -1869,9 +1868,10 @@ BOOL co_IntProcessKeyboardMessage(MSG* Msg, BOOL* RemoveMessages)
18691868
Ret = FALSE;
18701869
}
18711870

1872-
if ( pWnd && Ret && *RemoveMessages && Msg->message == WM_KEYDOWN && !(pti->TIF_flags & TIF_DISABLEIME))
1871+
if (pWnd && Ret && *RemoveMessages && bKeyUpDown && !(pti->TIF_flags & TIF_DISABLEIME))
18731872
{
1874-
if ( (ImmRet = IntImmProcessKey(pti->MessageQueue, pWnd, Msg->message, Msg->wParam, Msg->lParam)) )
1873+
ImmRet = IntImmProcessKey(pti->MessageQueue, pWnd, uMsg, Msg->wParam, Msg->lParam);
1874+
if (ImmRet)
18751875
{
18761876
if ( ImmRet & (IPHK_HOTKEY|IPHK_SKIPTHISKEY) )
18771877
{

0 commit comments

Comments
 (0)