win32u: Move ScreenToClient implementation from user32.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-03-23 14:02:18 +01:00 committed by Alexandre Julliard
parent 0cfc7c4458
commit b133b756de
3 changed files with 23 additions and 14 deletions

View File

@ -432,21 +432,9 @@ BOOL WINAPI ClientToScreen( HWND hwnd, LPPOINT lppnt )
/******************************************************************* /*******************************************************************
* ScreenToClient (USER32.@) * ScreenToClient (USER32.@)
*/ */
BOOL WINAPI ScreenToClient( HWND hwnd, LPPOINT lppnt ) BOOL WINAPI ScreenToClient( HWND hwnd, POINT *pt )
{ {
POINT offset; return NtUserCallHwndParam( hwnd, (UINT_PTR)pt, NtUserScreenToClient );
BOOL mirrored;
if (!hwnd)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return FALSE;
}
if (!WINPOS_GetWinOffset( 0, hwnd, &mirrored, &offset )) return FALSE;
lppnt->x += offset.x;
lppnt->y += offset.y;
if (mirrored) lppnt->x = -lppnt->x;
return TRUE;
} }

View File

@ -2587,6 +2587,24 @@ other_process: /* one of the parents may belong to another process, do it the h
return ret; return ret;
} }
/* see ScreenToClient */
static BOOL screen_to_client( HWND hwnd, POINT *pt )
{
POINT offset;
BOOL mirrored;
if (!hwnd)
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return FALSE;
}
if (!get_windows_offset( 0, hwnd, get_thread_dpi(), &mirrored, &offset )) return FALSE;
pt->x += offset.x;
pt->y += offset.y;
if (mirrored) pt->x = -pt->x;
return TRUE;
}
/* map coordinates of a window region */ /* map coordinates of a window region */
void map_window_region( HWND from, HWND to, HRGN hrgn ) void map_window_region( HWND from, HWND to, HRGN hrgn )
{ {
@ -5019,6 +5037,8 @@ ULONG_PTR WINAPI NtUserCallHwndParam( HWND hwnd, DWORD_PTR param, DWORD code )
return kill_system_timer( hwnd, param ); return kill_system_timer( hwnd, param );
case NtUserMonitorFromWindow: case NtUserMonitorFromWindow:
return HandleToUlong( monitor_from_window( hwnd, param, NtUserMonitorFromWindow )); return HandleToUlong( monitor_from_window( hwnd, param, NtUserMonitorFromWindow ));
case NtUserScreenToClient:
return screen_to_client( hwnd, (POINT *)param );
case NtUserSetCaptureWindow: case NtUserSetCaptureWindow:
return set_capture_window( hwnd, param, NULL ); return set_capture_window( hwnd, param, NULL );
case NtUserSetForegroundWindow: case NtUserSetForegroundWindow:

View File

@ -212,6 +212,7 @@ enum
NtUserIsChild, NtUserIsChild,
NtUserKillSystemTimer, NtUserKillSystemTimer,
NtUserMonitorFromWindow, NtUserMonitorFromWindow,
NtUserScreenToClient,
NtUserSetCaptureWindow, NtUserSetCaptureWindow,
NtUserSetForegroundWindow, NtUserSetForegroundWindow,
NtUserSetWindowPixelFormat, NtUserSetWindowPixelFormat,