From cb0b5d3b3a673429b584a41fe9466a6c4342eb92 Mon Sep 17 00:00:00 2001 From: James Tabor Date: Fri, 31 Dec 2010 04:43:35 +0000 Subject: [PATCH] [Win32k|User32] - Add hack to mark desktop window as a desktop window and notes for creating a desktop with tips in win32k. Move user position code from window to winpos. svn path=/trunk/; revision=50229 --- reactos/dll/win32/user32/windows/window.c | 87 ------------------ reactos/dll/win32/user32/windows/winpos.c | 90 ++++++++++++++++++- .../win32/csrss/win32csr/desktopbg.c | 1 + .../subsystems/win32/win32k/ntuser/desktop.c | 42 ++++++++- .../subsystems/win32/win32k/ntuser/window.c | 7 +- 5 files changed, 132 insertions(+), 95 deletions(-) diff --git a/reactos/dll/win32/user32/windows/window.c b/reactos/dll/win32/user32/windows/window.c index 2538acf82cf..be687a64b6f 100644 --- a/reactos/dll/win32/user32/windows/window.c +++ b/reactos/dll/win32/user32/windows/window.c @@ -1831,92 +1831,6 @@ UpdateLayeredWindowIndirect(HWND hwnd, return FALSE; } - -/* - * @implemented - */ -HWND WINAPI -WindowFromPoint(POINT Point) -{ - //TODO: Determine what the actual parameters to - // NtUserWindowFromPoint are. - return NtUserWindowFromPoint(Point.x, Point.y); -} - - -/* - * @implemented - */ -int WINAPI -MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) -{ - PWND FromWnd, ToWnd; - POINT Delta; - UINT i; - - FromWnd = ValidateHwndOrDesk(hWndFrom); - if (!FromWnd) - return 0; - - ToWnd = ValidateHwndOrDesk(hWndTo); - if (!ToWnd) - return 0; - - Delta.x = FromWnd->rcClient.left - ToWnd->rcClient.left; - Delta.y = FromWnd->rcClient.top - ToWnd->rcClient.top; - - for (i = 0; i != cPoints; i++) - { - lpPoints[i].x += Delta.x; - lpPoints[i].y += Delta.y; - } - - return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y)); -} - - -/* - * @implemented - */ -BOOL WINAPI -ScreenToClient(HWND hWnd, LPPOINT lpPoint) -{ - PWND Wnd, DesktopWnd; - - Wnd = ValidateHwnd(hWnd); - if (!Wnd) - return FALSE; - - DesktopWnd = GetThreadDesktopWnd(); - - lpPoint->x += DesktopWnd->rcClient.left - Wnd->rcClient.left; - lpPoint->y += DesktopWnd->rcClient.top - Wnd->rcClient.top; - - return TRUE; -} - - -/* - * @implemented - */ -BOOL WINAPI -ClientToScreen(HWND hWnd, LPPOINT lpPoint) -{ - PWND Wnd, DesktopWnd; - - Wnd = ValidateHwnd(hWnd); - if (!Wnd) - return FALSE; - - DesktopWnd = GetThreadDesktopWnd(); - - lpPoint->x += Wnd->rcClient.left - DesktopWnd->rcClient.left; - lpPoint->y += Wnd->rcClient.top - DesktopWnd->rcClient.top; - - return TRUE; -} - - /* * @implemented */ @@ -1927,7 +1841,6 @@ SetWindowContextHelpId(HWND hwnd, return NtUserSetWindowContextHelpId(hwnd, dwContextHelpId); } - /* * @implemented */ diff --git a/reactos/dll/win32/user32/windows/winpos.c b/reactos/dll/win32/user32/windows/winpos.c index 9503b96be34..44a3371ff66 100644 --- a/reactos/dll/win32/user32/windows/winpos.c +++ b/reactos/dll/win32/user32/windows/winpos.c @@ -1,8 +1,7 @@ -/* $Id$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll - * FILE: lib/user32/windows/window.c + * FILE: dll/win32/user32/windows/winpos.c * PURPOSE: Window management * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) * UPDATE HISTORY: @@ -111,3 +110,88 @@ ArrangeIconicWindows(HWND hWnd) { return NtUserCallHwndLock( hWnd, HWNDLOCK_ROUTINE_ARRANGEICONICWINDOWS); } + +/* + * @implemented + */ +HWND WINAPI +WindowFromPoint(POINT Point) +{ + //TODO: Determine what the actual parameters to + // NtUserWindowFromPoint are. + return NtUserWindowFromPoint(Point.x, Point.y); +} + + +/* + * @implemented + */ +int WINAPI +MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints) +{ + PWND FromWnd, ToWnd; + POINT Delta; + UINT i; + + FromWnd = ValidateHwndOrDesk(hWndFrom); + if (!FromWnd) + return 0; + + ToWnd = ValidateHwndOrDesk(hWndTo); + if (!ToWnd) + return 0; + + Delta.x = FromWnd->rcClient.left - ToWnd->rcClient.left; + Delta.y = FromWnd->rcClient.top - ToWnd->rcClient.top; + + for (i = 0; i != cPoints; i++) + { + lpPoints[i].x += Delta.x; + lpPoints[i].y += Delta.y; + } + + return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y)); +} + + +/* + * @implemented + */ +BOOL WINAPI +ScreenToClient(HWND hWnd, LPPOINT lpPoint) +{ + PWND Wnd, DesktopWnd; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return FALSE; + + DesktopWnd = GetThreadDesktopWnd(); + + lpPoint->x += DesktopWnd->rcClient.left - Wnd->rcClient.left; + lpPoint->y += DesktopWnd->rcClient.top - Wnd->rcClient.top; + + return TRUE; +} + + +/* + * @implemented + */ +BOOL WINAPI +ClientToScreen(HWND hWnd, LPPOINT lpPoint) +{ + PWND Wnd, DesktopWnd; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return FALSE; + + DesktopWnd = GetThreadDesktopWnd(); + + lpPoint->x += Wnd->rcClient.left - DesktopWnd->rcClient.left; + lpPoint->y += Wnd->rcClient.top - DesktopWnd->rcClient.top; + + return TRUE; +} + diff --git a/reactos/subsystems/win32/csrss/win32csr/desktopbg.c b/reactos/subsystems/win32/csrss/win32csr/desktopbg.c index 14a6155fb00..2c158c57e58 100644 --- a/reactos/subsystems/win32/csrss/win32csr/desktopbg.c +++ b/reactos/subsystems/win32/csrss/win32csr/desktopbg.c @@ -65,6 +65,7 @@ DtbgWindowProc(HWND Wnd, return (LRESULT)TRUE; case WM_CREATE: + NtUserSetWindowFNID(Wnd, FNID_DESKTOP); // Anti-ReactOS hack! case WM_CLOSE: return 0; diff --git a/reactos/subsystems/win32/win32k/ntuser/desktop.c b/reactos/subsystems/win32/win32k/ntuser/desktop.c index 95c07af381e..74da248d3e7 100644 --- a/reactos/subsystems/win32/win32k/ntuser/desktop.c +++ b/reactos/subsystems/win32/win32k/ntuser/desktop.c @@ -1036,12 +1036,16 @@ NtUserCreateDesktop( } ExFreePoolWithTag(DesktopName.Buffer, TAG_STRING); +//// why is this here? +#if 0 if (! NT_SUCCESS(Status)) { DPRINT1("Failed to create desktop handle\n"); SetLastNtError(Status); RETURN( NULL); } +#endif +//// /* * Create a handle for CSRSS and notify CSRSS for Creating Desktop Window. @@ -1072,7 +1076,35 @@ NtUserCreateDesktop( SetLastNtError(Status); RETURN( NULL); } +#if 0 // Turn on when server side proc is ready. + // + // Create desktop window. + // + ClassName.Buffer = ((PWSTR)((ULONG_PTR)(WORD)(gpsi->atomSysClass[ICLS_DESKTOP]))); + ClassName.Length = 0; + RtlZeroMemory(&MenuName, sizeof(MenuName)); + RtlZeroMemory(&WindowName, sizeof(WindowName)); + RtlZeroMemory(&Cs, sizeof(Cs)); + Cs.x = UserGetSystemMetrics(SM_XVIRTUALSCREEN); + Cs.y = UserGetSystemMetrics(SM_YVIRTUALSCREEN); + Cs.cx = UserGetSystemMetrics(SM_CXVIRTUALSCREEN); + Cs.cy = UserGetSystemMetrics(SM_CYVIRTUALSCREEN); + Cs.style = WS_POPUP|WS_CLIPCHILDREN; + Cs.hInstance = hModClient; // Experimental mode... Move csr stuff to User32. hModuleWin; // Server side winproc! + Cs.lpszName = (LPCWSTR) &WindowName; + Cs.lpszClass = (LPCWSTR) &ClassName; + + pWndDesktop = co_UserCreateWindowEx(&Cs, &ClassName, &WindowName); + if (!pWnd) + { + DPRINT1("Failed to create Desktop window handle\n"); + } + else + { + DesktopObject->pDeskInfo->spwnd = pWndDesktop; + } +#endif W32Thread = PsGetCurrentThreadWin32Thread(); if (!W32Thread->rpdesk) IntSetThreadDesktop(DesktopObject,FALSE); @@ -1089,7 +1121,7 @@ NtUserCreateDesktop( RtlZeroMemory(&Cs, sizeof(Cs)); Cs.cx = Cs.cy = 100; Cs.style = WS_POPUP|WS_CLIPCHILDREN; - Cs.hInstance = hModClient; + Cs.hInstance = hModClient; // hModuleWin; // Server side winproc! Leave it to Timo to not pass on notes! Cs.lpszName = (LPCWSTR) &WindowName; Cs.lpszClass = (LPCWSTR) &ClassName; @@ -1103,6 +1135,14 @@ NtUserCreateDesktop( DesktopObject->spwndMessage = pWnd; } + /* Now,,, + if !(WinStaObject->Flags & WSF_NOIO) is (not set) for desktop input output mode (see wiki) + Create Tooltip. Saved in DesktopObject->spwndTooltip. + Tooltip dwExStyle: WS_EX_TOOLWINDOW|WS_EX_TOPMOST + hWndParent are spwndMessage. Use hModuleWin for server side winproc! + The rest is same as message window. + http://msdn.microsoft.com/en-us/library/bb760250(VS.85).aspx + */ RETURN( Desktop); CLEANUP: diff --git a/reactos/subsystems/win32/win32k/ntuser/window.c b/reactos/subsystems/win32/win32k/ntuser/window.c index 4d978038e3f..a231bdb7e17 100644 --- a/reactos/subsystems/win32/win32k/ntuser/window.c +++ b/reactos/subsystems/win32/win32k/ntuser/window.c @@ -2130,7 +2130,6 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, } Window->rcClient = Window->rcWindow; - /* Link the window*/ if (NULL != ParentWindow) { @@ -2140,7 +2139,7 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs, else IntLinkHwnd(Window, hwndInsertAfter); } - + /* Send the NCCREATE message */ Result = co_IntSendMessage(UserHMGetHandle(Window), WM_NCCREATE, 0, (LPARAM) Cs); if (!Result) @@ -3886,8 +3885,8 @@ NtUserSetWindowFNID(HWND hWnd, // From user land we only set these. if (fnID != FNID_DESTROY) - { - if ( ((fnID < FNID_BUTTON) && (fnID > FNID_GHOST)) || + { // Hacked so we can mark desktop~! + if ( (/*(fnID < FNID_BUTTON)*/ (fnID < FNID_FIRST) && (fnID > FNID_GHOST)) || Wnd->fnid != 0 ) { EngSetLastError(ERROR_INVALID_PARAMETER);