2003-07-05 Casper S. Hornstrup <chorns@users.sourceforge.net>

* include/win32k/ntuser.h (NtUserSetFocus): Correct prototype.
	* lib/user32/misc/stubs.c (SetFocus): Remove.
	* lib/user32/windows/defwnd.c (KEYDATA_ALT): New.
	(User32DefWindowProc): Handle WM_SYSKEYDOWN.
	* lib/user32/windows/input.c (SetFocus): New.
	* subsys/win32k/include/msgqueue.h (USER_MESSAGE_QUEUE): Document
	FocusWindow field.
	* subsys/win32k/include/window.h (W32kSetFocusWindow): Change return type
	to HWND.
	* subsys/win32k/include/winsta.h (W32kGetFocusMessageQueue): New.
	* subsys/win32k/ntuser/input.c (KeyboardThreadMain): Handle system keys.
	* subsys/win32k/ntuser/keyboard.c (NtUserSetFocus): New.
	* subsys/win32k/ntuser/msgqueue.c (MsqPostKeyboardMessage): Implement.
	* subsys/win32k/ntuser/stubs.c (NtUserSetFocus): Remove.
	* subsys/win32k/ntuser/window.c (W32kSetFocusWindow): Implement.
	(NtUserGetClientRect, W32kGetWindowProc, NtUserCreateWindowEx): Release
	window reference on error.
	(W32kDestroyWindow): Remove focus from window tree before destroying it
	if needed.
	* subsys/win32k/ntuser/winpos.c (WinPosChangeActiveWindow): Implement.
	(WinPosShowWindow): Activate window if needed.
	* subsys/win32k/ntuser/winsta.c (W32kGetFocusMessageQueue): New.

svn path=/trunk/; revision=5000
This commit is contained in:
Casper Hornstrup 2003-07-05 16:04:01 +00:00
parent 6c51b3072c
commit 9826d4e679
15 changed files with 259 additions and 72 deletions

View file

@ -1,6 +1,31 @@
2003-07-05 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/win32k/ntuser.h (NtUserSetFocus): Correct prototype.
* lib/user32/misc/stubs.c (SetFocus): Remove.
* lib/user32/windows/defwnd.c (KEYDATA_ALT): New.
(User32DefWindowProc): Handle WM_SYSKEYDOWN.
* lib/user32/windows/input.c (SetFocus): New.
* subsys/win32k/include/msgqueue.h (USER_MESSAGE_QUEUE): Document
FocusWindow field.
* subsys/win32k/include/window.h (W32kSetFocusWindow): Change return type
to HWND.
* subsys/win32k/include/winsta.h (W32kGetFocusMessageQueue): New.
* subsys/win32k/ntuser/input.c (KeyboardThreadMain): Handle system keys.
* subsys/win32k/ntuser/keyboard.c (NtUserSetFocus): New.
* subsys/win32k/ntuser/msgqueue.c (MsqPostKeyboardMessage): Implement.
* subsys/win32k/ntuser/stubs.c (NtUserSetFocus): Remove.
* subsys/win32k/ntuser/window.c (W32kSetFocusWindow): Implement.
(NtUserGetClientRect, W32kGetWindowProc, NtUserCreateWindowEx): Release
window reference on error.
(W32kDestroyWindow): Remove focus from window tree before destroying it
if needed.
* subsys/win32k/ntuser/winpos.c (WinPosChangeActiveWindow): Implement.
(WinPosShowWindow): Activate window if needed.
* subsys/win32k/ntuser/winsta.c (W32kGetFocusMessageQueue): New.
2003-06-27 Casper S. Hornstrup <chorns@users.sourceforge.net> 2003-06-27 Casper S. Hornstrup <chorns@users.sourceforge.net>
* lib/user32/controls/button.c (ButtonWndProc_comm): Fix unsigned/signed * lib/user32/controls/button.c (ButtonWndProc_common): Fix unsigned/signed
warning. warning.
2003-06-07 Casper S. Hornstrup <chorns@users.sourceforge.net> 2003-06-07 Casper S. Hornstrup <chorns@users.sourceforge.net>

View file

@ -1270,10 +1270,10 @@ NtUserSetDbgTag(
DWORD Unknown0, DWORD Unknown0,
DWORD Unknown1); DWORD Unknown1);
DWORD HWND
STDCALL STDCALL
NtUserSetFocus( NtUserSetFocus(
DWORD Unknown0); HWND hWnd);
DWORD DWORD
STDCALL STDCALL

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.23 2003/07/03 02:52:54 sedwards Exp $ /* $Id: stubs.c,v 1.24 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
@ -399,15 +399,6 @@ SetDoubleClickTime(
return FALSE; return FALSE;
} }
HWND
STDCALL
SetFocus(
HWND hWnd)
{
UNIMPLEMENTED;
return (HWND)0;
}
VOID VOID
STDCALL STDCALL
SetLastErrorEx( SetLastErrorEx(

View file

@ -1,4 +1,4 @@
/* $Id: defwnd.c,v 1.52 2003/06/24 00:55:02 rcampbell Exp $ /* $Id: defwnd.c,v 1.53 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
@ -71,6 +71,9 @@ static COLORREF SysColours[] =
static ATOM AtomInternalPos; static ATOM AtomInternalPos;
/* Bits in the dwKeyData */
#define KEYDATA_ALT 0x2000
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
BOOL IsMaxBoxActive(HWND hWnd) BOOL IsMaxBoxActive(HWND hWnd)
@ -1182,11 +1185,11 @@ User32DefWindowProc(HWND hWnd,
} }
case WM_ACTIVATE: case WM_ACTIVATE:
{
if (LOWORD(lParam) != WA_INACTIVE &&
GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE)
{ {
/* Check if the window is minimized. */ /* Check if the window is minimized. */
if (LOWORD(lParam) != WA_INACTIVE &&
!(GetWindowLong(hWnd, GWL_STYLE) & WS_MINIMIZE))
{
SetFocus(hWnd); SetFocus(hWnd);
} }
break; break;
@ -1370,6 +1373,30 @@ User32DefWindowProc(HWND hWnd,
} }
break; break;
} }
case WM_SYSKEYDOWN:
if (HIWORD(lParam) & KEYDATA_ALT)
{
if (wParam == VK_F4) /* Try to close the window */
{
//HWND hTopWnd = GetAncestor(hWnd, GA_ROOT);
HWND hTopWnd = hWnd;
if (!(GetClassLongW(hTopWnd, GCL_STYLE) & CS_NOCLOSE))
{
if (bUnicode)
{
PostMessageW(hTopWnd, WM_CLOSE, 0, 0);
PostMessageW(hTopWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
}
else
{
PostMessageA(hTopWnd, WM_CLOSE, 0, 0);
PostMessageA(hTopWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
}
}
}
}
break;
} }
return 0; return 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: input.c,v 1.6 2003/05/12 19:30:00 jfilby Exp $ /* $Id: input.c,v 1.7 2003/07/05 16:04:01 chorns Exp $
* *
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
* FILE: lib/user32/windows/input.c * FILE: lib/user32/windows/input.c
@ -209,6 +209,12 @@ OemKeyScan(WORD wOemChar)
return 0; return 0;
} }
HWND STDCALL
SetFocus(HWND hWnd)
{
return NtUserSetFocus(hWnd);
}
WINBOOL STDCALL WINBOOL STDCALL
SetKeyboardState(LPBYTE lpKeyState) SetKeyboardState(LPBYTE lpKeyState)
{ {

View file

@ -52,7 +52,7 @@ typedef struct _USER_MESSAGE_QUEUE
KEVENT NewMessages; KEVENT NewMessages;
/* FIXME: Unknown. */ /* FIXME: Unknown. */
ULONG QueueStatus; ULONG QueueStatus;
/* Current window with focus for this queue. */ /* Current window with focus (ie. receives keyboard input) for this queue. */
HWND FocusWindow; HWND FocusWindow;
/* True if a window needs painting. */ /* True if a window needs painting. */
BOOLEAN PaintPosted; BOOLEAN PaintPosted;

View file

@ -107,7 +107,7 @@ BOOL FASTCALL W32kIsWindowVisible (HWND Wnd);
BOOL FASTCALL W32kIsChildWindow (HWND Parent, HWND Child); BOOL FASTCALL W32kIsChildWindow (HWND Parent, HWND Child);
HWND FASTCALL W32kGetDesktopWindow (VOID); HWND FASTCALL W32kGetDesktopWindow (VOID);
HWND FASTCALL W32kGetFocusWindow (VOID); HWND FASTCALL W32kGetFocusWindow (VOID);
VOID FASTCALL W32kSetFocusWindow (HWND hWnd); HWND FASTCALL W32kSetFocusWindow (HWND hWnd);
#endif /* __WIN32K_WINDOW_H */ #endif /* __WIN32K_WINDOW_H */
/* EOF */ /* EOF */

View file

@ -5,6 +5,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ex.h> #include <internal/ex.h>
#include <internal/ps.h> #include <internal/ps.h>
#include "msgqueue.h"
#define PROCESS_WINDOW_STATION() \ #define PROCESS_WINDOW_STATION() \
((HWINSTA)(IoGetCurrentProcess()->Win32WindowStation)) ((HWINSTA)(IoGetCurrentProcess()->Win32WindowStation))
@ -34,6 +35,8 @@ LRESULT CALLBACK
W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); W32kDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
PDESKTOP_OBJECT FASTCALL PDESKTOP_OBJECT FASTCALL
W32kGetActiveDesktop(VOID); W32kGetActiveDesktop(VOID);
PUSER_MESSAGE_QUEUE FASTCALL
W32kGetFocusMessageQueue(VOID);
VOID FASTCALL VOID FASTCALL
W32kInitializeDesktopGraphics(VOID); W32kInitializeDesktopGraphics(VOID);
VOID FASTCALL VOID FASTCALL

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: input.c,v 1.7 2003/05/22 00:47:04 gdalsnes Exp $ /* $Id: input.c,v 1.8 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -89,6 +89,7 @@ KeyboardThreadMain(PVOID StartContext)
UserMode, UserMode,
TRUE, TRUE,
NULL); NULL);
/* /*
* Receive and process keyboard input. * Receive and process keyboard input.
*/ */
@ -96,6 +97,7 @@ KeyboardThreadMain(PVOID StartContext)
{ {
KEY_EVENT_RECORD KeyEvent; KEY_EVENT_RECORD KeyEvent;
LPARAM lParam; LPARAM lParam;
BOOLEAN SysKey;
Status = NtReadFile (KeyboardDeviceHandle, Status = NtReadFile (KeyboardDeviceHandle,
NULL, NULL,
@ -116,23 +118,48 @@ KeyboardThreadMain(PVOID StartContext)
return(Status); return(Status);
} }
SysKey = KeyEvent.dwControlKeyState & (LEFT_ALT_PRESSED | RIGHT_ALT_PRESSED);
/* /*
* Post a keyboard message. * Post a keyboard message.
*/ */
if (KeyEvent.bKeyDown) if (KeyEvent.bKeyDown)
{ {
/* FIXME: Bit 24 indicates if this is an extended key. */
lParam = KeyEvent.wRepeatCount | lParam = KeyEvent.wRepeatCount |
((KeyEvent.wVirtualScanCode << 16) & 0x00FF0000) | 0x40000000; ((KeyEvent.wVirtualScanCode << 16) & 0x00FF0000) | 0x40000000;
MsqPostKeyboardMessage(WM_KEYDOWN, KeyEvent.wVirtualKeyCode,
/* Bit 24 indicates if this is an extended key */
if (KeyEvent.dwControlKeyState & ENHANCED_KEY)
{
lParam |= (1 << 24);
}
if (SysKey)
{
lParam |= (1 << 29); /* Context mode. 1 if ALT if pressed while the key is pressed */
}
MsqPostKeyboardMessage(SysKey ? WM_SYSKEYDOWN : WM_KEYDOWN, KeyEvent.wVirtualKeyCode,
lParam); lParam);
} }
else else
{ {
/* FIXME: Bit 24 indicates if this is an extended key. */
lParam = KeyEvent.wRepeatCount | lParam = KeyEvent.wRepeatCount |
((KeyEvent.wVirtualScanCode << 16) & 0x00FF0000) | 0xC0000000; ((KeyEvent.wVirtualScanCode << 16) & 0x00FF0000) | 0xC0000000;
MsqPostKeyboardMessage(WM_KEYUP, KeyEvent.wVirtualKeyCode,
/* Bit 24 indicates if this is an extended key */
if (KeyEvent.dwControlKeyState & ENHANCED_KEY)
{
lParam |= (1 << 24);
}
if (SysKey)
{
lParam |= (1 << 29); /* Context mode. 1 if ALT if pressed while the key is pressed */
}
MsqPostKeyboardMessage(SysKey ? WM_SYSKEYDOWN : WM_KEYDOWN, KeyEvent.wVirtualKeyCode,
lParam); lParam);
} }
} }

View file

@ -16,12 +16,12 @@
* 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: keyboard.c,v 1.3 2003/05/18 17:16:17 ea Exp $ /* $Id: keyboard.c,v 1.4 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* PURPOSE: Messages * PURPOSE: Messages
* FILE: subsys/win32k/ntuser/message.c * FILE: subsys/win32k/ntuser/keyboard.c
* PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * PROGRAMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
* REVISION HISTORY: * REVISION HISTORY:
* 06-06-2001 CSH Created * 06-06-2001 CSH Created
@ -239,4 +239,11 @@ NtUserTranslateMessage(LPMSG lpMsg,
} }
return(FALSE); return(FALSE);
} }
HWND STDCALL
NtUserSetFocus(HWND hWnd)
{
return W32kSetFocusWindow(hWnd);
}
/* EOF */ /* EOF */

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: msgqueue.c,v 1.9 2003/05/21 22:58:42 gvg Exp $ /* $Id: msgqueue.c,v 1.10 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -351,24 +351,35 @@ MsqPeekHardwareMessage(PUSER_MESSAGE_QUEUE MessageQueue, HWND hWnd,
VOID STDCALL VOID STDCALL
MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
#if 0 PUSER_MESSAGE_QUEUE FocusMessageQueue;
MSG Msg;
PUSER_MESSAGE Message; PUSER_MESSAGE Message;
MSG Msg;
if (CurrentFocusMessageQueue == NULL) DPRINT("MsqPostKeyboardMessage(uMsg 0x%x, wParam 0x%x, lParam 0x%x)\n",
uMsg, wParam, lParam);
FocusMessageQueue = W32kGetFocusMessageQueue();
if (FocusMessageQueue == NULL)
{ {
DPRINT("No focus message queue\n");
return; return;
} }
Msg.hwnd = CurrentFocusMessageQueue->FocusWindow; if (FocusMessageQueue->FocusWindow != (HWND)0)
{
Msg.hwnd = FocusMessageQueue->FocusWindow;
Msg.message = uMsg; Msg.message = uMsg;
Msg.wParam = wParam; Msg.wParam = wParam;
Msg.lParam = lParam; Msg.lParam = lParam;
/* FIXME: Initialize time and point. */ /* FIXME: Initialize time and point. */
Message = MsqCreateMessage(&Msg); Message = MsqCreateMessage(&Msg);
MsqPostMessage(CurrentFocusMessageQueue, Message, TRUE); MsqPostMessage(FocusMessageQueue, Message);
#endif }
else
{
DPRINT("Invalid focus window handle\n");
}
} }
VOID FASTCALL VOID FASTCALL

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.12 2003/06/03 22:26:12 ekohl Exp $ /* $Id: stubs.c,v 1.13 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1261,16 +1261,6 @@ NtUserSetDbgTag(
return 0; return 0;
} }
DWORD
STDCALL
NtUserSetFocus(
DWORD Unknown0)
{
UNIMPLEMENTED
return 0;
}
DWORD DWORD
STDCALL STDCALL
NtUserSetImeHotKey( NtUserSetImeHotKey(

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.58 2003/06/25 22:37:07 gvg Exp $ /* $Id: window.c,v 1.59 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -124,9 +124,65 @@ NtUserGetAncestor(HWND hWnd, UINT Flags)
} }
} }
VOID FASTCALL HWND FASTCALL
W32kSetFocusWindow(HWND hWnd) W32kSetFocusWindow(HWND hWnd)
{ {
PUSER_MESSAGE_QUEUE OldMessageQueue;
PDESKTOP_OBJECT DesktopObject;
PWINDOW_OBJECT WindowObject;
HWND hWndOldFocus;
DPRINT("W32kSetFocusWindow(hWnd 0x%x)\n", hWnd);
if (hWnd != (HWND)0)
{
WindowObject = W32kGetWindowObject(hWnd);
if (!WindowObject)
{
DPRINT("Bad window handle 0x%x\n", hWnd);
SetLastWin32Error(ERROR_INVALID_HANDLE);
return (HWND)0;
}
}
else
{
WindowObject = NULL;
}
DesktopObject = W32kGetActiveDesktop();
if (!DesktopObject)
{
DPRINT("No active desktop\n");
if (WindowObject != NULL)
{
W32kReleaseWindowObject(WindowObject);
}
SetLastWin32Error(ERROR_INVALID_HANDLE);
return (HWND)0;
}
hWndOldFocus = (HWND)0;
OldMessageQueue = (PUSER_MESSAGE_QUEUE)DesktopObject->ActiveMessageQueue;
if (OldMessageQueue != NULL)
{
hWndOldFocus = OldMessageQueue->FocusWindow;
}
if (WindowObject != NULL)
{
WindowObject->MessageQueue->FocusWindow = hWnd;
(PUSER_MESSAGE_QUEUE)DesktopObject->ActiveMessageQueue =
WindowObject->MessageQueue;
W32kReleaseWindowObject(WindowObject);
}
else
{
(PUSER_MESSAGE_QUEUE)DesktopObject->ActiveMessageQueue = NULL;
}
DPRINT("hWndOldFocus = 0x%x\n", hWndOldFocus);
return hWndOldFocus;
} }
BOOL FASTCALL BOOL FASTCALL
@ -297,6 +353,7 @@ NtUserGetClientRect(HWND hWnd, LPRECT Rect)
W32kGetClientRect(WindowObject, &SafeRect); W32kGetClientRect(WindowObject, &SafeRect);
if (! NT_SUCCESS(MmCopyToCaller(Rect, &SafeRect, sizeof(RECT)))) if (! NT_SUCCESS(MmCopyToCaller(Rect, &SafeRect, sizeof(RECT))))
{ {
W32kReleaseWindowObject(WindowObject);
return(FALSE); return(FALSE);
} }
@ -348,7 +405,7 @@ W32kGetWindowProc(HWND Wnd)
return NULL; return NULL;
WndProc = WindowObject->WndProc; WndProc = WindowObject->WndProc;
W32kReleaseWindowObject(Wnd); W32kReleaseWindowObject(WindowObject);
return(WndProc); return(WndProc);
} }
@ -495,6 +552,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
RtlFreeUnicodeString(&WindowName); RtlFreeUnicodeString(&WindowName);
W32kReleaseWindowObject(ParentWindow);
return((HWND)0); return((HWND)0);
} }
@ -509,6 +567,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
{ {
RtlFreeUnicodeString(&WindowName); RtlFreeUnicodeString(&WindowName);
ObmDereferenceObject(ClassObject); ObmDereferenceObject(ClassObject);
W32kReleaseWindowObject(ParentWindow);
DPRINT("Validation of window station handle (0x%X) failed\n", DPRINT("Validation of window station handle (0x%X) failed\n",
PROCESS_WINDOW_STATION()); PROCESS_WINDOW_STATION());
return (HWND)0; return (HWND)0;
@ -524,6 +583,7 @@ NtUserCreateWindowEx(DWORD dwExStyle,
ObDereferenceObject(WinStaObject); ObDereferenceObject(WinStaObject);
ObmDereferenceObject(ClassObject); ObmDereferenceObject(ClassObject);
RtlFreeUnicodeString(&WindowName); RtlFreeUnicodeString(&WindowName);
W32kReleaseWindowObject(ParentWindow);
SetLastNtError(STATUS_INSUFFICIENT_RESOURCES); SetLastNtError(STATUS_INSUFFICIENT_RESOURCES);
return (HWND)0; return (HWND)0;
} }
@ -649,8 +709,9 @@ NtUserCreateWindowEx(DWORD dwExStyle,
if (!Result) if (!Result)
{ {
/* FIXME: Cleanup. */ /* FIXME: Cleanup. */
W32kReleaseWindowObject(ParentWindow);
DPRINT("NtUserCreateWindowEx(): NCCREATE message failed.\n"); DPRINT("NtUserCreateWindowEx(): NCCREATE message failed.\n");
return(NULL); return((HWND)0);
} }
/* Calculate the non-client size. */ /* Calculate the non-client size. */
@ -670,8 +731,9 @@ NtUserCreateWindowEx(DWORD dwExStyle,
if (Result == (LRESULT)-1) if (Result == (LRESULT)-1)
{ {
/* FIXME: Cleanup. */ /* FIXME: Cleanup. */
W32kReleaseWindowObject(ParentWindow);
DPRINT("NtUserCreateWindowEx(): send CREATE message failed.\n"); DPRINT("NtUserCreateWindowEx(): send CREATE message failed.\n");
return(NULL); return((HWND)0);
} }
/* Send move and size messages. */ /* Send move and size messages. */
@ -984,8 +1046,9 @@ static LRESULT W32kDestroyWindow(PWINDOW_OBJECT Window,
BOOLEAN STDCALL BOOLEAN STDCALL
NtUserDestroyWindow(HWND Wnd) NtUserDestroyWindow(HWND Wnd)
{ {
BOOL isChild;
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
BOOLEAN isChild;
HWND hWndFocus;
Window = W32kGetWindowObject(Wnd); Window = W32kGetWindowObject(Wnd);
if (Window == NULL) if (Window == NULL)
@ -996,6 +1059,7 @@ NtUserDestroyWindow(HWND Wnd)
/* Check for desktop window (has NULL parent) */ /* Check for desktop window (has NULL parent) */
if (NULL == Window->Parent) if (NULL == Window->Parent)
{ {
W32kReleaseWindowObject(Window);
SetLastWin32Error(ERROR_ACCESS_DENIED); SetLastWin32Error(ERROR_ACCESS_DENIED);
return FALSE; return FALSE;
} }
@ -1003,18 +1067,16 @@ NtUserDestroyWindow(HWND Wnd)
/* Look whether the focus is within the tree of windows we will /* Look whether the focus is within the tree of windows we will
* be destroying. * be destroying.
*/ */
#if 0 /* FIXME */ hWndFocus = W32kGetFocusWindow();
h = GetFocus(); if (hWndFocus == Wnd || W32kIsChildWindow(Wnd, hWndFocus))
if (h == Wnd || IsChild(Wnd, h))
{ {
HWND Parent = GetAncestor(Wnd, GA_PARENT); HWND Parent = NtUserGetAncestor(Wnd, GA_PARENT);
if (Parent == GetDesktopWindow()) if (Parent == W32kGetDesktopWindow())
{ {
Parent = NULL; Parent = NULL;
} }
SetFocus(Parent); W32kSetFocusWindow(Parent);
} }
#endif
/* 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.11 2003/05/18 22:09:08 gvg Exp $ /* $Id: winpos.c,v 1.12 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -346,9 +346,25 @@ WinPosGetMinMaxInfo(PWINDOW_OBJECT Window, POINT* MaxSize, POINT* MaxPos,
} }
BOOL STATIC FASTCALL BOOL STATIC FASTCALL
WinPosChangeActiveWindow(HWND Wnd, BOOL MouseMsg) WinPosChangeActiveWindow(HWND hWnd, BOOL MouseMsg)
{ {
PWINDOW_OBJECT WindowObject;
WindowObject = W32kGetWindowObject(hWnd);
if (WindowObject == NULL)
{
return FALSE; return FALSE;
}
NtUserSendMessage(hWnd,
WM_ACTIVATE,
MAKELONG(MouseMsg ? WA_CLICKACTIVE : WA_CLICKACTIVE,
(WindowObject->Style & WS_MINIMIZE) ? 1 : 0),
W32kGetDesktopWindow()); /* FIXME: Previous active window */
W32kReleaseWindowObject(WindowObject);
return TRUE;
} }
LONG STATIC STDCALL LONG STATIC STDCALL
@ -759,6 +775,13 @@ WinPosShowWindow(HWND Wnd, INT Cmd)
MAKELONG(Window->ClientRect.left, MAKELONG(Window->ClientRect.left,
Window->ClientRect.top)); Window->ClientRect.top));
} }
/* 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); ObmDereferenceObject(Window);
return(WasVisible); return(WasVisible);
} }

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: winsta.c,v 1.16 2003/06/20 16:26:14 ekohl Exp $ /* $Id: winsta.c,v 1.17 2003/07/05 16:04:01 chorns Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -74,6 +74,21 @@ W32kGetActiveDesktop(VOID)
return(InputDesktop); return(InputDesktop);
} }
PUSER_MESSAGE_QUEUE FASTCALL
W32kGetFocusMessageQueue(VOID)
{
PDESKTOP_OBJECT pdo = W32kGetActiveDesktop();
if (!pdo)
{
DPRINT("No active desktop\n");
return(NULL);
}
return (PUSER_MESSAGE_QUEUE)pdo->ActiveMessageQueue;
}
NTSTATUS FASTCALL NTSTATUS FASTCALL
InitWindowStationImpl(VOID) InitWindowStationImpl(VOID)
{ {