user32: Store the window DPI awareness in the server.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-05-15 16:18:16 +02:00
parent a67a3305d6
commit 433788736b
8 changed files with 68 additions and 31 deletions

View File

@ -3526,7 +3526,7 @@ static void test_dpi_window(void)
DPI_AWARENESS_CONTEXT context, orig;
DPI_AWARENESS awareness;
ULONG_PTR i, j;
HWND hwnd;
HWND hwnd, child;
MSG msg = { 0, WM_USER + 1, 0, 0 };
if (!pGetWindowDpiAwarenessContext)
@ -3551,6 +3551,12 @@ static void test_dpi_window(void)
SendMessageA( hwnd, WM_USER, 0, 0 );
DispatchMessageA( &msg );
CallWindowProcA( dpi_winproc, hwnd, WM_USER + 2, 0, 0 );
child = CreateWindowA( "DpiTestClass", "Test",
WS_CHILD, 0, 0, 100, 100, hwnd, 0, GetModuleHandleA(0), NULL );
context = pGetWindowDpiAwarenessContext( child );
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == i, "%lu/%lu: wrong awareness %u\n", i, j, awareness );
DestroyWindow( child );
}
DestroyWindow( hwnd );
}

View File

@ -200,12 +200,14 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name,
HWND handle = 0, full_parent = 0, full_owner = 0;
struct tagCLASS *class = NULL;
int extra_bytes = 0;
DPI_AWARENESS awareness = GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() );
SERVER_START_REQ( create_window )
{
req->parent = wine_server_user_handle( parent );
req->owner = wine_server_user_handle( owner );
req->instance = wine_server_client_ptr( instance );
req->awareness = awareness;
if (!(req->atom = get_int_atom_value( name )) && name)
wine_server_add_data( req, name, strlenW(name)*sizeof(WCHAR) );
if (!wine_server_call_err( req ))
@ -214,6 +216,7 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name,
full_parent = wine_server_ptr_handle( reply->parent );
full_owner = wine_server_ptr_handle( reply->owner );
extra_bytes = reply->extra;
awareness = reply->awareness;
class = wine_server_get_ptr( reply->class_ptr );
}
}
@ -266,6 +269,7 @@ static WND *create_window_handle( HWND parent, HWND owner, LPCWSTR name,
win->class = class;
win->winproc = get_class_winproc( class );
win->cbWndExtra = extra_bytes;
win->dpi_awareness = awareness;
InterlockedExchangePointer( &user_handles[index], win );
if (WINPROC_IsUnicode( win->winproc, unicode )) win->flags |= WIN_ISUNICODE;
return win;
@ -1464,7 +1468,6 @@ HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module,
wndPtr->hIconSmall = 0;
wndPtr->hIconSmall2 = 0;
wndPtr->hSysMenu = 0;
wndPtr->dpi_awareness = GetThreadDpiAwarenessContext();
wndPtr->min_pos.x = wndPtr->min_pos.y = -1;
wndPtr->max_pos.x = wndPtr->max_pos.y = -1;
@ -2188,7 +2191,7 @@ BOOL WINAPI IsWindowUnicode( HWND hwnd )
DPI_AWARENESS_CONTEXT WINAPI GetWindowDpiAwarenessContext( HWND hwnd )
{
WND *win;
DPI_AWARENESS_CONTEXT ret;
DPI_AWARENESS_CONTEXT ret = 0;
if (!(win = WIN_GetPtr( hwnd )))
{
@ -2196,14 +2199,20 @@ DPI_AWARENESS_CONTEXT WINAPI GetWindowDpiAwarenessContext( HWND hwnd )
return 0;
}
if (win == WND_DESKTOP) return DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE;
if (win == WND_OTHER_PROCESS)
if (win != WND_OTHER_PROCESS)
{
if (IsWindow( hwnd )) FIXME( "not supported on other process window %p\n", hwnd );
else SetLastError( ERROR_INVALID_WINDOW_HANDLE );
return 0;
ret = ULongToHandle( win->dpi_awareness | 0x10 );
WIN_ReleasePtr( win );
}
else
{
SERVER_START_REQ( get_window_info )
{
req->handle = wine_server_user_handle( hwnd );
if (!wine_server_call_err( req )) ret = ULongToHandle( reply->awareness | 0x10 );
}
SERVER_END_REQ;
}
ret = win->dpi_awareness;
WIN_ReleasePtr( win );
return ret;
}

View File

@ -61,7 +61,7 @@ typedef struct tagWND
HICON hIcon; /* window's icon */
HICON hIconSmall; /* window's small icon */
HICON hIconSmall2; /* window's secondary small icon, derived from hIcon */
DPI_AWARENESS_CONTEXT dpi_awareness; /* DPI awareness context */
DPI_AWARENESS dpi_awareness; /* DPI awareness */
struct window_surface *surface; /* Window surface if any */
struct tagDIALOGINFO *dlgInfo;/* Dialog additional info (dialogs only) */
int pixel_format; /* Pixel format set by the graphics driver */

View File

@ -3443,7 +3443,9 @@ struct create_window_request
user_handle_t owner;
atom_t atom;
mod_handle_t instance;
int awareness;
/* VARARG(class,unicode_str); */
char __pad_36[4];
};
struct create_window_reply
{
@ -3453,6 +3455,8 @@ struct create_window_reply
user_handle_t owner;
int extra;
client_ptr_t class_ptr;
int awareness;
char __pad_36[4];
};
@ -3513,6 +3517,8 @@ struct get_window_info_reply
thread_id_t tid;
atom_t atom;
int is_unicode;
int awareness;
char __pad_36[4];
};
@ -6501,6 +6507,6 @@ union generic_reply
struct terminate_job_reply terminate_job_reply;
};
#define SERVER_PROTOCOL_VERSION 548
#define SERVER_PROTOCOL_VERSION 549
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -2476,6 +2476,7 @@ enum message_type
user_handle_t owner; /* owner window */
atom_t atom; /* class atom */
mod_handle_t instance; /* module instance */
int awareness; /* thread DPI awareness */
VARARG(class,unicode_str); /* class name */
@REPLY
user_handle_t handle; /* created window */
@ -2483,6 +2484,7 @@ enum message_type
user_handle_t owner; /* full handle of owner */
int extra; /* number of extra bytes */
client_ptr_t class_ptr; /* pointer to class in client address space */
int awareness; /* window DPI awareness */
@END
@ -2521,6 +2523,7 @@ enum message_type
thread_id_t tid; /* thread owning the window */
atom_t atom; /* class atom */
int is_unicode; /* ANSI or unicode */
int awareness; /* DPI awareness */
@END

View File

@ -1661,13 +1661,15 @@ C_ASSERT( FIELD_OFFSET(struct create_window_request, parent) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_window_request, owner) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_window_request, atom) == 20 );
C_ASSERT( FIELD_OFFSET(struct create_window_request, instance) == 24 );
C_ASSERT( sizeof(struct create_window_request) == 32 );
C_ASSERT( FIELD_OFFSET(struct create_window_request, awareness) == 32 );
C_ASSERT( sizeof(struct create_window_request) == 40 );
C_ASSERT( FIELD_OFFSET(struct create_window_reply, handle) == 8 );
C_ASSERT( FIELD_OFFSET(struct create_window_reply, parent) == 12 );
C_ASSERT( FIELD_OFFSET(struct create_window_reply, owner) == 16 );
C_ASSERT( FIELD_OFFSET(struct create_window_reply, extra) == 20 );
C_ASSERT( FIELD_OFFSET(struct create_window_reply, class_ptr) == 24 );
C_ASSERT( sizeof(struct create_window_reply) == 32 );
C_ASSERT( FIELD_OFFSET(struct create_window_reply, awareness) == 32 );
C_ASSERT( sizeof(struct create_window_reply) == 40 );
C_ASSERT( FIELD_OFFSET(struct destroy_window_request, handle) == 12 );
C_ASSERT( sizeof(struct destroy_window_request) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_desktop_window_request, force) == 12 );
@ -1689,7 +1691,8 @@ C_ASSERT( FIELD_OFFSET(struct get_window_info_reply, pid) == 16 );
C_ASSERT( FIELD_OFFSET(struct get_window_info_reply, tid) == 20 );
C_ASSERT( FIELD_OFFSET(struct get_window_info_reply, atom) == 24 );
C_ASSERT( FIELD_OFFSET(struct get_window_info_reply, is_unicode) == 28 );
C_ASSERT( sizeof(struct get_window_info_reply) == 32 );
C_ASSERT( FIELD_OFFSET(struct get_window_info_reply, awareness) == 32 );
C_ASSERT( sizeof(struct get_window_info_reply) == 40 );
C_ASSERT( FIELD_OFFSET(struct set_window_info_request, flags) == 12 );
C_ASSERT( FIELD_OFFSET(struct set_window_info_request, is_unicode) == 14 );
C_ASSERT( FIELD_OFFSET(struct set_window_info_request, handle) == 16 );

View File

@ -3038,6 +3038,7 @@ static void dump_create_window_request( const struct create_window_request *req
fprintf( stderr, ", owner=%08x", req->owner );
fprintf( stderr, ", atom=%04x", req->atom );
dump_uint64( ", instance=", &req->instance );
fprintf( stderr, ", awareness=%d", req->awareness );
dump_varargs_unicode_str( ", class=", cur_size );
}
@ -3048,6 +3049,7 @@ static void dump_create_window_reply( const struct create_window_reply *req )
fprintf( stderr, ", owner=%08x", req->owner );
fprintf( stderr, ", extra=%d", req->extra );
dump_uint64( ", class_ptr=", &req->class_ptr );
fprintf( stderr, ", awareness=%d", req->awareness );
}
static void dump_destroy_window_request( const struct destroy_window_request *req )
@ -3091,6 +3093,7 @@ static void dump_get_window_info_reply( const struct get_window_info_reply *req
fprintf( stderr, ", tid=%04x", req->tid );
fprintf( stderr, ", atom=%04x", req->atom );
fprintf( stderr, ", is_unicode=%d", req->is_unicode );
fprintf( stderr, ", awareness=%d", req->awareness );
}
static void dump_set_window_info_request( const struct set_window_info_request *req )
@ -5461,6 +5464,7 @@ static const struct
{ "INVALID_LOCK_SEQUENCE", STATUS_INVALID_LOCK_SEQUENCE },
{ "INVALID_OWNER", STATUS_INVALID_OWNER },
{ "INVALID_PARAMETER", STATUS_INVALID_PARAMETER },
{ "INVALID_READ_MODE", STATUS_INVALID_READ_MODE },
{ "INVALID_SECURITY_DESCR", STATUS_INVALID_SECURITY_DESCR },
{ "IO_TIMEOUT", STATUS_IO_TIMEOUT },
{ "KEY_DELETED", STATUS_KEY_DELETED },
@ -5496,6 +5500,7 @@ static const struct
{ "OBJECT_TYPE_MISMATCH", STATUS_OBJECT_TYPE_MISMATCH },
{ "PENDING", STATUS_PENDING },
{ "PIPE_BROKEN", STATUS_PIPE_BROKEN },
{ "PIPE_BUSY", STATUS_PIPE_BUSY },
{ "PIPE_CONNECTED", STATUS_PIPE_CONNECTED },
{ "PIPE_DISCONNECTED", STATUS_PIPE_DISCONNECTED },
{ "PIPE_LISTENING", STATUS_PIPE_LISTENING },

View File

@ -83,6 +83,7 @@ struct window
unsigned int color_key; /* color key for a layered window */
unsigned int alpha; /* alpha value for a layered window */
unsigned int layered_flags; /* flags for a layered window */
DPI_AWARENESS dpi_awareness; /* DPI awareness mode */
lparam_t user_data; /* user-specific data */
WCHAR *text; /* window caption text */
unsigned int paint_flags; /* various painting flags */
@ -429,7 +430,7 @@ void post_desktop_message( struct desktop *desktop, unsigned int message,
/* create a new window structure (note: the window is not linked in the window tree) */
static struct window *create_window( struct window *parent, struct window *owner,
atom_t atom, mod_handle_t instance )
atom_t atom, mod_handle_t instance, DPI_AWARENESS dpi_awareness )
{
static const rectangle_t empty_rect;
int extra_bytes;
@ -466,6 +467,8 @@ static struct window *create_window( struct window *parent, struct window *owner
goto failed;
}
if (parent && !is_desktop_window( parent )) dpi_awareness = parent->dpi_awareness;
if (!(win = mem_alloc( sizeof(*win) + extra_bytes - 1 ))) goto failed;
if (!(win->handle = alloc_user_handle( win, USER_WINDOW ))) goto failed;
@ -485,6 +488,7 @@ static struct window *create_window( struct window *parent, struct window *owner
win->is_unicode = 1;
win->is_linked = 0;
win->is_layered = 0;
win->dpi_awareness = dpi_awareness;
win->user_data = 0;
win->text = NULL;
win->paint_flags = 0;
@ -1908,12 +1912,13 @@ DECL_HANDLER(create_window)
atom = cls_name.len ? find_global_atom( NULL, &cls_name ) : req->atom;
if (!(win = create_window( parent, owner, atom, req->instance ))) return;
if (!(win = create_window( parent, owner, atom, req->instance, req->awareness ))) return;
reply->handle = win->handle;
reply->parent = win->parent ? win->parent->handle : 0;
reply->owner = win->owner;
reply->extra = win->nb_extra_bytes;
reply->awareness = win->dpi_awareness;
reply->class_ptr = get_class_client_ptr( win->class );
}
@ -1963,7 +1968,8 @@ DECL_HANDLER(get_desktop_window)
if (!desktop->top_window && force) /* create it */
{
if ((desktop->top_window = create_window( NULL, NULL, DESKTOP_ATOM, 0 )))
if ((desktop->top_window = create_window( NULL, NULL, DESKTOP_ATOM, 0,
DPI_AWARENESS_PER_MONITOR_AWARE )))
{
detach_window_thread( desktop->top_window );
desktop->top_window->style = WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
@ -1975,7 +1981,8 @@ DECL_HANDLER(get_desktop_window)
static const WCHAR messageW[] = {'M','e','s','s','a','g','e'};
static const struct unicode_str name = { messageW, sizeof(messageW) };
atom_t atom = add_global_atom( NULL, &name );
if (atom && (desktop->msg_window = create_window( NULL, NULL, atom, 0 )))
if (atom && (desktop->msg_window = create_window( NULL, NULL, atom, 0,
DPI_AWARENESS_PER_MONITOR_AWARE )))
{
detach_window_thread( desktop->msg_window );
desktop->msg_window->style = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
@ -2022,20 +2029,18 @@ DECL_HANDLER(get_window_info)
{
struct window *win = get_window( req->handle );
reply->full_handle = 0;
reply->tid = reply->pid = 0;
if (win)
if (!win) return;
reply->full_handle = win->handle;
reply->last_active = win->handle;
reply->is_unicode = win->is_unicode;
reply->awareness = win->dpi_awareness;
if (get_user_object( win->last_active, USER_WINDOW )) reply->last_active = win->last_active;
if (win->thread)
{
reply->full_handle = win->handle;
reply->last_active = win->handle;
reply->is_unicode = win->is_unicode;
if (get_user_object( win->last_active, USER_WINDOW )) reply->last_active = win->last_active;
if (win->thread)
{
reply->tid = get_thread_id( win->thread );
reply->pid = get_process_id( win->thread->process );
reply->atom = win->class ? get_class_atom( win->class ) : DESKTOP_ATOM;
}
reply->tid = get_thread_id( win->thread );
reply->pid = get_process_id( win->thread->process );
reply->atom = win->class ? get_class_atom( win->class ) : DESKTOP_ATOM;
}
}