[NTUSER] IntWinListOwnedPopups: Exclude default IME window from the list (#5069)

And in IntShowOwnedPopups: Remove the window owner check hack as it's no longer needed.
Based on my observation, the owner of the default IME window can change and it depends on
the window that is being focused.

CORE-18659
CORE-18768
This commit is contained in:
Thamatip Chitpong 2023-02-15 03:57:41 +07:00 committed by GitHub
parent 38c0da9978
commit 0fee1fc80c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -314,6 +314,15 @@ IntWinListChildren(PWND Window)
return List; return List;
} }
static BOOL
IntWndIsDefaultIme(_In_ PWND Window)
{
PTHREADINFO pti = Window->head.pti;
return (IS_IMM_MODE() && !(pti->TIF_flags & TIF_INCLEANUP) &&
Window == pti->spwndDefaultIme);
}
HWND* FASTCALL HWND* FASTCALL
IntWinListOwnedPopups(PWND Window) IntWinListOwnedPopups(PWND Window)
{ {
@ -327,7 +336,7 @@ IntWinListOwnedPopups(PWND Window)
for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext) for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
{ {
if (Child->spwndOwner == Window) if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
++NumOwned; ++NumOwned;
} }
@ -342,7 +351,7 @@ IntWinListOwnedPopups(PWND Window)
Index = 0; Index = 0;
for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext) for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
{ {
if (Child->spwndOwner == Window) if (Child->spwndOwner == Window && !IntWndIsDefaultIme(Child))
List[Index++] = Child->head.h; List[Index++] = Child->head.h;
} }
List[Index] = NULL; List[Index] = NULL;
@ -2807,7 +2816,6 @@ VOID FASTCALL IntDestroyOwnedWindows(PWND Window)
HWND* List; HWND* List;
HWND* phWnd; HWND* phWnd;
PWND pWnd; PWND pWnd;
PTHREADINFO pti = Window->head.pti;
USER_REFERENCE_ENTRY Ref; USER_REFERENCE_ENTRY Ref;
List = IntWinListOwnedPopups(Window); List = IntWinListOwnedPopups(Window);
@ -2822,12 +2830,6 @@ VOID FASTCALL IntDestroyOwnedWindows(PWND Window)
ASSERT(pWnd->spwndOwner == Window); ASSERT(pWnd->spwndOwner == Window);
ASSERT(pWnd != Window); ASSERT(pWnd != Window);
if (IS_IMM_MODE() && !(pti->TIF_flags & TIF_INCLEANUP) &&
pWnd == pti->spwndDefaultIme)
{
continue;
}
WndSetOwner(pWnd, NULL); WndSetOwner(pWnd, NULL);
if (IntWndBelongsToThread(pWnd, PsGetCurrentThreadWin32Thread())) if (IntWndBelongsToThread(pWnd, PsGetCurrentThreadWin32Thread()))
{ {
@ -4679,8 +4681,7 @@ IntShowOwnedPopups(PWND OwnerWnd, BOOL fShow )
{ {
if (!(pWnd = ValidateHwndNoErr( win_array[count] ))) if (!(pWnd = ValidateHwndNoErr( win_array[count] )))
continue; continue;
if (pWnd->spwndOwner != OwnerWnd) ASSERT(pWnd->spwndOwner == OwnerWnd);
continue;
if (fShow) if (fShow)
{ {