win32u: Move GetDpiForWindow 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-09 15:22:07 +01:00 committed by Alexandre Julliard
parent 7231632635
commit 6c8cac10ef
5 changed files with 48 additions and 29 deletions

View File

@ -2099,35 +2099,7 @@ DPI_AWARENESS_CONTEXT WINAPI GetWindowDpiAwarenessContext( HWND hwnd )
*/
UINT WINAPI GetDpiForWindow( HWND hwnd )
{
WND *win;
UINT ret = 0;
if (!(win = WIN_GetPtr( hwnd )))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (win == WND_DESKTOP)
{
POINT pt = { 0, 0 };
return get_monitor_dpi( MonitorFromPoint( pt, MONITOR_DEFAULTTOPRIMARY ));
}
if (win != WND_OTHER_PROCESS)
{
ret = win->dpi;
if (!ret) ret = get_win_monitor_dpi( hwnd );
WIN_ReleasePtr( win );
}
else
{
SERVER_START_REQ( get_window_info )
{
req->handle = wine_server_user_handle( hwnd );
if (!wine_server_call_err( req )) ret = reply->dpi;
}
SERVER_END_REQ;
}
return ret;
return NtUserCallHwnd( hwnd, NtUserGetDpiForWindow );
}

View File

@ -1379,6 +1379,15 @@ UINT get_monitor_dpi( HMONITOR monitor )
return system_dpi;
}
/**********************************************************************
* get_win_monitor_dpi
*/
UINT get_win_monitor_dpi( HWND hwnd )
{
/* FIXME: use the monitor DPI instead */
return system_dpi;
}
/**********************************************************************
* get_thread_dpi_awareness
*/

View File

@ -284,6 +284,7 @@ extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
/* sysparams.c */
extern RECT get_display_rect( const WCHAR *display ) DECLSPEC_HIDDEN;
extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
extern UINT get_win_monitor_dpi( HWND hwnd ) DECLSPEC_HIDDEN;
extern UINT get_system_dpi(void) DECLSPEC_HIDDEN;
extern int get_system_metrics( int index ) DECLSPEC_HIDDEN;
extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN;

View File

@ -708,6 +708,40 @@ static DPI_AWARENESS_CONTEXT get_window_dpi_awareness_context( HWND hwnd )
return ret;
}
/* see GetDpiForWindow */
static UINT get_dpi_for_window( HWND hwnd )
{
WND *win;
UINT ret = 0;
if (!(win = get_win_ptr( hwnd )))
{
SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
}
if (win == WND_DESKTOP)
{
POINT pt = { 0, 0 };
return get_monitor_dpi( monitor_from_point( pt, MONITOR_DEFAULTTOPRIMARY, 0 ));
}
if (win != WND_OTHER_PROCESS)
{
ret = win->dpi;
if (!ret) ret = get_win_monitor_dpi( hwnd );
release_win_ptr( win );
}
else
{
SERVER_START_REQ( get_window_info )
{
req->handle = wine_server_user_handle( hwnd );
if (!wine_server_call_err( req )) ret = reply->dpi;
}
SERVER_END_REQ;
}
return ret;
}
static LONG_PTR get_win_data( const void *ptr, UINT size )
{
if (size == sizeof(WORD))
@ -1115,6 +1149,8 @@ ULONG_PTR WINAPI NtUserCallHwnd( HWND hwnd, DWORD code )
{
switch (code)
{
case NtUserGetDpiForWindow:
return get_dpi_for_window( hwnd );
case NtUserGetParent:
return HandleToUlong( get_parent( hwnd ));
case NtUserGetWindowDpiAwarenessContext:

View File

@ -141,6 +141,7 @@ enum
/* NtUserCallHwnd codes, not compatible with Windows */
enum
{
NtUserGetDpiForWindow,
NtUserGetParent,
NtUserGetWindowDpiAwarenessContext,
NtUserGetWindowTextLength,