2003-11-30 20:29:09 +00:00
|
|
|
/*
|
|
|
|
* ReactOS Win32 Subsystem
|
|
|
|
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
2004-04-13 13:50:31 +00:00
|
|
|
* $Id: focus.c,v 1.20 2004/04/13 13:50:31 weiden Exp $
|
2003-11-30 20:29:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <win32k/win32k.h>
|
2004-02-24 01:30:58 +00:00
|
|
|
#include <include/object.h>
|
2003-11-30 20:29:09 +00:00
|
|
|
#include <include/window.h>
|
2003-12-07 19:29:33 +00:00
|
|
|
#include <include/desktop.h>
|
2003-11-30 20:29:09 +00:00
|
|
|
#include <include/focus.h>
|
|
|
|
#include <include/error.h>
|
|
|
|
#include <include/winpos.h>
|
2004-02-24 13:27:03 +00:00
|
|
|
#include <include/msgqueue.h>
|
2004-02-01 15:46:53 +00:00
|
|
|
#define NDEBUG
|
2003-11-30 20:29:09 +00:00
|
|
|
#include <win32k/debug1.h>
|
|
|
|
#include <debug.h>
|
|
|
|
|
|
|
|
HWND FASTCALL
|
|
|
|
IntGetCaptureWindow()
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
|
|
|
|
return ForegroundQueue != NULL ? ForegroundQueue->CaptureWindow : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND FASTCALL
|
|
|
|
IntGetFocusWindow()
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
|
|
|
|
return ForegroundQueue != NULL ? ForegroundQueue->FocusWindow : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND FASTCALL
|
|
|
|
IntGetThreadFocusWindow()
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
return ThreadQueue != NULL ? ThreadQueue->FocusWindow : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
|
|
|
IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd)
|
|
|
|
{
|
|
|
|
if (hWndPrev)
|
|
|
|
{
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0);
|
|
|
|
IntPostOrSendMessage(hWndPrev, WM_ACTIVATE,
|
2003-11-30 20:29:09 +00:00
|
|
|
MAKEWPARAM(WA_INACTIVE, NtUserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE),
|
2004-01-12 20:48:48 +00:00
|
|
|
(LPARAM)hWnd);
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
2004-01-12 20:48:48 +00:00
|
|
|
IntSendActivateMessages(HWND hWndPrev, HWND hWnd, BOOL MouseActivate)
|
2003-11-30 20:29:09 +00:00
|
|
|
{
|
|
|
|
if (hWnd)
|
|
|
|
{
|
|
|
|
/* Send palette messages */
|
2004-04-13 13:50:31 +00:00
|
|
|
if (IntPostOrSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0))
|
2003-11-30 20:29:09 +00:00
|
|
|
{
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING,
|
2003-12-26 22:52:12 +00:00
|
|
|
(WPARAM)hWnd, 0);
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
|
2004-01-15 21:00:49 +00:00
|
|
|
if (NtUserGetWindow(hWnd, GW_HWNDPREV) != NULL)
|
|
|
|
WinPosSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
|
|
|
|
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSENDCHANGING);
|
2003-11-30 20:29:09 +00:00
|
|
|
|
|
|
|
/* FIXME: IntIsWindow */
|
|
|
|
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == NtUserGetForegroundWindow()), 0);
|
2003-11-30 20:29:09 +00:00
|
|
|
/* FIXME: WA_CLICKACTIVE */
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(hWnd, WM_ACTIVATE,
|
2004-01-12 20:48:48 +00:00
|
|
|
MAKEWPARAM(MouseActivate ? WA_CLICKACTIVE : WA_ACTIVE,
|
|
|
|
NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE),
|
2003-12-26 22:52:12 +00:00
|
|
|
(LPARAM)hWndPrev);
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
|
|
|
IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd)
|
|
|
|
{
|
|
|
|
if (hWndPrev)
|
|
|
|
{
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0);
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
|
|
|
IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd)
|
|
|
|
{
|
|
|
|
if (hWnd)
|
|
|
|
{
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0);
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-27 11:52:37 +00:00
|
|
|
HWND FASTCALL
|
|
|
|
IntFindChildWindowToOwner(PWINDOW_OBJECT Root, PWINDOW_OBJECT Owner)
|
|
|
|
{
|
|
|
|
HWND Ret;
|
2004-02-24 01:30:58 +00:00
|
|
|
PWINDOW_OBJECT Child, OwnerWnd;
|
|
|
|
IntLockRelatives(Root);
|
2004-01-27 11:52:37 +00:00
|
|
|
|
|
|
|
for(Child = Root->FirstChild; Child; Child = Child->NextSibling)
|
|
|
|
{
|
2004-02-24 01:30:58 +00:00
|
|
|
IntLockRelatives(Child);
|
|
|
|
OwnerWnd = IntGetWindowObject(Child->Owner);
|
|
|
|
IntUnLockRelatives(Child);
|
|
|
|
if(!OwnerWnd)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(OwnerWnd == Owner)
|
2004-01-27 11:52:37 +00:00
|
|
|
{
|
2004-02-24 01:30:58 +00:00
|
|
|
IntUnLockRelatives(Root);
|
2004-01-27 11:52:37 +00:00
|
|
|
Ret = Child->Self;
|
2004-02-24 01:30:58 +00:00
|
|
|
IntReleaseWindowObject(OwnerWnd);
|
2004-01-27 11:52:37 +00:00
|
|
|
return Ret;
|
|
|
|
}
|
2004-02-24 01:30:58 +00:00
|
|
|
IntReleaseWindowObject(OwnerWnd);
|
2004-01-27 11:52:37 +00:00
|
|
|
}
|
|
|
|
|
2004-02-24 01:30:58 +00:00
|
|
|
IntUnLockRelatives(Root);
|
2004-01-27 11:52:37 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-01-12 20:48:48 +00:00
|
|
|
STATIC BOOL FASTCALL
|
|
|
|
IntSetForegroundAndFocusWindow(PWINDOW_OBJECT Window, PWINDOW_OBJECT FocusWindow, BOOL MouseActivate)
|
2003-11-30 20:29:09 +00:00
|
|
|
{
|
|
|
|
HWND hWnd = Window->Self;
|
2004-01-12 20:48:48 +00:00
|
|
|
HWND hWndPrev = NULL;
|
|
|
|
HWND hWndFocus = FocusWindow->Self;
|
|
|
|
HWND hWndFocusPrev = NULL;
|
2003-11-30 20:29:09 +00:00
|
|
|
PUSER_MESSAGE_QUEUE PrevForegroundQueue;
|
|
|
|
|
2004-01-12 20:48:48 +00:00
|
|
|
DPRINT("IntSetForegroundAndFocusWindow(%x, %x, %s)\n", hWnd, hWndFocus, MouseActivate ? "TRUE" : "FALSE");
|
2003-11-30 20:29:09 +00:00
|
|
|
DPRINT("(%wZ)\n", &Window->WindowName);
|
|
|
|
|
|
|
|
if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
|
|
|
|
{
|
|
|
|
DPRINT("Failed - Child\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrevForegroundQueue = IntGetFocusMessageQueue();
|
|
|
|
if (PrevForegroundQueue != 0)
|
|
|
|
{
|
|
|
|
hWndPrev = PrevForegroundQueue->ActiveWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hWndPrev == hWnd)
|
|
|
|
{
|
|
|
|
DPRINT("Failed - Same\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-12 20:48:48 +00:00
|
|
|
hWndFocusPrev = (PrevForegroundQueue == FocusWindow->MessageQueue
|
|
|
|
? FocusWindow->MessageQueue->FocusWindow : NULL);
|
|
|
|
|
2003-11-30 20:29:09 +00:00
|
|
|
/* FIXME: Call hooks. */
|
|
|
|
|
|
|
|
IntSetFocusMessageQueue(Window->MessageQueue);
|
2004-02-24 13:27:03 +00:00
|
|
|
IntLockMessageQueue(Window->MessageQueue);
|
2003-12-02 19:58:54 +00:00
|
|
|
if (Window->MessageQueue)
|
|
|
|
{
|
|
|
|
Window->MessageQueue->ActiveWindow = hWnd;
|
2004-01-12 20:48:48 +00:00
|
|
|
}
|
2004-02-24 13:27:03 +00:00
|
|
|
IntUnLockMessageQueue(Window->MessageQueue);
|
|
|
|
IntLockMessageQueue(FocusWindow->MessageQueue);
|
2004-01-12 20:48:48 +00:00
|
|
|
if (FocusWindow->MessageQueue)
|
|
|
|
{
|
|
|
|
FocusWindow->MessageQueue->FocusWindow = hWndFocus;
|
2003-12-02 19:58:54 +00:00
|
|
|
}
|
2004-02-24 13:27:03 +00:00
|
|
|
IntUnLockMessageQueue(FocusWindow->MessageQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
|
|
|
|
IntSendDeactivateMessages(hWndPrev, hWnd);
|
2004-01-12 20:48:48 +00:00
|
|
|
IntSendKillFocusMessages(hWndFocusPrev, hWndFocus);
|
2003-11-30 20:29:09 +00:00
|
|
|
if (PrevForegroundQueue != Window->MessageQueue)
|
|
|
|
{
|
|
|
|
/* FIXME: Send WM_ACTIVATEAPP to all thread windows. */
|
|
|
|
}
|
2004-01-12 20:48:48 +00:00
|
|
|
IntSendSetFocusMessages(hWndFocusPrev, hWndFocus);
|
|
|
|
IntSendActivateMessages(hWndPrev, hWnd, MouseActivate);
|
2004-02-24 01:30:58 +00:00
|
|
|
|
2003-11-30 20:29:09 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-01-12 20:48:48 +00:00
|
|
|
BOOL FASTCALL
|
|
|
|
IntSetForegroundWindow(PWINDOW_OBJECT Window)
|
|
|
|
{
|
|
|
|
return IntSetForegroundAndFocusWindow(Window, Window, FALSE);
|
|
|
|
}
|
|
|
|
|
2004-01-27 08:49:58 +00:00
|
|
|
BOOL FASTCALL
|
2004-01-12 20:48:48 +00:00
|
|
|
IntMouseActivateWindow(PWINDOW_OBJECT Window)
|
|
|
|
{
|
|
|
|
HWND Top;
|
|
|
|
PWINDOW_OBJECT TopWindow;
|
2004-01-27 08:49:58 +00:00
|
|
|
|
|
|
|
if(Window->Style & WS_DISABLED)
|
|
|
|
{
|
2004-01-27 11:52:37 +00:00
|
|
|
BOOL Ret;
|
|
|
|
PWINDOW_OBJECT TopWnd;
|
|
|
|
PWINDOW_OBJECT DesktopWindow = IntGetWindowObject(IntGetDesktopWindow());
|
|
|
|
if(DesktopWindow)
|
|
|
|
{
|
|
|
|
Top = IntFindChildWindowToOwner(DesktopWindow, Window);
|
2004-02-24 01:30:58 +00:00
|
|
|
if((TopWnd = IntGetWindowObject(Top)))
|
2004-01-27 11:52:37 +00:00
|
|
|
{
|
|
|
|
Ret = IntMouseActivateWindow(TopWnd);
|
|
|
|
IntReleaseWindowObject(TopWnd);
|
|
|
|
IntReleaseWindowObject(DesktopWindow);
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
IntReleaseWindowObject(DesktopWindow);
|
|
|
|
}
|
2004-01-27 08:49:58 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-01-16 13:26:26 +00:00
|
|
|
Top = NtUserGetAncestor(Window->Self, GA_ROOT);
|
2004-01-12 20:48:48 +00:00
|
|
|
if (Top != Window->Self)
|
|
|
|
{
|
|
|
|
TopWindow = IntGetWindowObject(Top);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TopWindow = Window;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSetForegroundAndFocusWindow(TopWindow, Window, TRUE);
|
|
|
|
|
|
|
|
if (Top != Window->Self)
|
|
|
|
{
|
|
|
|
IntReleaseWindowObject(TopWindow);
|
|
|
|
}
|
2004-01-27 08:49:58 +00:00
|
|
|
return TRUE;
|
2004-01-12 20:48:48 +00:00
|
|
|
}
|
|
|
|
|
2003-11-30 20:29:09 +00:00
|
|
|
HWND FASTCALL
|
|
|
|
IntSetActiveWindow(PWINDOW_OBJECT Window)
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
HWND hWndPrev;
|
|
|
|
HWND hWnd = 0;
|
|
|
|
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
ASSERT(ThreadQueue != 0);
|
|
|
|
|
|
|
|
if (Window != 0)
|
|
|
|
{
|
2003-11-30 22:48:11 +00:00
|
|
|
if (!(Window->Style & WS_VISIBLE) ||
|
|
|
|
(Window->Style & (WS_POPUP | WS_CHILD)) == WS_CHILD)
|
2003-11-30 20:29:09 +00:00
|
|
|
{
|
2003-11-30 22:48:11 +00:00
|
|
|
return ThreadQueue ? 0 : ThreadQueue->ActiveWindow;
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
hWnd = Window->Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
hWndPrev = ThreadQueue->ActiveWindow;
|
|
|
|
if (hWndPrev == hWnd)
|
|
|
|
{
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: Call hooks. */
|
|
|
|
|
2004-02-24 13:27:03 +00:00
|
|
|
IntLockMessageQueue(ThreadQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
ThreadQueue->ActiveWindow = hWnd;
|
2004-02-24 13:27:03 +00:00
|
|
|
IntUnLockMessageQueue(ThreadQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
|
|
|
|
IntSendDeactivateMessages(hWndPrev, hWnd);
|
2004-01-12 20:48:48 +00:00
|
|
|
IntSendActivateMessages(hWndPrev, hWnd, FALSE);
|
2003-11-30 20:29:09 +00:00
|
|
|
|
|
|
|
/* FIXME */
|
|
|
|
/* return IntIsWindow(hWndPrev) ? hWndPrev : 0;*/
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND FASTCALL
|
2004-02-24 01:30:58 +00:00
|
|
|
IntSetFocusWindow(HWND hWnd)
|
2003-11-30 20:29:09 +00:00
|
|
|
{
|
|
|
|
HWND hWndPrev = 0;
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
ASSERT(ThreadQueue != 0);
|
|
|
|
|
|
|
|
hWndPrev = ThreadQueue->FocusWindow;
|
|
|
|
if (hWndPrev == hWnd)
|
|
|
|
{
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
|
2004-02-24 13:27:03 +00:00
|
|
|
IntLockMessageQueue(ThreadQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
ThreadQueue->FocusWindow = hWnd;
|
2004-02-24 13:27:03 +00:00
|
|
|
IntUnLockMessageQueue(ThreadQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
|
|
|
|
IntSendKillFocusMessages(hWndPrev, hWnd);
|
|
|
|
IntSendSetFocusMessages(hWndPrev, hWnd);
|
|
|
|
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HWND STDCALL
|
|
|
|
NtUserGetForegroundWindow(VOID)
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ForegroundQueue = IntGetFocusMessageQueue();
|
|
|
|
return ForegroundQueue != NULL ? ForegroundQueue->ActiveWindow : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HWND STDCALL
|
|
|
|
NtUserGetActiveWindow(VOID)
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
return ThreadQueue ? ThreadQueue->ActiveWindow : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
HWND STDCALL
|
|
|
|
NtUserSetActiveWindow(HWND hWnd)
|
|
|
|
{
|
|
|
|
DPRINT("NtUserSetActiveWindow(%x)\n", hWnd);
|
|
|
|
|
|
|
|
if (hWnd)
|
|
|
|
{
|
|
|
|
PWINDOW_OBJECT Window;
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
HWND hWndPrev;
|
|
|
|
|
|
|
|
Window = IntGetWindowObject(hWnd);
|
|
|
|
if (Window == NULL)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINT("(%wZ)\n", &Window->WindowName);
|
|
|
|
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
|
|
|
|
if (Window->MessageQueue != ThreadQueue)
|
|
|
|
{
|
|
|
|
IntReleaseWindowObject(Window);
|
|
|
|
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
hWndPrev = IntSetActiveWindow(Window);
|
|
|
|
IntReleaseWindowObject(Window);
|
|
|
|
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return IntSetActiveWindow(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HWND STDCALL
|
|
|
|
NtUserGetCapture(VOID)
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
return ThreadQueue ? ThreadQueue->CaptureWindow : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HWND STDCALL
|
|
|
|
NtUserSetCapture(HWND hWnd)
|
|
|
|
{
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
PWINDOW_OBJECT Window;
|
|
|
|
HWND hWndPrev;
|
|
|
|
|
|
|
|
DPRINT("NtUserSetCapture(%x)\n", hWnd);
|
|
|
|
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
Window = IntGetWindowObject(hWnd);
|
|
|
|
if (Window != 0)
|
|
|
|
{
|
|
|
|
if (Window->MessageQueue != ThreadQueue)
|
|
|
|
{
|
|
|
|
IntReleaseWindowObject(Window);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
hWndPrev = ThreadQueue->CaptureWindow;
|
2004-04-13 13:50:31 +00:00
|
|
|
IntPostOrSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd);
|
2004-02-24 13:27:03 +00:00
|
|
|
IntLockMessageQueue(ThreadQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
ThreadQueue->CaptureWindow = hWnd;
|
2004-02-24 13:27:03 +00:00
|
|
|
IntUnLockMessageQueue(ThreadQueue);
|
2003-11-30 20:29:09 +00:00
|
|
|
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HWND STDCALL
|
|
|
|
NtUserSetFocus(HWND hWnd)
|
|
|
|
{
|
|
|
|
DPRINT("NtUserSetFocus(%x)\n", hWnd);
|
|
|
|
|
|
|
|
if (hWnd)
|
|
|
|
{
|
|
|
|
PWINDOW_OBJECT Window;
|
|
|
|
PUSER_MESSAGE_QUEUE ThreadQueue;
|
|
|
|
HWND hWndPrev, hWndTop;
|
|
|
|
|
|
|
|
Window = IntGetWindowObject(hWnd);
|
|
|
|
if (Window == NULL)
|
|
|
|
{
|
|
|
|
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
|
|
|
|
|
|
|
|
if (Window->Style & (WS_MINIMIZE | WS_DISABLED))
|
|
|
|
{
|
|
|
|
IntReleaseWindowObject(Window);
|
|
|
|
return ThreadQueue ? 0 : ThreadQueue->FocusWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Window->MessageQueue != ThreadQueue)
|
|
|
|
{
|
|
|
|
IntReleaseWindowObject(Window);
|
|
|
|
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-01-16 13:26:26 +00:00
|
|
|
hWndTop = NtUserGetAncestor(hWnd, GA_ROOT);
|
2003-11-30 20:29:09 +00:00
|
|
|
if (hWndTop != NtUserGetActiveWindow())
|
|
|
|
{
|
|
|
|
NtUserSetActiveWindow(hWndTop);
|
|
|
|
}
|
|
|
|
|
2004-02-24 01:30:58 +00:00
|
|
|
hWndPrev = IntSetFocusWindow(hWnd);
|
2003-11-30 20:29:09 +00:00
|
|
|
IntReleaseWindowObject(Window);
|
|
|
|
|
|
|
|
return hWndPrev;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-02-24 01:30:58 +00:00
|
|
|
return IntSetFocusWindow(NULL);
|
2003-11-30 20:29:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|