HWND* FASTCALL
IntWinListChildren(PWND Window)
{
- PWND Child;
- HWND *List;
- UINT Index, NumChildren = 0;
+ PWND Child;
+ HWND *List;
+ UINT Index, NumChildren = 0;
- if (!Window) return NULL;
+ if (!Window) return NULL;
- for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
- ++NumChildren;
+ for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
+ {
+ ++NumChildren;
+ }
- List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
- if(!List)
- {
- ERR("Failed to allocate memory for children array\n");
- EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return NULL;
- }
- for (Child = Window->spwndChild, Index = 0;
- Child != NULL;
- Child = Child->spwndNext, ++Index)
- List[Index] = Child->head.h;
- List[Index] = NULL;
+ List = ExAllocatePoolWithTag(PagedPool, (NumChildren + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
+ if(!List)
+ {
+ ERR("Failed to allocate memory for children array\n");
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return NULL;
+ }
+
+ Index = 0;
+ for (Child = Window->spwndChild; Child; Child = Child->spwndNext)
+ {
+ List[Index++] = Child->head.h;
+ }
+ List[Index] = NULL;
- return List;
+ return List;
+}
+
+HWND* FASTCALL
+IntWinListOwnedPopups(PWND Window)
+{
+ PWND Child, Desktop;
+ HWND *List;
+ UINT Index, NumOwned = 0;
+
+ Desktop = co_GetDesktopWindow(Window);
+ if (!Desktop)
+ return NULL;
+
+ for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
+ {
+ if (Child->spwndOwner == Window)
+ ++NumOwned;
+ }
+
+ List = ExAllocatePoolWithTag(PagedPool, (NumOwned + 1) * sizeof(HWND), USERTAG_WINDOWLIST);
+ if (!List)
+ {
+ ERR("Failed to allocate memory for children array\n");
+ EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return NULL;
+ }
+
+ Index = 0;
+ for (Child = Desktop->spwndChild; Child; Child = Child->spwndNext)
+ {
+ if (Child->spwndOwner == Window)
+ List[Index++] = Child->head.h;
+ }
+ List[Index] = NULL;
+
+ return List;
}
PWND FASTCALL
}
////
-/*
- Link the window into siblings list
- children and parent are kept in place.
-*/
+/* Link the window into siblings list. Children and parent are kept in place. */
VOID FASTCALL
IntLinkWindow(
- PWND Wnd,
- PWND WndInsertAfter /* set to NULL if top sibling */
+ PWND Wnd,
+ PWND WndInsertAfter /* Set to NULL if top sibling */
)
{
- if ((Wnd->spwndPrev = WndInsertAfter))
- {
- /* link after WndInsertAfter */
- if ((Wnd->spwndNext = WndInsertAfter->spwndNext))
- Wnd->spwndNext->spwndPrev = Wnd;
+ if (Wnd == WndInsertAfter)
+ {
+ ERR("IntLinkWindow -- Trying to link window 0x%p to itself!!\n", Wnd);
+ return;
+ }
- Wnd->spwndPrev->spwndNext = Wnd;
- }
- else
- {
- /* link at top */
- if ((Wnd->spwndNext = Wnd->spwndParent->spwndChild))
- Wnd->spwndNext->spwndPrev = Wnd;
+ Wnd->spwndPrev = WndInsertAfter;
+ if (Wnd->spwndPrev)
+ {
+ /* Link after WndInsertAfter */
+ ASSERT(Wnd != WndInsertAfter->spwndNext);
+ Wnd->spwndNext = WndInsertAfter->spwndNext;
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd;
+
+ ASSERT(Wnd != Wnd->spwndPrev);
+ Wnd->spwndPrev->spwndNext = Wnd;
+ }
+ else
+ {
+ /* Link at the top */
+ ASSERT(Wnd != Wnd->spwndParent->spwndChild);
+ Wnd->spwndNext = Wnd->spwndParent->spwndChild;
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd;
- Wnd->spwndParent->spwndChild = Wnd;
- }
+ Wnd->spwndParent->spwndChild = Wnd;
+ }
}
/*
{
if (hWndPrev == HWND_NOTOPMOST)
{
- if (!(Wnd->ExStyle & WS_EX_TOPMOST) &&
- (Wnd->ExStyle2 & WS_EX2_LINKED)) return; /* nothing to do */
+ if (!(Wnd->ExStyle & WS_EX_TOPMOST) && (Wnd->ExStyle2 & WS_EX2_LINKED))
+ return; /* nothing to do */
Wnd->ExStyle &= ~WS_EX_TOPMOST;
hWndPrev = HWND_TOP; /* fallback to the HWND_TOP case */
}
PWND WndInsertAfter;
WndInsertAfter = Wnd->spwndParent->spwndChild;
- while( WndInsertAfter && WndInsertAfter->spwndNext)
+ while (WndInsertAfter && WndInsertAfter->spwndNext)
+ {
WndInsertAfter = WndInsertAfter->spwndNext;
+ }
IntLinkWindow(Wnd, WndInsertAfter);
Wnd->ExStyle &= ~WS_EX_TOPMOST;
{
/* Link in the top of the list */
IntLinkWindow(Wnd, NULL);
-
Wnd->ExStyle |= WS_EX_TOPMOST;
}
else if (hWndPrev == HWND_TOP)
{
while (WndInsertBefore != NULL && WndInsertBefore->spwndNext != NULL)
{
- if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST)) break;
+ if (!(WndInsertBefore->ExStyle & WS_EX_TOPMOST))
+ break;
+
if (WndInsertBefore == Wnd->spwndOwner) /* keep it above owner */
{
Wnd->ExStyle |= WS_EX_TOPMOST;
WndInsertAfter = UserGetWindowObject(hWndPrev);
/* Are we called with an erroneous handle */
- if(WndInsertAfter == NULL)
+ if (WndInsertAfter == NULL)
{
/* Link in a default position */
IntLinkHwnd(Wnd, HWND_TOP);
return;
}
+ if (Wnd == WndInsertAfter)
+ ERR("IntLinkHwnd -- Trying to link window 0x%p to itself!!\n", Wnd);
IntLinkWindow(Wnd, WndInsertAfter);
/* Fix the WS_EX_TOPMOST flag */
}
else
{
- if(WndInsertAfter->spwndNext &&
- WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST)
+ if (WndInsertAfter->spwndNext &&
+ (WndInsertAfter->spwndNext->ExStyle & WS_EX_TOPMOST))
{
Wnd->ExStyle |= WS_EX_TOPMOST;
}
return( hWndOldParent);
}
-/* Unlink the window from siblings. children and parent are kept in place. */
+/* Unlink the window from siblings. Children and parent are kept in place. */
VOID FASTCALL
IntUnlinkWindow(PWND Wnd)
{
- if (Wnd->spwndNext)
- Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
+ ASSERT(Wnd != Wnd->spwndNext);
+ ASSERT(Wnd != Wnd->spwndPrev);
- if (Wnd->spwndPrev)
- Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
+ if (Wnd->spwndNext)
+ Wnd->spwndNext->spwndPrev = Wnd->spwndPrev;
- if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
- Wnd->spwndParent->spwndChild = Wnd->spwndNext;
+ if (Wnd->spwndPrev)
+ Wnd->spwndPrev->spwndNext = Wnd->spwndNext;
- Wnd->spwndPrev = Wnd->spwndNext = NULL;
+ if (Wnd->spwndParent && Wnd->spwndParent->spwndChild == Wnd)
+ Wnd->spwndParent->spwndChild = Wnd->spwndNext;
+
+ Wnd->spwndPrev = Wnd->spwndNext = NULL;
}
/* FUNCTIONS *****************************************************************/
hWnd = Window->head.h;
ti = PsGetCurrentThreadWin32Thread();
- TRACE("co_UserDestroyWindow \n");
+ TRACE("co_UserDestroyWindow(Window = 0x%p, hWnd = 0x%p)\n", Window, hWnd);
/* Check for owner thread */
if ( Window->head.pti != PsGetCurrentThreadWin32Thread())
}
}
- // Adjust last active.
+ /* Adjust last active */
if ((pwndTemp = Window->spwndOwner))
{
while (pwndTemp->spwndOwner)
// ASSERT(OwnerWnd);
TRACE("Enter ShowOwnedPopups Show: %s\n", (fShow ? "TRUE" : "FALSE"));
- win_array = IntWinListChildren(OwnerWnd);
+
+ /* NOTE: Popups are not children */
+ win_array = IntWinListOwnedPopups(OwnerWnd);
if (!win_array)
return TRUE;
* regardless of the state of the owner
*/
co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_SHOWNORMAL, SW_PARENTOPENING);
+ pWnd->state &= ~WNDS_HIDDENPOPUP;
continue;
}
}
* regardless of the state of the owner
*/
co_IntSendMessage(win_array[count], WM_SHOWWINDOW, SW_HIDE, SW_PARENTCLOSING);
+ pWnd->state |= WNDS_HIDDENPOPUP;
continue;
}
}
-
}
ExFreePoolWithTag(win_array, USERTAG_WINDOWLIST);
TRACE("Leave ShowOwnedPopups\n");