Work on activation/focus.

svn path=/trunk/; revision=6833
This commit is contained in:
Filip Navara 2003-11-30 20:03:47 +00:00
parent 863613cbbd
commit 791bef9a1b
16 changed files with 157 additions and 565 deletions

View file

@ -113,11 +113,16 @@ NtUserCallHwnd(
DWORD Unknown0,
DWORD Unknown1);
#define HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS 0x54
#define HWNDLOCK_ROUTINE_DRAWMENUBAR 0x55
#define HWNDLOCK_ROUTINE_REDRAWFRAME 0x58
#define HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW 0x5B
#define HWNDLOCK_ROUTINE_UPDATEWINDOW 0x5E
BOOL
STDCALL
NtUserCallHwndLock(
HWND hWnd,
DWORD Unknown1);
DWORD Routine);
#define HWNDOPT_ROUTINE_SETPROGMANWINDOW 0x4A
#define HWNDOPT_ROUTINE_SETTASKMANWINDOW 0x4B
@ -689,7 +694,7 @@ UINT
STDCALL
NtUserGetDoubleClickTime(VOID);
DWORD
HWND
STDCALL
NtUserGetForegroundWindow(VOID);

View file

@ -330,7 +330,7 @@ DefWndNCPaint(HWND hWnd, HRGN hRgn)
}
ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
Active = (GetActiveWindow() == hWnd);
Active = (GetForegroundWindow() == hWnd);
GetWindowRect(hWnd, &WindowRect);
GetClientRect(hWnd, &ClientRect);

View file

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.82 2003/11/18 23:33:31 weiden Exp $
/* $Id: window.c,v 1.83 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@ -702,8 +702,7 @@ GetDesktopWindow(VOID)
HWND STDCALL
GetForegroundWindow(VOID)
{
UNIMPLEMENTED;
return (HWND)0;
return NtUserGetForegroundWindow();
}
@ -1351,8 +1350,7 @@ RealChildWindowFromPoint(HWND hwndParent,
WINBOOL STDCALL
SetForegroundWindow(HWND hWnd)
{
UNIMPLEMENTED;
return FALSE;
return NtUserCallHwndLock(hWnd, HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW);
}
@ -1663,14 +1661,13 @@ GetSystemMenu(
}
/*
* @unimplemented
* @implemented
*/
HWND
STDCALL
GetFocus(VOID)
{
UNIMPLEMENTED;
return (HWND)0;
return (HWND)NtUserGetThreadState(0);
}
/*

View file

@ -85,7 +85,6 @@ typedef struct _DESKTOP_OBJECT
/* Handle of the desktop window. */
HANDLE DesktopWindow;
HANDLE PrevActiveWindow;
struct _WINDOW_OBJECT* CaptureWindow;
} DESKTOP_OBJECT, *PDESKTOP_OBJECT;

View file

@ -135,12 +135,6 @@ IntIsChildWindow (HWND Parent, HWND Child);
HWND FASTCALL
IntGetDesktopWindow (VOID);
HWND FASTCALL
IntGetFocusWindow (VOID);
HWND FASTCALL
IntSetFocusWindow (HWND hWnd);
BOOL FASTCALL
IntSetProp(PWINDOW_OBJECT Wnd, ATOM Atom, HANDLE Data);

View file

@ -52,11 +52,13 @@ IntInitializeDesktopGraphics(VOID);
VOID FASTCALL
IntEndDesktopGraphics(VOID);
/*
struct _WINDOW_OBJECT* FASTCALL
IntGetCaptureWindow(VOID);
VOID FASTCALL
IntSetCaptureWindow(struct _WINDOW_OBJECT* Window);
*/
PUSER_MESSAGE_QUEUE FASTCALL
IntGetFocusMessageQueue(VOID);

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.83 2003/11/23 11:39:48 navaraf Exp $
# $Id: makefile,v 1.84 2003/11/30 20:03:47 navaraf Exp $
PATH_TO_TOP = ../..
@ -48,13 +48,13 @@ MISC_OBJECTS = misc/driver.o misc/error.o misc/math.o misc/object.o
LDR_OBJECTS = ldr/loader.o
NTUSER_OBJECTS = ntuser/callback.o ntuser/caret.o ntuser/class.o ntuser/guicheck.o \
ntuser/hook.o ntuser/hotkey.o ntuser/input.o ntuser/keyboard.o \
ntuser/menu.o ntuser/message.o ntuser/metric.o ntuser/misc.o \
ntuser/msgqueue.o ntuser/painting.o ntuser/prop.o ntuser/scrollbar.o \
ntuser/stubs.o ntuser/timer.o ntuser/userobj.o ntuser/vis.o \
ntuser/windc.o ntuser/window.o ntuser/winlock.o ntuser/winpos.o \
ntuser/winsta.o
NTUSER_OBJECTS = ntuser/callback.o ntuser/caret.o ntuser/class.o ntuser/focus.o \
ntuser/guicheck.o ntuser/hook.o ntuser/hotkey.o ntuser/input.o \
ntuser/keyboard.o ntuser/menu.o ntuser/message.o ntuser/metric.o \
ntuser/misc.o ntuser/msgqueue.o ntuser/painting.o ntuser/prop.o \
ntuser/scrollbar.o ntuser/stubs.o ntuser/timer.o ntuser/userobj.o \
ntuser/vis.o ntuser/windc.o ntuser/window.o ntuser/winlock.o \
ntuser/winpos.o ntuser/winsta.o
OBJECTS_OBJECTS = objects/bitmaps.o objects/brush.o objects/cliprgn.o \
objects/color.o objects/coord.o objects/dc.o \

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: input.c,v 1.22 2003/11/24 16:15:00 gvg Exp $
/* $Id: input.c,v 1.23 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -172,15 +172,20 @@ KeyboardThreadMain(PVOID StartContext)
msg.message = WM_KEYUP;
/* Find the target thread whose locale is in effect */
FocusQueue = IntGetFocusMessageQueue();
if (!FocusQueue) {
FocusQueue = W32kGetPrimitiveMessageQueue();
}
if (!IntGetScreenDC())
{
FocusQueue = W32kGetPrimitiveMessageQueue();
}
else
{
FocusQueue = IntGetFocusMessageQueue();
}
if (!FocusQueue) continue;
msg.wParam = KeyEvent.wVirtualKeyCode;
msg.lParam = lParam;
if (!FocusQueue) continue;
msg.hwnd = FocusQueue->FocusWindow;
FocusThread = FocusQueue->Thread;

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: keyboard.c,v 1.18 2003/11/25 22:28:00 gvg Exp $
/* $Id: keyboard.c,v 1.19 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -670,12 +670,6 @@ NtUserTranslateMessage(LPMSG lpMsg,
return Result;
}
HWND STDCALL
NtUserSetFocus(HWND hWnd)
{
return IntSetFocusWindow(hWnd);
}
DWORD
STDCALL
NtUserGetKeyboardState(

View file

@ -1,4 +1,4 @@
/* $Id: misc.c,v 1.31 2003/11/24 16:19:58 gvg Exp $
/* $Id: misc.c,v 1.32 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -21,6 +21,7 @@
#include <include/winsta.h>
#include <include/caret.h>
#include <include/object.h>
#include <include/focus.h>
#define NDEBUG
#include <debug.h>
@ -275,6 +276,54 @@ NtUserCallTwoParam(
return 0;
}
/*
* @unimplemented
*/
BOOL
STDCALL
NtUserCallHwndLock(
HWND hWnd,
DWORD Routine)
{
BOOL Ret = 0;
PWINDOW_OBJECT Window;
Window = IntGetWindowObject(hWnd);
if (Window == 0)
{
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return FALSE;
}
/* FIXME: Routine can be 0x53 - 0x5E */
switch (Routine)
{
case HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS:
/* FIXME */
break;
case HWNDLOCK_ROUTINE_DRAWMENUBAR:
/* FIXME */
break;
case HWNDLOCK_ROUTINE_REDRAWFRAME:
/* FIXME */
break;
case HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOW:
Ret = IntSetForegroundWindow(Window);
break;
case HWNDLOCK_ROUTINE_UPDATEWINDOW:
/* FIXME */
break;
}
IntReleaseWindowObject(Window);
return Ret;
}
HWND
STDCALL
NtUserCallHwndOpt(
@ -295,6 +344,21 @@ NtUserCallHwndOpt(
return 0;
}
/*
* @unimplemented
*/
DWORD STDCALL
NtUserGetThreadState(
DWORD Routine)
{
switch (Routine)
{
case 0:
return (DWORD)IntGetThreadFocusWindow();
}
return 0;
}
/*
* @implemented
*/

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: msgqueue.c,v 1.38 2003/11/24 00:22:53 arty Exp $
/* $Id: msgqueue.c,v 1.39 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -40,6 +40,7 @@
#include <include/object.h>
#include <include/input.h>
#include <include/cursoricon.h>
#include <include/focus.h>
#define NDEBUG
#include <win32k/debug1.h>
@ -239,12 +240,12 @@ MsqTranslateMouseMessage(HWND hWnd, UINT FilterLow, UINT FilterHigh,
case MA_NOACTIVATE:
break;
case MA_ACTIVATEANDEAT:
IntSetFocusWindow(Wnd);
NtUserSetFocus(Wnd);
return TRUE;
/* case MA_ACTIVATE:
case 0:*/
default:
IntSetFocusWindow(Wnd);
NtUserSetFocus(Wnd);
break;
}
}
@ -259,12 +260,13 @@ MsqTranslateMouseMessage(HWND hWnd, UINT FilterLow, UINT FilterHigh,
CaptureWin = IntGetCaptureWindow();
if ((Window = CaptureWin) == NULL)
if (CaptureWin == NULL)
{
*HitTest = WinPosWindowFromPoint(ScopeWin, Message->Msg.pt, &Window);
}
else
{
Window = IntGetWindowObject(CaptureWin);
*HitTest = HTCLIENT;
}
@ -513,6 +515,7 @@ MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (FocusMessageQueue->FocusWindow != (HWND)0)
{
Msg.hwnd = FocusMessageQueue->FocusWindow;
DPRINT("Msg.hwnd = %x\n", Msg.hwnd);
Message = MsqCreateMessage(&Msg);
MsqPostMessage(FocusMessageQueue, Message);
}

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: painting.c,v 1.39 2003/11/25 23:46:23 gvg Exp $
* $Id: painting.c,v 1.40 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -694,7 +694,12 @@ IntGetPaintMessage(PWINDOW_OBJECT Wnd, PW32THREAD Thread, MSG *Message,
if (Message->hwnd == NULL)
{
#if 0
DPRINT1("PAINTING BUG: Thread marked as containing dirty windows, but no dirty windows found!\n");
/* FIXME: Lock the queue! */
MessageQueue->PaintPosted = 0;
MessageQueue->PaintCount = 0;
#endif
return FALSE;
}

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.39 2003/11/23 11:39:48 navaraf Exp $
/* $Id: stubs.c,v 1.40 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -569,16 +569,6 @@ NtUserGetPriorityClipboardFormat(
return 0;
}
DWORD
STDCALL
NtUserGetThreadState(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD
STDCALL
NtUserGetTitleBarInfo(

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: window.c,v 1.148 2003/11/25 22:06:31 gvg Exp $
/* $Id: window.c,v 1.149 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -48,6 +48,7 @@
#include <include/vis.h>
#include <include/menu.h>
#include <include/hotkey.h>
#include <include/focus.h>
#define NDEBUG
#include <win32k/debug1.h>
@ -407,23 +408,6 @@ DestroyThreadWindows(struct _ETHREAD *Thread)
}
HWND FASTCALL
IntGetActiveWindow(VOID)
{
PUSER_MESSAGE_QUEUE Queue;
Queue = (PUSER_MESSAGE_QUEUE)IntGetActiveDesktop()->ActiveMessageQueue;
if (Queue == NULL)
{
return(NULL);
}
else
{
return(Queue->ActiveWindow);
}
}
/*!
* Internal function.
* Returns client window rectangle relative to the upper-left corner of client area.
@ -449,6 +433,7 @@ HWND FASTCALL IntGetDesktopWindow(VOID)
}
#if 0
HWND FASTCALL
IntGetFocusWindow(VOID)
{
@ -465,6 +450,7 @@ IntGetFocusWindow(VOID)
else
return(Queue->FocusWindow);
}
#endif
PWINDOW_OBJECT FASTCALL
IntGetParent(PWINDOW_OBJECT Wnd)
@ -715,184 +701,6 @@ IntLinkWindow(
}
/*****************************************************************
* set_focus_window
*
* Change the focus window, sending the WM_SETFOCUS and WM_KILLFOCUS messages
*/
#if 0
static HWND FASTCALL
set_focus_window(HWND New, PWINDOW_OBJECT Window, HWND Previous)
{
PDESKTOP_OBJECT Desktop;
ASSERT(NULL == Window || New == Window->Self);
Desktop = IntGetActiveDesktop();
ASSERT(NULL != Desktop);
if (Window != NULL)
{
Window->MessageQueue->FocusWindow = New;
(PUSER_MESSAGE_QUEUE)Desktop->ActiveMessageQueue =
Window->MessageQueue;
}
else
{
(PUSER_MESSAGE_QUEUE) Desktop->ActiveMessageQueue = NULL;
}
if (Previous == New)
{
return Previous;
}
if (NULL != Previous)
{
NtUserSendMessage(Previous, WM_KILLFOCUS, (WPARAM) New, 0);
if ((NULL == Desktop->ActiveMessageQueue && NULL != New)
|| (NULL != Desktop->ActiveMessageQueue
&& ((PUSER_MESSAGE_QUEUE)(Desktop->ActiveMessageQueue))->FocusWindow != New))
{
/* changed by the message */
return Previous;
}
}
if (IntIsWindow(New))
{
NtUserSendMessage(New, WM_SETFOCUS, (WPARAM) Previous, 0);
}
return Previous;
}
#endif
HWND FASTCALL
IntSetFocusWindow(HWND hWnd)
{
#if 0
PUSER_MESSAGE_QUEUE OldMessageQueue;
PDESKTOP_OBJECT DesktopObject;
PWINDOW_OBJECT WindowObject;
HWND hWndOldFocus;
HWND hWndTop;
DPRINT("IntSetFocusWindow(hWnd 0x%x)\n", hWnd);
if (hWnd != (HWND)0)
{
WindowObject = IntGetWindowObject(hWnd);
if (!WindowObject || IntIsDesktopWindow(WindowObject))
{
DPRINT("Bad window handle 0x%x\n", hWnd);
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return (HWND)0;
}
}
else
{
WindowObject = NULL;
}
DesktopObject = IntGetActiveDesktop();
if (! DesktopObject)
{
DPRINT("No active desktop\n");
if (WindowObject != NULL)
{
IntReleaseWindowObject(WindowObject);
}
SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE);
return (HWND)0;
}
hWndOldFocus = (HWND)0;
OldMessageQueue = (PUSER_MESSAGE_QUEUE)DesktopObject->ActiveMessageQueue;
if (OldMessageQueue != NULL)
{
hWndOldFocus = OldMessageQueue->FocusWindow;
}
if (hWndOldFocus == hWnd)
{
/* Nothing to do */
IntReleaseWindowObject(WindowObject);
return hWndOldFocus;
}
if (NULL != WindowObject)
{
hWndTop = hWnd;
for (;;)
{
LONG style = NtUserGetWindowLong(hWndTop, GWL_STYLE, FALSE);
if (style & (WS_MINIMIZE | WS_DISABLED))
{
IntReleaseWindowObject(WindowObject);
return NULL;
}
if (! (style & WS_CHILD))
{
break;
}
hWndTop = NtUserGetAncestor(hWndTop, GA_PARENT);
}
#if 0 /* FIXME */
/* call hooks */
if (HOOK_CallHooks(WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)previous, TRUE))
{
IntReleaseWindowObject(WindowObject);
return NULL;
}
#endif
/* activate hWndTop if needed. */
if (hWndTop != NtUserGetActiveWindow())
{
#ifdef TODO
if (! set_active_window(hWndTop, NULL, FALSE, FALSE))
{
return NULL;
}
#endif
#if 0 /* FIXME */
if (! NtUserIsWindow(hWnd))
{
/* Abort if window destroyed */
return NULL;
}
#endif
}
}
#if 0 /* FIXME */
else
{
/* call hooks */
if (HOOK_CallHooks(WH_CBT, HCBT_SETFOCUS, (WPARAM)hwnd, (LPARAM)previous, TRUE))
{
IntReleaseWindowObject(WindowObject);
return NULL;
}
}
#endif
hWndOldFocus = set_focus_window(hWnd, WindowObject, hWndOldFocus);
if (WindowObject != NULL)
{
IntReleaseWindowObject(WindowObject);
}
DPRINT("hWndOldFocus = 0x%x\n", hWndOldFocus);
return hWndOldFocus;
#endif
return 0;
}
HWND FASTCALL
IntSetOwner(HWND hWnd, HWND hWndNewOwner)
{
@ -1233,21 +1041,6 @@ NtUserBuildHwndList(
}
/*
* @unimplemented
*/
BOOL
STDCALL
NtUserCallHwndLock(
HWND hWnd,
DWORD Unknown1)
{
UNIMPLEMENTED
/* DrawMenuBar() calls it with Unknown1==0x55 */
return 0;
}
/*
* @unimplemented
*/
@ -1638,7 +1431,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
SW_MAXIMIZE;
WinPosMinMaximize(WindowObject, SwFlag, &NewPos);
SwFlag =
((WindowObject->Style & WS_CHILD) || IntGetActiveWindow()) ?
((WindowObject->Style & WS_CHILD) || NtUserGetActiveWindow()) ?
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED :
SWP_NOZORDER | SWP_FRAMECHANGED;
DPRINT("NtUserCreateWindow(): About to minimize/maximize\n");
@ -1662,9 +1455,11 @@ NtUserCreateWindowEx(DWORD dwExStyle,
DPRINT("NtUserCreateWindow(): About to show window\n");
WinPosShowWindow(WindowObject->Self, dwShowMode);
}
/* FIXME: Should code be reworked to accomodate the following line? */
DPRINT("Setting Active Window to %d\n\n\n",WindowObject->Self);
NtUserSetActiveWindow(WindowObject->Self);
else if (NtUserGetActiveWindow() == NULL)
{
NtUserSetActiveWindow(WindowObject->Self);
}
DPRINT("NtUserCreateWindow(): = %X\n", Handle);
DPRINT("WindowObject->SystemMenu = 0x%x\n", WindowObject->SystemMenu);
return((HWND)Handle);
@ -1698,7 +1493,6 @@ NtUserDestroyWindow(HWND Wnd)
{
PWINDOW_OBJECT Window;
BOOLEAN isChild;
HWND hWndFocus;
Window = IntGetWindowObject(Wnd);
if (Window == NULL)
@ -1717,16 +1511,7 @@ NtUserDestroyWindow(HWND Wnd)
/* Look whether the focus is within the tree of windows we will
* be destroying.
*/
hWndFocus = IntGetFocusWindow();
if (hWndFocus == Wnd || IntIsChildWindow(Wnd, hWndFocus))
{
HWND Parent = NtUserGetAncestor(Wnd, GA_PARENT);
if (Parent == IntGetDesktopWindow())
{
Parent = NULL;
}
IntSetFocusWindow(Parent);
}
WinPosActivateOtherWindow(Window);
/* Call hooks */
#if 0 /* FIXME */
@ -2069,26 +1854,6 @@ NtUserGetAncestor(HWND hWnd, UINT Type)
}
/*
* @implemented
*/
HWND
STDCALL
NtUserGetCapture(VOID)
{
PWINDOW_OBJECT Window;
Window = IntGetCaptureWindow();
if (Window != NULL)
{
return(Window->Self);
}
else
{
return(NULL);
}
}
/*!
* Returns client window rectangle relative to the upper-left corner of client area.
*
@ -2135,18 +1900,6 @@ NtUserGetDesktopWindow()
}
/*
* @unimplemented
*/
DWORD STDCALL
NtUserGetForegroundWindow(VOID)
{
UNIMPLEMENTED
return 0;
}
/*
* @unimplemented
*/
@ -3100,43 +2853,6 @@ NtUserScrollWindowEx(DWORD Unknown0,
}
/*
* @implemented
*/
HWND STDCALL
NtUserSetCapture(HWND Wnd)
{
PWINDOW_OBJECT Window;
PWINDOW_OBJECT Prev;
Prev = IntGetCaptureWindow();
if (Prev != NULL)
{
IntSendMessage(Prev->Self, WM_CAPTURECHANGED, 0L, (LPARAM)Wnd, FALSE);
}
if (Wnd == NULL)
{
IntSetCaptureWindow(NULL);
}
else
{
Window = IntGetWindowObject(Wnd);
IntSetCaptureWindow(Window);
IntReleaseWindowObject(Window);
}
if (Prev != NULL)
{
return(Prev->Self);
}
else
{
return(NULL);
}
}
/*
* @unimplemented
*/

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: winpos.c,v 1.47 2003/11/24 21:01:20 navaraf Exp $
/* $Id: winpos.c,v 1.48 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -42,6 +42,7 @@
#include <include/painting.h>
#include <include/dce.h>
#include <include/vis.h>
#include <include/focus.h>
#define NDEBUG
#include <debug.h>
@ -129,9 +130,7 @@ void FASTCALL
WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
{
HWND hwndTo;
#if 0
HWND fg;
#endif
if ((NtUserGetWindowLong(Window->Self, GWL_STYLE, FALSE) & WS_POPUP)
&& (hwndTo = NtUserGetWindow(Window->Self, GW_OWNER)))
@ -154,17 +153,18 @@ WinPosActivateOtherWindow(PWINDOW_OBJECT Window)
}
done:
#ifdef TODO
fg = NtUserGetForegroundWindow();
/* TRACE("win = %p fg = %p\n", hwndTo, fg); */
if (! fg || (hwnd == fg))
if (! fg || (hwndTo == fg))
{
if (NtUserSetForegroundWindow(hwndTo))
PWINDOW_OBJECT ToWindow = IntGetWindowObject(hwndTo);
if (IntSetForegroundWindow(ToWindow))
{
IntReleaseWindowObject(ToWindow);
return;
}
IntReleaseWindowObject(Window);
}
#endif
if (! NtUserSetActiveWindow(hwndTo))
{
@ -423,6 +423,7 @@ WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
return 0; //FIXME: what does it return?
}
#if 0
BOOL STATIC FASTCALL
WinPosChangeActiveWindow(HWND hWnd, BOOL MouseMsg)
{
@ -434,16 +435,20 @@ WinPosChangeActiveWindow(HWND hWnd, BOOL MouseMsg)
return FALSE;
}
#if 0
NtUserSendMessage(hWnd,
WM_ACTIVATE,
MAKELONG(MouseMsg ? WA_CLICKACTIVE : WA_CLICKACTIVE,
(WindowObject->Style & WS_MINIMIZE) ? 1 : 0),
(LPARAM)IntGetDesktopWindow()); /* FIXME: Previous active window */
#endif
IntSetForegroundWindow(WindowObject);
IntReleaseWindowObject(WindowObject);
return TRUE;
}
#endif
LONG STATIC STDCALL
WinPosDoNCCALCSize(PWINDOW_OBJECT Window, PWINDOWPOS WinPos,
@ -641,14 +646,11 @@ WinPosFixupFlags(WINDOWPOS *WinPos, PWINDOW_OBJECT Window)
WinPos->flags |= SWP_NOMOVE;
}
/* FIXME: We don't have NtUserGetForegroundWindow yet. */
#if 0
if (WinPos->hwnd == NtUserGetForegroundWindow())
{
WinPos->flags |= SWP_NOACTIVATE; /* Already active */
}
else
#endif
if ((Window->Style & (WS_POPUP | WS_CHILD)) != WS_CHILD)
{
/* Bring to the top when activating */
@ -864,11 +866,6 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx,
Window->Style |= WS_VISIBLE;
}
if (!(WinPos.flags & SWP_NOACTIVATE))
{
WinPosChangeActiveWindow(WinPos.hwnd, FALSE);
}
/* Determine the new visible region */
VisAfter = VIS_ComputeVisibleRegion(
PsGetWin32Thread()->Desktop, Window, FALSE, FALSE, TRUE);
@ -1017,6 +1014,18 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx,
IntRedrawWindow(Window, NULL, 0, RDW_ALLCHILDREN | RDW_ERASENOW);
}
if (!(WinPos.flags & SWP_NOACTIVATE))
{
if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD)
{
NtUserSendMessage(WinPos.hwnd, WM_CHILDACTIVATE, 0, 0);
}
else
{
IntSetForegroundWindow(Window);
}
}
/* FIXME: Check some conditions before doing this. */
IntSendWINDOWPOSCHANGEDMessage(WinPos.hwnd, &WinPos);
@ -1139,7 +1148,6 @@ WinPosShowWindow(HWND Wnd, INT Cmd)
*/
}
#if 1
/* We can't activate a child window */
if ((Window->Style & WS_CHILD) &&
!(Window->ExStyle & WS_EX_MDICHILD))
@ -1157,16 +1165,16 @@ WinPosShowWindow(HWND Wnd, INT Cmd)
* asynchronously.
*/
if (Window->Self == IntGetActiveWindow())
if (Window->Self == NtUserGetActiveWindow())
{
WinPosActivateOtherWindow(Window);
}
/* Revert focus to parent */
if (Wnd == IntGetFocusWindow() ||
IntIsChildWindow(Wnd, IntGetFocusWindow()))
if (Wnd == IntGetThreadFocusWindow() ||
IntIsChildWindow(Wnd, IntGetThreadFocusWindow()))
{
IntSetFocusWindow(Window->Parent->Self);
NtUserSetFocus(Window->Parent->Self);
}
}
@ -1176,58 +1184,6 @@ WinPosShowWindow(HWND Wnd, INT Cmd)
{
WinPosShowIconTitle(Window, TRUE);
}
#else
if (Window->Style & WS_CHILD &&
!IntIsWindowVisible(Window->Parent->Self) &&
(Swp & (SWP_NOSIZE | SWP_NOMOVE)) == (SWP_NOSIZE | SWP_NOMOVE))
{
if (Cmd == SW_HIDE)
{
VisibleRgn = VIS_ComputeVisibleRegion(PsGetWin32Thread()->Desktop, Window,
FALSE, FALSE, FALSE);
Window->Style &= ~WS_VISIBLE;
VIS_WindowLayoutChanged(PsGetWin32Thread()->Desktop, Window, VisibleRgn);
NtGdiDeleteObject(VisibleRgn);
}
else
{
Window->Style |= WS_VISIBLE;
}
}
else
{
if (Window->Style & WS_CHILD &&
!(Window->ExStyle & WS_EX_MDICHILD))
{
Swp |= SWP_NOACTIVATE | SWP_NOZORDER;
}
if (!(Swp & MINMAX_NOSWP))
{
WinPosSetWindowPos(Wnd, HWND_TOP, NewPos.left, NewPos.top,
NewPos.right, NewPos.bottom, LOWORD(Swp));
if (Cmd == SW_HIDE)
{
/* Hide the window. */
if (Wnd == IntGetActiveWindow())
{
WinPosActivateOtherWindow(Window);
}
/* Revert focus to parent. */
if (Wnd == IntGetFocusWindow() ||
IntIsChildWindow(Wnd, IntGetFocusWindow()))
{
IntSetFocusWindow(Window->Parent->Self);
}
}
}
/* FIXME: Check for window destruction. */
/* Show title for minimized windows. */
if (Window->Style & WS_MINIMIZE)
{
WinPosShowIconTitle(Window, TRUE);
}
}
#endif
if (Window->Flags & WINDOWOBJECT_NEED_SIZE)
{
@ -1254,10 +1210,12 @@ WinPosShowWindow(HWND Wnd, INT Cmd)
}
/* Activate the window if activation is not requested and the window is not minimized */
/*
if (!(Swp & (SWP_NOACTIVATE | SWP_HIDEWINDOW)) && !(Window->Style & WS_MINIMIZE))
{
WinPosChangeActiveWindow(Wnd, FALSE);
}
*/
ObmDereferenceObject(Window);
return(WasVisible);
@ -1365,120 +1323,4 @@ WinPosWindowFromPoint(PWINDOW_OBJECT ScopeWin, POINT WinPoint,
return(HitTest);
}
BOOL
WinPosSetActiveWindow(PWINDOW_OBJECT Window, BOOL Mouse, BOOL ChangeFocus)
{
PUSER_MESSAGE_QUEUE ActiveQueue;
HWND PrevActive;
ActiveQueue = IntGetFocusMessageQueue();
if (ActiveQueue != NULL)
{
PrevActive = ActiveQueue->ActiveWindow;
}
else
{
PrevActive = NULL;
}
if (Window->Self == IntGetActiveDesktop() || Window->Self == PrevActive)
{
return(FALSE);
}
if (PrevActive != NULL)
{
PWINDOW_OBJECT PrevActiveWindow = IntGetWindowObject(PrevActive);
if(PrevActiveWindow)
{
WORD Iconised = HIWORD(PrevActiveWindow->Style & WS_MINIMIZE);
if (!IntSendMessage(PrevActive, WM_NCACTIVATE, FALSE, 0, TRUE))
{
/* FIXME: Check if the new window is system modal. */
return(FALSE);
}
IntSendMessage(PrevActive,
WM_ACTIVATE,
MAKEWPARAM(WA_INACTIVE, Iconised),
(LPARAM)Window->Self,
TRUE);
/* FIXME: Check if anything changed while processing the message. */
IntReleaseWindowObject(PrevActiveWindow);
}
else
{
if(ActiveQueue)
ActiveQueue->ActiveWindow = NULL;
PrevActive = NULL;
}
}
if (Window != NULL)
{
Window->MessageQueue->ActiveWindow = Window->Self;
}
else if (ActiveQueue != NULL)
{
ActiveQueue->ActiveWindow = NULL;
}
/* FIXME: Unset this flag for inactive windows */
//if ((Window->Style) & WS_CHILD) Window->Flags |= WIN_NCACTIVATED;
/* FIXME: Send palette messages. */
/* FIXME: Redraw icon title of previously active window. */
/* FIXME: Bring the window to the top. */
/* FIXME: Send WM_ACTIVATEAPP */
IntSetFocusMessageQueue(Window->MessageQueue);
/* FIXME: Send activate messages. */
/* FIXME: Change focus. */
/* FIXME: Redraw new window icon title. */
return(TRUE);
}
HWND STDCALL
NtUserGetActiveWindow(VOID)
{
PUSER_MESSAGE_QUEUE ActiveQueue;
ActiveQueue = IntGetFocusMessageQueue();
if (ActiveQueue == NULL)
{
return(NULL);
}
return(ActiveQueue->ActiveWindow);
}
HWND STDCALL
NtUserSetActiveWindow(HWND hWnd)
{
PWINDOW_OBJECT Window;
PUSER_MESSAGE_QUEUE ThreadQueue;
HWND Prev;
Window = IntGetWindowObject(hWnd);
if (Window == NULL || (Window->Style & (WS_DISABLED | WS_CHILD)))
{
IntReleaseWindowObject(Window);
return(0);
}
ThreadQueue = (PUSER_MESSAGE_QUEUE)PsGetWin32Thread()->MessageQueue;
if (Window->MessageQueue != ThreadQueue)
{
IntReleaseWindowObject(Window);
return(0);
}
Prev = Window->MessageQueue->ActiveWindow;
WinPosSetActiveWindow(Window, FALSE, FALSE);
IntReleaseWindowObject(Window);
return(Prev);
}
/* EOF */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Id: winsta.c,v 1.48 2003/11/26 21:48:35 gvg Exp $
* $Id: winsta.c,v 1.49 2003/11/30 20:03:47 navaraf Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -328,30 +328,6 @@ IntGetActiveDesktop(VOID)
return InputDesktop;
}
PWINDOW_OBJECT FASTCALL
IntGetCaptureWindow(VOID)
{
PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
if (!pdo)
{
DPRINT("No active desktop\n");
return NULL;
}
return pdo->CaptureWindow;
}
VOID FASTCALL
IntSetCaptureWindow(PWINDOW_OBJECT Window)
{
PDESKTOP_OBJECT pdo = IntGetActiveDesktop();
if (!pdo)
{
DPRINT("No active desktop\n");
return;
}
pdo->CaptureWindow = Window;
}
PUSER_MESSAGE_QUEUE FASTCALL
IntGetFocusMessageQueue(VOID)
{