Don't steal foreground window focus from other applications in
WinPosActivateOtherWindow and remove incorrect code for searching
top-most windows.
Modified: trunk/reactos/subsys/win32k/ntuser/winpos.c
_____
Modified: trunk/reactos/subsys/win32k/ntuser/winpos.c
--- trunk/reactos/subsys/win32k/ntuser/winpos.c 2005-07-26 16:34:48 UTC
(rev 16749)
+++ trunk/reactos/subsys/win32k/ntuser/winpos.c 2005-07-26 17:46:48 UTC
(rev 16750)
@@ -107,7 +107,7 @@
WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
{
PWINDOW_OBJECT Wnd, Old;
- int TryTopmost;
+ HWND Fg;
if (!Window || IntIsDesktopWindow(Window))
{
@@ -129,11 +129,9 @@
IntReleaseWindowObject(Old);
}
- if (IntSetForegroundWindow(Wnd))
- {
- IntReleaseWindowObject(Wnd);
- return;
- }
+ if ((Wnd->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE &&
+ (Wnd->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
+ goto done;
IntReleaseWindowObject(Wnd);
}
@@ -156,35 +154,45 @@
if((List = IntWinListChildren(Wnd)))
{
- for(TryTopmost = 0; TryTopmost <= 1; TryTopmost++)
+ /* FIXME: We should scan for non-tooltip windows first. */
+ for(phWnd = List; *phWnd; phWnd++)
{
- for(phWnd = List; *phWnd; phWnd++)
+ PWINDOW_OBJECT Child;
+
+ if((*phWnd) == Window->Self)
{
- PWINDOW_OBJECT Child;
+ continue;
+ }
- if((*phWnd) == Window->Self)
+ if((Child = IntGetWindowObject(*phWnd)))
+ {
+ if ((Child->Style & (WS_DISABLED | WS_VISIBLE)) == WS_VISIBLE
&&
+ (Child->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
{
- continue;
+ ExFreePool(List);
+ IntReleaseWindowObject(Wnd);
+ Wnd = Child;
+ goto done;
}
-
- if((Child = IntGetWindowObject(*phWnd)))
- {
- if(((! TryTopmost && (0 == (Child->ExStyle &
WS_EX_TOPMOST)))
- || (TryTopmost && (0 != (Child->ExStyle &
WS_EX_TOPMOST))))
- && IntSetForegroundWindow(Child))
- {
- ExFreePool(List);
- IntReleaseWindowObject(Wnd);
- IntReleaseWindowObject(Child);
- return;
- }
- IntReleaseWindowObject(Child);
- }
+ IntReleaseWindowObject(Child);
}
}
ExFreePool(List);
}
}
+
+done:
+ Fg = NtUserGetForegroundWindow();
+ if (!Fg || Window->Self == Fg)
+ {
+ if (IntSetForegroundWindow(Wnd))
+ {
+ IntReleaseWindowObject(Wnd);
+ return;
+ }
+ }
+ if (!IntSetActiveWindow(Wnd))
+ IntSetActiveWindow(0);
IntReleaseWindowObject(Wnd);
}
Show replies by date