7 modified files
reactos/lib/user32/windows
diff -u -r1.115 -r1.116
--- window.c 2 May 2004 17:25:21 -0000 1.115
+++ window.c 8 May 2004 12:42:45 -0000 1.116
@@ -1,4 +1,4 @@
-/* $Id: window.c,v 1.115 2004/05/02 17:25:21 weiden Exp $
+/* $Id: window.c,v 1.116 2004/05/08 12:42:45 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll
@@ -168,7 +168,6 @@
UNICODE_STRING ClassName;
WNDCLASSEXA wce;
HWND Handle;
- INT sw;
#if 0
DbgPrint("[window] CreateWindowExA style %d, exstyle %d, parent %d\n", dwStyle, dwExStyle, hWndParent);
@@ -211,56 +210,6 @@
SetLastError(ERROR_OUTOFMEMORY);
return (HWND)0;
}
-
- /* Fixup default coordinates. */
- sw = SW_SHOW;
- if (x == (LONG) CW_USEDEFAULT || nWidth == (LONG) CW_USEDEFAULT)
- {
- if (dwStyle & (WS_CHILD | WS_POPUP))
- {
- if (x == (LONG) CW_USEDEFAULT)
- {
- x = y = 0;
- }
- if (nWidth == (LONG) CW_USEDEFAULT)
- {
- nWidth = nHeight = 0;
- }
- }
- else
- {
- STARTUPINFOA info;
-
- GetStartupInfoA(&info);
-
- if (x == (LONG) CW_USEDEFAULT)
- {
- if (y != (LONG) CW_USEDEFAULT)
- {
- sw = y;
- }
- x = (info.dwFlags & STARTF_USEPOSITION) ? info.dwX : 0;
- y = (info.dwFlags & STARTF_USEPOSITION) ? info.dwY : 0;
- }
-
- if (nWidth == (LONG) CW_USEDEFAULT)
- {
- if (info.dwFlags & STARTF_USESIZE)
- {
- nWidth = info.dwXSize;
- nHeight = info.dwYSize;
- }
- else
- {
- RECT r;
-
- SystemParametersInfoA(SPI_GETWORKAREA, 0, &r, 0);
- nWidth = (((r.right - r.left) * 3) / 4) - x;
- nHeight = (((r.bottom - r.top) * 3) / 4) - y;
- }
- }
- }
- }
if(!hMenu && (dwStyle & (WS_OVERLAPPEDWINDOW | WS_POPUP)))
{
@@ -283,7 +232,7 @@
hMenu,
hInstance,
lpParam,
- sw,
+ SW_SHOW,
FALSE);
#if 0
@@ -322,7 +271,6 @@
UNICODE_STRING ClassName;
WNDCLASSEXW wce;
HANDLE Handle;
- UINT sw;
/* Register built-in controls if not already done */
if (! ControlsInitialized)
@@ -346,56 +294,6 @@
RtlInitUnicodeString(&WindowName, lpWindowName);
- /* Fixup default coordinates. */
- sw = SW_SHOW;
- if (x == (LONG) CW_USEDEFAULT || nWidth == (LONG) CW_USEDEFAULT)
- {
- if (dwStyle & (WS_CHILD | WS_POPUP))
- {
- if (x == (LONG) CW_USEDEFAULT)
- {
- x = y = 0;
- }
- if (nWidth == (LONG) CW_USEDEFAULT)
- {
- nWidth = nHeight = 0;
- }
- }
- else
- {
- STARTUPINFOW info;
-
- GetStartupInfoW(&info);
-
- if (x == (LONG) CW_USEDEFAULT)
- {
- if (y != (LONG) CW_USEDEFAULT)
- {
- sw = y;
- }
- x = (info.dwFlags & STARTF_USEPOSITION) ? info.dwX : 0;
- y = (info.dwFlags & STARTF_USEPOSITION) ? info.dwY : 0;
- }
-
- if (nWidth == (LONG) CW_USEDEFAULT)
- {
- if (info.dwFlags & STARTF_USESIZE)
- {
- nWidth = info.dwXSize;
- nHeight = info.dwYSize;
- }
- else
- {
- RECT r;
-
- SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0);
- nWidth = (((r.right - r.left) * 3) / 4) - x;
- nHeight = (((r.bottom - r.top) * 3) / 4) - y;
- }
- }
- }
- }
-
if(!hMenu && (dwStyle & (WS_OVERLAPPEDWINDOW | WS_POPUP)))
{
wce.cbSize = sizeof(WNDCLASSEXW);
@@ -417,7 +315,7 @@
hMenu,
hInstance,
lpParam,
- sw,
+ SW_SHOW,
TRUE);
return (HWND)Handle;
reactos/subsys/win32k/include
diff -u -r1.6 -r1.7
--- desktop.h 5 May 2004 22:47:06 -0000 1.6
+++ desktop.h 8 May 2004 12:42:46 -0000 1.7
@@ -19,8 +19,8 @@
NTSTATUS FASTCALL
CleanupDesktopImpl(VOID);
-PRECT FASTCALL
-IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop);
+VOID FASTCALL
+IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop, PRECT Rect);
LRESULT CALLBACK
IntDesktopWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
reactos/subsys/win32k/include
diff -u -r1.57 -r1.58
--- window.h 2 May 2004 17:25:21 -0000 1.57
+++ window.h 8 May 2004 12:42:46 -0000 1.58
@@ -95,6 +95,8 @@
HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
PINTERNALPOS InternalPos;
ULONG Status;
+ /* counter for tiled child windows */
+ ULONG TiledCounter;
} WINDOW_OBJECT; /* PWINDOW_OBJECT already declared at top of file */
/* Window flags. */
reactos/subsys/win32k/ntuser
diff -u -r1.12 -r1.13
--- desktop.c 5 May 2004 22:47:06 -0000 1.12
+++ desktop.c 8 May 2004 12:42:46 -0000 1.13
@@ -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: desktop.c,v 1.12 2004/05/05 22:47:06 weiden Exp $
+ * $Id: desktop.c,v 1.13 2004/05/08 12:42:46 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -118,11 +118,13 @@
return Status;
}
-PRECT FASTCALL
-IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop)
+VOID FASTCALL
+IntGetDesktopWorkArea(PDESKTOP_OBJECT Desktop, PRECT Rect)
{
PRECT Ret;
+ ASSERT(Desktop);
+
Ret = &Desktop->WorkArea;
if((Ret->right == -1) && ScreenDeviceContext)
{
@@ -138,7 +140,10 @@
DC_UnlockDc(ScreenDeviceContext);
}
- return Ret;
+ if(Rect)
+ {
+ *Rect = *Ret;
+ }
}
PDESKTOP_OBJECT FASTCALL
@@ -432,7 +437,7 @@
DesktopObject->WorkArea.top = 0;
DesktopObject->WorkArea.right = -1;
DesktopObject->WorkArea.bottom = -1;
- IntGetDesktopWorkArea(DesktopObject);
+ IntGetDesktopWorkArea(DesktopObject, NULL);
/* Initialize some local (to win32k) desktop state. */
DesktopObject->ActiveMessageQueue = NULL;
reactos/subsys/win32k/ntuser
diff -u -r1.69 -r1.70
--- misc.c 2 May 2004 17:25:21 -0000 1.69
+++ misc.c 8 May 2004 12:42:46 -0000 1.70
@@ -1,4 +1,4 @@
-/* $Id: misc.c,v 1.69 2004/05/02 17:25:21 weiden Exp $
+/* $Id: misc.c,v 1.70 2004/05/08 12:42:46 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -711,7 +711,7 @@
}
ASSERT(pvParam);
- *((PRECT)pvParam) = *(IntGetDesktopWorkArea(Desktop));
+ IntGetDesktopWorkArea(Desktop, (PRECT)pvParam);
return TRUE;
}
reactos/subsys/win32k/ntuser
diff -u -r1.224 -r1.225
--- window.c 5 May 2004 22:26:04 -0000 1.224
+++ window.c 8 May 2004 12:42:46 -0000 1.225
@@ -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.224 2004/05/05 22:26:04 weiden Exp $
+/* $Id: window.c,v 1.225 2004/05/08 12:42:46 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -64,6 +64,9 @@
static WORD WndProcHandlesArraySize = 0;
#define WPH_SIZE 0x40 /* the size to add to the WndProcHandle array each time */
+/* dialog resources appear to pass this in 16 bits, handle them properly */
+#define CW_USEDEFAULT16 (0x8000)
+
#define POINT_IN_RECT(p, r) (((r.bottom >= p.y) && (r.top <= p.y))&&((r.left <= p.x )&&( r.right >= p.x )))
/* PRIVATE FUNCTIONS **********************************************************/
@@ -1355,6 +1358,57 @@
/*
+ * calculates the default position of a window
+ */
+BOOL FASTCALL
+IntCalcDefPosSize(PWINDOW_OBJECT Parent, PWINDOW_OBJECT WindowObject, RECT *rc, BOOL IncPos)
+{
+ PDESKTOP_OBJECT Desktop;
+ SIZE Sz;
+ POINT Pos;
+ DbgPrint("IntCalcDefPosSize: Parent: 0x%x, Window: 0x%x, IncPos: 0x%x\n", Parent, WindowObject, IncPos);
+ Desktop = WindowObject->OwnerThread->Win32Thread->Desktop;
+ IntGetDesktopWorkArea(Desktop, rc);
+
+ if(Parent != NULL)
+ {
+ NtGdiIntersectRect(rc, rc, &Parent->ClientRect);
+
+ if(IncPos)
+ {
+ Pos.x = Parent->TiledCounter * (NtUserGetSystemMetrics(SM_CXSIZE) + NtUserGetSystemMetrics(SM_CXFRAME));
+ Pos.y = Parent->TiledCounter * (NtUserGetSystemMetrics(SM_CYSIZE) + NtUserGetSystemMetrics(SM_CYFRAME));
+ if(Pos.x > ((rc->right - rc->left) / 4) ||
+ Pos.y > ((rc->bottom - rc->top) / 4))
+ {
+ /* reset counter and position */
+ Pos.x = 0;
+ Pos.y = 0;
+ Parent->TiledCounter = 0;
+ }
+ Parent->TiledCounter++;
+ }
+ Pos.x += rc->left;
+ Pos.y += rc->top;
+ }
+ else
+ {
+ Pos.x = rc->left;
+ Pos.y = rc->top;
+ }
+
+ Sz.cx = EngMulDiv(rc->right - rc->left, 3, 4);
+ Sz.cy = EngMulDiv(rc->bottom - rc->top, 3, 4);
+
+ rc->left = Pos.x;
+ rc->top = Pos.y;
+ rc->right = rc->left + Sz.cx;
+ rc->bottom = rc->top + Sz.cy;
+ return TRUE;
+}
+
+
+/*
* @implemented
*/
HWND STDCALL
@@ -1383,6 +1437,8 @@
UNICODE_STRING WindowName;
NTSTATUS Status;
HANDLE Handle;
+ POINT Pos;
+ SIZE Size;
#if 0
POINT MaxSize, MaxPos, MinTrack, MaxTrack;
#else
@@ -1607,6 +1663,13 @@
}
}
+ if(!(WindowObject->Style & (WS_POPUP | WS_CHILD)))
+ {
+ /* Automatically assign the caption and border style. Also always
+ clip siblings for overlapped windows. */
+ WindowObject->Style |= (WS_CAPTION | WS_BORDER | WS_CLIPSIBLINGS);
+ }
+
/* create system menu */
if((WindowObject->Style & WS_SYSMENU) && (WindowObject->Style & WS_CAPTION))
{
@@ -1631,26 +1694,20 @@
}
/* FIXME: Handle "CS_CLASSDC" */
- /* Initialize the window dimensions. */
- WindowObject->WindowRect.left = x;
- WindowObject->WindowRect.top = y;
- WindowObject->WindowRect.right = x + nWidth;
- WindowObject->WindowRect.bottom = y + nHeight;
- if (0 != (WindowObject->Style & WS_CHILD) && ParentWindow)
- {
- NtGdiOffsetRect(&(WindowObject->WindowRect), ParentWindow->ClientRect.left,
- ParentWindow->ClientRect.top);
- }
- WindowObject->ClientRect = WindowObject->WindowRect;
+ Pos.x = x;
+ Pos.y = y;
+ Size.cx = nWidth;
+ Size.cy = nHeight;
+ /* call hook */
Cs.lpCreateParams = lpParam;
Cs.hInstance = hInstance;
Cs.hMenu = hMenu;
Cs.hwndParent = ParentWindowHandle;
- Cs.cx = nWidth;
- Cs.cy = nHeight;
- Cs.x = x;
- Cs.y = y;
+ Cs.cx = Size.cx;
+ Cs.cy = Size.cy;
+ Cs.x = Pos.x;
+ Cs.y = Pos.y;
Cs.style = dwStyle;
Cs.lpszName = OrigWindowName; /* pass the original pointer to usermode! */
Cs.lpszClass = lpClassName->Buffer;
@@ -1667,6 +1724,96 @@
return (HWND) NULL;
}
+ x = Cs.x;
+ y = Cs.y;
+ nWidth = Cs.cx;
+ nHeight = Cs.cy;
+
+ /* default positioning for overlapped windows */
+ if(!(WindowObject->Style & (WS_POPUP | WS_CHILD)))
+ {
+ RECT rc;
+ PRTL_USER_PROCESS_PARAMETERS ProcessParams;
+ BOOL CalculatedDefPosSize = FALSE;
+
+ ProcessParams = PsGetCurrentProcess()->Peb->ProcessParameters;
+
+ DbgPrint("Creating WS_OVERLAPPED window (0x%x, 0x%x, 0x%x, 0x%x)\n", x, y, nWidth, nHeight);
+ if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
+ {
+ CalculatedDefPosSize = IntCalcDefPosSize(ParentWindow, WindowObject, &rc, TRUE);
+
+ if(ProcessParams->dwFlags & STARTF_USEPOSITION)
+ {
+ ProcessParams->dwFlags &= ~STARTF_USEPOSITION;
+ Pos.x = ProcessParams->dwX;
+ Pos.y = ProcessParams->dwY;
+ }
+ else
+ {
+ Pos.x = rc.left;
+ Pos.y = rc.top;
+ }
+
+ /* According to wine, the ShowMode is set to y if x == CW_USEDEFAULT(16) and
+ y is something else */
+ if(y != CW_USEDEFAULT && y != CW_USEDEFAULT16)
+ {
+ dwShowMode = y;
+ }
+ }
+ if(nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16)
+ {
+ if(!CalculatedDefPosSize)
+ {
+ IntCalcDefPosSize(ParentWindow, WindowObject, &rc, FALSE);
+ }
+ if(ProcessParams->dwFlags & STARTF_USESIZE)
+ {
+ ProcessParams->dwFlags &= ~STARTF_USESIZE;
+ Size.cx = ProcessParams->dwXSize;
+ Size.cy = ProcessParams->dwYSize;
+ }
+ else
+ {
+ Size.cx = rc.right - rc.left;
+ Size.cy = rc.bottom - rc.top;
+ }
+
+ /* move the window if necessary */
+ if(Pos.x > rc.left)
+ Pos.x = max(rc.left, 0);
+ if(Pos.y > rc.top)
+ Pos.y = max(rc.top, 0);
+ }
+ }
+ else
+ {
+ /* if CW_USEDEFAULT(16) is set for non-overlapped windows, both values are set to zero) */
+ if(x == CW_USEDEFAULT || x == CW_USEDEFAULT16)
+ {
+ Pos.x = 0;
+ Pos.y = 0;
+ }
+ if(nWidth == CW_USEDEFAULT || nWidth == CW_USEDEFAULT16)
+ {
+ Size.cx = 0;
+ Size.cy = 0;
+ }
+ }
+
+ /* Initialize the window dimensions. */
+ WindowObject->WindowRect.left = Pos.x;
+ WindowObject->WindowRect.top = Pos.y;
+ WindowObject->WindowRect.right = Pos.x + Size.cx;
+ WindowObject->WindowRect.bottom = Pos.y + Size.cy;
+ if (0 != (WindowObject->Style & WS_CHILD) && ParentWindow)
+ {
+ NtGdiOffsetRect(&(WindowObject->WindowRect), ParentWindow->ClientRect.left,
+ ParentWindow->ClientRect.top);
+ }
+ WindowObject->ClientRect = WindowObject->WindowRect;
+
/*
* Get the size and position of the window.
*/
@@ -1685,10 +1832,10 @@
if (nHeight < 0) nHeight = 0;
}
- WindowObject->WindowRect.left = x;
- WindowObject->WindowRect.top = y;
- WindowObject->WindowRect.right = x + nWidth;
- WindowObject->WindowRect.bottom = y + nHeight;
+ WindowObject->WindowRect.left = Pos.x;
+ WindowObject->WindowRect.top = Pos.y;
+ WindowObject->WindowRect.right = Pos.x + Size.cx;
+ WindowObject->WindowRect.bottom = Pos.y + Size.cy;
if (0 != (WindowObject->Style & WS_CHILD) && ParentWindow)
{
NtGdiOffsetRect(&(WindowObject->WindowRect), ParentWindow->ClientRect.left,
@@ -1699,10 +1846,10 @@
/* FIXME: Initialize the window menu. */
/* Send a NCCREATE message. */
- Cs.cx = nWidth;
- Cs.cy = nHeight;
- Cs.x = x;
- Cs.y = y;
+ Cs.cx = Size.cx;
+ Cs.cy = Size.cy;
+ Cs.x = Pos.x;
+ Cs.y = Pos.y;
DPRINT("[win32k.window] NtUserCreateWindowEx style %d, exstyle %d, parent %d\n", Cs.style, Cs.dwExStyle, Cs.hwndParent);
DPRINT("NtUserCreateWindowEx(): (%d,%d-%d,%d)\n", x, y, nWidth, nHeight);
reactos/subsys/win32k/ntuser
diff -u -r1.112 -r1.113
--- winpos.c 24 Apr 2004 14:21:36 -0000 1.112
+++ winpos.c 8 May 2004 12:42:46 -0000 1.113
@@ -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.112 2004/04/24 14:21:36 weiden Exp $
+/* $Id: winpos.c,v 1.113 2004/05/08 12:42:46 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@@ -198,13 +198,13 @@
if(Parent)
{
if(IntIsDesktopWindow(Parent))
- WorkArea = *IntGetDesktopWorkArea(Desktop);
+ IntGetDesktopWorkArea(Desktop, &WorkArea);
else
WorkArea = Parent->ClientRect;
IntReleaseWindowObject(Parent);
}
else
- WorkArea = *IntGetDesktopWorkArea(Desktop);
+ IntGetDesktopWorkArea(Desktop, &WorkArea);
WindowObject->InternalPos = ExAllocatePoolWithTag(NonPagedPool, sizeof(INTERNALPOS), TAG_WININTLIST);
if(!WindowObject->InternalPos)
@@ -347,7 +347,7 @@
RECT WorkArea;
PDESKTOP_OBJECT Desktop = PsGetWin32Thread()->Desktop; /* Or rather get it from the window? */
- WorkArea = *IntGetDesktopWorkArea(Desktop);
+ IntGetDesktopWorkArea(Desktop, &WorkArea);
/* Get default values. */
Info->ptMaxSize.x = WorkArea.right - WorkArea.left;
CVSspam 0.2.8