- Attempt to fix window activation bugs reported by G� van Geldorp and Thomas Weidenmueller.

svn path=/trunk/; revision=6849
This commit is contained in:
Filip Navara 2003-12-02 19:58:54 +00:00
parent c2642685e7
commit b4e30cf77b
4 changed files with 56 additions and 74 deletions

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Id: focus.c,v 1.2 2003/11/30 22:48:11 navaraf Exp $ * $Id: focus.c,v 1.3 2003/12/02 19:58:54 navaraf Exp $
*/ */
#include <win32k/win32k.h> #include <win32k/win32k.h>
@ -144,8 +144,13 @@ IntSetForegroundWindow(PWINDOW_OBJECT Window)
/* FIXME: Call hooks. */ /* FIXME: Call hooks. */
IntSetFocusMessageQueue(Window->MessageQueue); IntSetFocusMessageQueue(Window->MessageQueue);
Window->MessageQueue->ActiveWindow = hWnd; /* ExAcquireFastMutex(&Window->MessageQueue->Lock);*/
Window->MessageQueue->FocusWindow = hWnd; if (Window->MessageQueue)
{
Window->MessageQueue->ActiveWindow = hWnd;
Window->MessageQueue->FocusWindow = hWnd;
}
/* ExReleaseFastMutex(&Window->MessageQueue->Lock);*/
IntSendDeactivateMessages(hWndPrev, hWnd); IntSendDeactivateMessages(hWndPrev, hWnd);
IntSendKillFocusMessages(hWndPrev, hWnd); IntSendKillFocusMessages(hWndPrev, hWnd);
@ -187,7 +192,9 @@ IntSetActiveWindow(PWINDOW_OBJECT Window)
/* FIXME: Call hooks. */ /* FIXME: Call hooks. */
/* ExAcquireFastMutex(&ThreadQueue->Lock);*/
ThreadQueue->ActiveWindow = hWnd; ThreadQueue->ActiveWindow = hWnd;
/* ExReleaseFastMutex(&ThreadQueue->Lock);*/
IntSendDeactivateMessages(hWndPrev, hWnd); IntSendDeactivateMessages(hWndPrev, hWnd);
IntSendActivateMessages(hWndPrev, hWnd); IntSendActivateMessages(hWndPrev, hWnd);
@ -213,7 +220,9 @@ IntSetFocusWindow(PWINDOW_OBJECT Window)
return hWndPrev; return hWndPrev;
} }
/* ExAcquireFastMutex(&ThreadQueue->Lock);*/
ThreadQueue->FocusWindow = hWnd; ThreadQueue->FocusWindow = hWnd;
/* ExReleaseFastMutex(&ThreadQueue->Lock);*/
IntSendKillFocusMessages(hWndPrev, hWnd); IntSendKillFocusMessages(hWndPrev, hWnd);
IntSendSetFocusMessages(hWndPrev, hWnd); IntSendSetFocusMessages(hWndPrev, hWnd);
@ -317,7 +326,9 @@ NtUserSetCapture(HWND hWnd)
} }
hWndPrev = ThreadQueue->CaptureWindow; hWndPrev = ThreadQueue->CaptureWindow;
NtUserSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); NtUserSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd);
/* ExAcquireFastMutex(&ThreadQueue->Lock);*/
ThreadQueue->CaptureWindow = hWnd; ThreadQueue->CaptureWindow = hWnd;
/* ExReleaseFastMutex(&ThreadQueue->Lock);*/
return hWndPrev; return hWndPrev;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: windc.c,v 1.39 2003/11/26 21:48:35 gvg Exp $ /* $Id: windc.c,v 1.40 2003/12/02 19:58:54 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -440,6 +440,23 @@ NtUserGetDCEx(HWND hWnd, HANDLE ClipRegion, ULONG Flags)
Flags |= DCX_INTERSECTRGN; Flags |= DCX_INTERSECTRGN;
} }
/*
if (ClipRegion == (HRGN)1)
{
if (!(Flags & DCX_WINDOW))
{
ClipRegion = UnsafeIntCreateRectRgnIndirect(&Window->ClientRect);
}
else
{
ClipRegion = UnsafeIntCreateRectRgnIndirect(&Window->WindowRect);
}
NtGdiOffsetRgn(ClipRegion,
-Window->WindowRect.left,
-Window->WindowRect.top);
}
*/
if (NULL != ClipRegion) if (NULL != ClipRegion)
{ {
Dce->hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0); Dce->hClipRgn = NtGdiCreateRectRgn(0, 0, 0, 0);

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: window.c,v 1.149 2003/11/30 20:03:47 navaraf Exp $ /* $Id: window.c,v 1.150 2003/12/02 19:58:54 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1512,6 +1512,14 @@ NtUserDestroyWindow(HWND Wnd)
* be destroying. * be destroying.
*/ */
WinPosActivateOtherWindow(Window); WinPosActivateOtherWindow(Window);
/* FIXME: Lock */
if (Window->MessageQueue->ActiveWindow == Window->Self)
Window->MessageQueue->ActiveWindow = NULL;
if (Window->MessageQueue->FocusWindow == Window->Self)
Window->MessageQueue->FocusWindow = NULL;
if (Window->MessageQueue->CaptureWindow == Window->Self)
Window->MessageQueue->CaptureWindow = NULL;
/* FIXME: Unlock */
/* Call hooks */ /* Call hooks */
#if 0 /* FIXME */ #if 0 /* FIXME */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: winpos.c,v 1.49 2003/11/30 22:48:11 navaraf Exp $ /* $Id: winpos.c,v 1.50 2003/12/02 19:58:54 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -95,81 +95,27 @@ NtUserGetClientOrigin(HWND hWnd, LPPOINT Point)
return(TRUE); return(TRUE);
} }
/*******************************************************************
* can_activate_window
*
* Check if we can activate the specified window.
*/
static BOOL FASTCALL
can_activate_window(HWND hwnd)
{
LONG style;
if (! hwnd)
{
return FALSE;
}
style = NtUserGetWindowLong(hwnd, GWL_STYLE, FALSE);
if (! (style & WS_VISIBLE))
{
return FALSE;
}
if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD)
{
return FALSE;
}
return ! (style & WS_DISABLED);
}
/******************************************************************* /*******************************************************************
* WinPosActivateOtherWindow * WinPosActivateOtherWindow
* *
* Activates window other than pWnd. * Activates window other than pWnd.
*/ */
void FASTCALL VOID FASTCALL
WinPosActivateOtherWindow(PWINDOW_OBJECT Window) WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
{ {
HWND hwndTo; for (;;)
HWND fg; {
Window = IntGetParent(Window);
if ((NtUserGetWindowLong(Window->Self, GWL_STYLE, FALSE) & WS_POPUP) if (!Window || IntIsDesktopWindow(Window))
&& (hwndTo = NtUserGetWindow(Window->Self, GW_OWNER))) {
{ IntSetFocusMessageQueue(NULL);
hwndTo = NtUserGetAncestor(hwndTo, GA_ROOT); return;
if (can_activate_window(hwndTo)) goto done; }
} if (IntSetForegroundWindow(Window))
{
hwndTo = Window->Self; return;
for (;;) }
{ }
if (!(hwndTo = NtUserGetWindow(hwndTo, GW_HWNDNEXT)))
{
break;
}
if (can_activate_window(hwndTo))
{
break;
}
}
done:
fg = NtUserGetForegroundWindow();
/* TRACE("win = %p fg = %p\n", hwndTo, fg); */
if (! fg || (hwndTo == fg))
{
PWINDOW_OBJECT ToWindow = IntGetWindowObject(hwndTo);
if (IntSetForegroundWindow(ToWindow))
{
IntReleaseWindowObject(ToWindow);
return;
}
IntReleaseWindowObject(Window);
}
if (!IntSetActiveWindow(hwndTo))
{
IntSetActiveWindow(NULL);
}
} }
POINT STATIC FASTCALL POINT STATIC FASTCALL