mirror of
https://github.com/reactos/reactos.git
synced 2025-06-25 17:09:43 +00:00
Optimize ClientToScreen(), ScreenToClient() and MapWindowPoints()
svn path=/trunk/; revision=30495
This commit is contained in:
parent
43eb284cea
commit
cb75e8f462
5 changed files with 86 additions and 29 deletions
|
@ -87,3 +87,5 @@ SharedPtrToKernel(PVOID Ptr)
|
||||||
|
|
||||||
PCALLPROC FASTCALL ValidateCallProc(HANDLE hCallProc);
|
PCALLPROC FASTCALL ValidateCallProc(HANDLE hCallProc);
|
||||||
PWINDOW FASTCALL ValidateHwnd(HWND hwnd);
|
PWINDOW FASTCALL ValidateHwnd(HWND hwnd);
|
||||||
|
PWINDOW FASTCALL ValidateHwndOrDesk(HWND hwnd);
|
||||||
|
PWINDOW FASTCALL GetThreadDesktopWnd(VOID);
|
||||||
|
|
|
@ -148,6 +148,19 @@ GetW32ProcessInfo(VOID)
|
||||||
return pi;
|
return pi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static PDESKTOP
|
||||||
|
GetThreadDesktopInfo(VOID)
|
||||||
|
{
|
||||||
|
PW32THREADINFO ti;
|
||||||
|
PDESKTOP di = NULL;
|
||||||
|
|
||||||
|
ti = GetW32ThreadInfo();
|
||||||
|
if (ti != NULL)
|
||||||
|
di = DesktopPtrToUser(ti->Desktop);
|
||||||
|
|
||||||
|
return di;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetUserObjectSecurity
|
* GetUserObjectSecurity
|
||||||
|
@ -429,6 +442,7 @@ PWINDOW
|
||||||
FASTCALL
|
FASTCALL
|
||||||
ValidateHwnd(HWND hwnd)
|
ValidateHwnd(HWND hwnd)
|
||||||
{
|
{
|
||||||
|
PWINDOW Wnd;
|
||||||
PW32CLIENTINFO ClientInfo = GetWin32ClientInfo();
|
PW32CLIENTINFO ClientInfo = GetWin32ClientInfo();
|
||||||
ASSERT(ClientInfo != NULL);
|
ASSERT(ClientInfo != NULL);
|
||||||
|
|
||||||
|
@ -436,7 +450,7 @@ ValidateHwnd(HWND hwnd)
|
||||||
if (hwnd == ClientInfo->hWND)
|
if (hwnd == ClientInfo->hWND)
|
||||||
return ClientInfo->pvWND;
|
return ClientInfo->pvWND;
|
||||||
|
|
||||||
PWINDOW Wnd = ValidateHandle((HANDLE)hwnd, VALIDATE_TYPE_WIN);
|
Wnd = ValidateHandle((HANDLE)hwnd, VALIDATE_TYPE_WIN);
|
||||||
if (Wnd != NULL)
|
if (Wnd != NULL)
|
||||||
{
|
{
|
||||||
/* FIXME: Check if handle table entry is marked as deleting and
|
/* FIXME: Check if handle table entry is marked as deleting and
|
||||||
|
@ -459,3 +473,26 @@ ValidateHwnd(HWND hwnd)
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PWINDOW
|
||||||
|
FASTCALL
|
||||||
|
GetThreadDesktopWnd(VOID)
|
||||||
|
{
|
||||||
|
PWINDOW Wnd = GetThreadDesktopInfo()->Wnd;
|
||||||
|
if (Wnd != NULL)
|
||||||
|
Wnd = DesktopPtrToUser(Wnd);
|
||||||
|
return Wnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate a window handle and return the pointer to the object.
|
||||||
|
//
|
||||||
|
PWINDOW
|
||||||
|
FASTCALL
|
||||||
|
ValidateHwndOrDesk(HWND hwnd)
|
||||||
|
{
|
||||||
|
if (hwnd == HWND_DESKTOP)
|
||||||
|
return GetThreadDesktopWnd();
|
||||||
|
|
||||||
|
return ValidateHwnd(hwnd);
|
||||||
|
}
|
||||||
|
|
|
@ -1577,36 +1577,28 @@ WindowFromPoint(POINT Point)
|
||||||
int STDCALL
|
int STDCALL
|
||||||
MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
|
MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
|
||||||
{
|
{
|
||||||
POINT FromOffset, ToOffset;
|
PWINDOW FromWnd, ToWnd;
|
||||||
LONG XMove, YMove;
|
POINT Delta;
|
||||||
ULONG i;
|
UINT i;
|
||||||
|
|
||||||
if (hWndFrom == NULL)
|
FromWnd = ValidateHwndOrDesk(hWndFrom);
|
||||||
{
|
if (!FromWnd)
|
||||||
FromOffset.x = FromOffset.y = 0;
|
return 0;
|
||||||
} else
|
|
||||||
if(!NtUserGetClientOrigin(hWndFrom, &FromOffset))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hWndTo == NULL)
|
ToWnd = ValidateHwndOrDesk(hWndTo);
|
||||||
{
|
if (!ToWnd)
|
||||||
ToOffset.x = ToOffset.y = 0;
|
return 0;
|
||||||
} else
|
|
||||||
if(!NtUserGetClientOrigin(hWndTo, &ToOffset))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
XMove = FromOffset.x - ToOffset.x;
|
|
||||||
YMove = FromOffset.y - ToOffset.y;
|
|
||||||
|
|
||||||
for (i = 0; i < cPoints; i++)
|
Delta.x = FromWnd->ClientRect.left - ToWnd->ClientRect.left;
|
||||||
|
Delta.y = FromWnd->ClientRect.top - ToWnd->ClientRect.top;
|
||||||
|
|
||||||
|
for (i = 0; i != cPoints; i++)
|
||||||
{
|
{
|
||||||
lpPoints[i].x += XMove;
|
lpPoints[i].x += Delta.x;
|
||||||
lpPoints[i].y += YMove;
|
lpPoints[i].y += Delta.y;
|
||||||
}
|
}
|
||||||
return(MAKELONG(LOWORD(XMove), LOWORD(YMove)));
|
|
||||||
|
return MAKELONG(LOWORD(Delta.x), LOWORD(Delta.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1616,7 +1608,18 @@ MapWindowPoints(HWND hWndFrom, HWND hWndTo, LPPOINT lpPoints, UINT cPoints)
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
ScreenToClient(HWND hWnd, LPPOINT lpPoint)
|
ScreenToClient(HWND hWnd, LPPOINT lpPoint)
|
||||||
{
|
{
|
||||||
return(MapWindowPoints(NULL, hWnd, lpPoint, 1) != 0);
|
PWINDOW Wnd, DesktopWnd;
|
||||||
|
|
||||||
|
Wnd = ValidateHwnd(hWnd);
|
||||||
|
if (!Wnd)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
DesktopWnd = GetThreadDesktopWnd();
|
||||||
|
|
||||||
|
lpPoint->x += DesktopWnd->ClientRect.left - Wnd->ClientRect.left;
|
||||||
|
lpPoint->y += DesktopWnd->ClientRect.top - Wnd->ClientRect.top;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1626,7 +1629,18 @@ ScreenToClient(HWND hWnd, LPPOINT lpPoint)
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
ClientToScreen(HWND hWnd, LPPOINT lpPoint)
|
ClientToScreen(HWND hWnd, LPPOINT lpPoint)
|
||||||
{
|
{
|
||||||
return (MapWindowPoints( hWnd, NULL, lpPoint, 1 ) != 0);
|
PWINDOW Wnd, DesktopWnd;
|
||||||
|
|
||||||
|
Wnd = ValidateHwnd(hWnd);
|
||||||
|
if (!Wnd)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
DesktopWnd = GetThreadDesktopWnd();
|
||||||
|
|
||||||
|
lpPoint->x += Wnd->ClientRect.left - DesktopWnd->ClientRect.left;
|
||||||
|
lpPoint->y += Wnd->ClientRect.top - DesktopWnd->ClientRect.top;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
struct _W32PROCESSINFO;
|
struct _W32PROCESSINFO;
|
||||||
struct _W32THREADINFO;
|
struct _W32THREADINFO;
|
||||||
|
struct _WINDOW;
|
||||||
|
|
||||||
typedef struct _REGISTER_SYSCLASS
|
typedef struct _REGISTER_SYSCLASS
|
||||||
{
|
{
|
||||||
|
@ -22,9 +23,11 @@ typedef struct _DESKTOP
|
||||||
{
|
{
|
||||||
HANDLE hKernelHeap;
|
HANDLE hKernelHeap;
|
||||||
ULONG_PTR HeapLimit;
|
ULONG_PTR HeapLimit;
|
||||||
WCHAR szDesktopName[1];
|
|
||||||
HWND hTaskManWindow;
|
HWND hTaskManWindow;
|
||||||
HWND hProgmanWindow;
|
HWND hProgmanWindow;
|
||||||
|
struct _WINDOW *Wnd;
|
||||||
|
|
||||||
|
WCHAR szDesktopName[1];
|
||||||
} DESKTOP, *PDESKTOP;
|
} DESKTOP, *PDESKTOP;
|
||||||
|
|
||||||
typedef struct _CALLPROC
|
typedef struct _CALLPROC
|
||||||
|
|
|
@ -1600,6 +1600,7 @@ AllocErr:
|
||||||
{
|
{
|
||||||
/* If there is no desktop window yet, we must be creating it */
|
/* If there is no desktop window yet, we must be creating it */
|
||||||
PsGetCurrentThreadWin32Thread()->Desktop->DesktopWindow = hWnd;
|
PsGetCurrentThreadWin32Thread()->Desktop->DesktopWindow = hWnd;
|
||||||
|
PsGetCurrentThreadWin32Thread()->Desktop->DesktopInfo->Wnd = Wnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue