From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/win32u/class.c | 55 ++++++++++++++++----------------------------- server/class.c | 8 +++++++ server/protocol.def | 3 +++ server/trace.c | 5 +++-- tools/make_requests | 2 +- 5 files changed, 34 insertions(+), 39 deletions(-) diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 1ec80f458f5..9559f6d5fdf 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -51,8 +51,6 @@ typedef struct tagCLASS HICON hIcon; /* Default icon */ HICON hIconSm; /* Default small icon */ HICON icon_internal; /* internal small icon, derived from hIcon */ - HCURSOR hCursor; /* Default cursor */ - HBRUSH hbrBackground; /* Default background */ struct client_menu_name *menu_name; /* Default menu name */ const shared_object_t *shared; /* class object in session shared memory */ } CLASS; @@ -566,6 +564,8 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam .style = wc->style, .cls_extra = wc->cbClsExtra, .win_extra = wc->cbWndExtra, + .cursor = wine_server_user_handle( wc->hCursor ), + .background = wine_server_user_handle( wc->hbrBackground ), .instance = wine_server_client_ptr( instance ), .wndproc = wine_server_client_ptr( wndproc ), }; @@ -605,8 +605,6 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam class->hIcon = wc->hIcon; class->hIconSm = wc->hIconSm; class->icon_internal = icon_internal; - class->hCursor = wc->hCursor; - class->hbrBackground = wc->hbrBackground; class->menu_name = menu_name; class->shared = shared; release_class_ptr( class ); @@ -627,6 +625,7 @@ BOOL WINAPI NtUserUnregisterClass( UNICODE_STRING *name, HINSTANCE instance, str { struct list drawables = LIST_INIT( drawables ); CLASS *class = NULL; + HBRUSH background; /* create the desktop window to trigger builtin class registration */ get_desktop_window(); @@ -637,7 +636,9 @@ BOOL WINAPI NtUserUnregisterClass( UNICODE_STRING *name, HINSTANCE instance, str { req->instance = wine_server_client_ptr( instance ); req->atom = wine_server_add_atom( req, name ); - if (!wine_server_call_err( req )) class = wine_server_get_ptr( reply->client_ptr ); + wine_server_call_err( req ); + class = wine_server_get_ptr( reply->client_ptr ); + background = wine_server_ptr_handle( reply->background ); } SERVER_END_REQ; if (!class) @@ -650,8 +651,8 @@ BOOL WINAPI NtUserUnregisterClass( UNICODE_STRING *name, HINSTANCE instance, str if (class->dce) free_dce( class->dce, 0, &drawables ); list_remove( &class->entry ); - if (class->hbrBackground > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1)) - NtGdiDeleteObjectApp( class->hbrBackground ); + if (background > (HBRUSH)(COLOR_GRADIENTINACTIVECAPTION + 1)) + NtGdiDeleteObjectApp( background ); *menu_name = class->menu_name; NtUserDestroyCursor( class->icon_internal, 0 ); free( class ); @@ -689,8 +690,8 @@ ATOM WINAPI NtUserGetClassInfoEx( HINSTANCE instance, UNICODE_STRING *name, WNDC wc->hInstance = (instance == user32_module) ? 0 : instance; wc->hIcon = class->hIcon; wc->hIconSm = class->hIconSm; - wc->hCursor = class->hCursor; - wc->hbrBackground = class->hbrBackground; + wc->hCursor = wine_server_ptr_handle( class_shm->info.cursor ); + wc->hbrBackground = wine_server_ptr_handle( class_shm->info.background ); wc->lpszMenuName = (WCHAR *)class->menu_name; wc->lpszClassName = name->Buffer; } @@ -840,6 +841,13 @@ static ULONG_PTR set_class_long_size( HWND hwnd, INT offset, LONG_PTR newval, UI switch(offset) { + case GCL_CBWNDEXTRA: + case GCL_STYLE: + case GCLP_HBRBACKGROUND: + case GCLP_HCURSOR: + case GCLP_HMODULE: + set_server_info( hwnd, offset, newval, size, &retval ); + break; case GCLP_MENUNAME: retval = (ULONG_PTR)class->menu_name; class->menu_name = (void *)newval; @@ -849,14 +857,6 @@ static ULONG_PTR set_class_long_size( HWND hwnd, INT offset, LONG_PTR newval, UI if (!set_server_info( hwnd, offset, newval, size, &retval )) break; retval = (ULONG_PTR)get_winproc( (WNDPROC)retval, ansi ); break; - case GCLP_HBRBACKGROUND: - retval = (ULONG_PTR)class->hbrBackground; - class->hbrBackground = (HBRUSH)newval; - break; - case GCLP_HCURSOR: - retval = (ULONG_PTR)class->hCursor; - class->hCursor = (HCURSOR)newval; - break; case GCLP_HICON: retval = (ULONG_PTR)class->hIcon; if (retval == newval) break; @@ -867,15 +867,6 @@ static ULONG_PTR set_class_long_size( HWND hwnd, INT offset, LONG_PTR newval, UI if (retval == newval) break; class->hIconSm = (HICON)newval; break; - case GCL_STYLE: - if (!set_server_info( hwnd, offset, newval, size, &retval )) break; - break; - case GCL_CBWNDEXTRA: - if (!set_server_info( hwnd, offset, newval, size, &retval )) break; - break; - case GCLP_HMODULE: - if (!set_server_info( hwnd, offset, newval, size, &retval )) break; - break; case GCL_CBCLSEXTRA: /* cannot change this one */ RtlSetLastWin32Error( ERROR_INVALID_PARAMETER ); break; @@ -938,6 +929,8 @@ static ULONG_PTR get_class_long_shm( HWND hwnd, INT offset, UINT size, BOOL ansi case GCL_CBCLSEXTRA: ret = class_shm->info.cls_extra; break; case GCL_CBWNDEXTRA: ret = class_shm->info.win_extra; break; case GCLP_HMODULE: ret = class_shm->info.instance; break; + case GCLP_HCURSOR: ret = class_shm->info.cursor; break; + case GCLP_HBRBACKGROUND: ret = class_shm->info.background; break; default: valid = offset >= 0 && offset <= (INT)(class_shm->info.cls_extra - size); if (valid) memcpy( &ret, (char *)class_shm->extra + offset, size ); @@ -969,8 +962,6 @@ static ULONG_PTR get_class_long_size( HWND hwnd, INT offset, UINT size, BOOL ans { case GCLP_HICONSM: case GCLP_HICON: - case GCLP_HCURSOR: - case GCLP_HBRBACKGROUND: case GCLP_MENUNAME: break; default: @@ -990,8 +981,6 @@ static ULONG_PTR get_class_long_size( HWND hwnd, INT offset, UINT size, BOOL ans { switch (offset) { - case GCLP_HBRBACKGROUND: - case GCLP_HCURSOR: case GCLP_HICON: case GCLP_HICONSM: case GCLP_MENUNAME: @@ -1009,12 +998,6 @@ static ULONG_PTR get_class_long_size( HWND hwnd, INT offset, UINT size, BOOL ans switch(offset) { - case GCLP_HBRBACKGROUND: - retvalue = (ULONG_PTR)class->hbrBackground; - break; - case GCLP_HCURSOR: - retvalue = (ULONG_PTR)class->hCursor; - break; case GCLP_HICON: retvalue = (ULONG_PTR)class->hIcon; break; diff --git a/server/class.c b/server/class.c index bb78cf26b44..bac616e294c 100644 --- a/server/class.c +++ b/server/class.c @@ -316,6 +316,14 @@ DECL_HANDLER(set_class_info) reply->old_info = shared->info.wndproc; shared->info.wndproc = req->new_info; break; + case GCLP_HCURSOR: + reply->old_info = shared->info.cursor; + shared->info.cursor = req->new_info; + break; + case GCLP_HBRBACKGROUND: + reply->old_info = shared->info.background; + shared->info.background = req->new_info; + break; default: if (req->size > sizeof(req->new_info) || req->offset < 0 || req->offset > class->shared->info.cls_extra - (int)req->size) diff --git a/server/protocol.def b/server/protocol.def index 9632b8d424b..f20488311fc 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1044,6 +1044,8 @@ struct class_info unsigned int style; /* class style */ unsigned int cls_extra; /* number of class extra bytes */ unsigned int win_extra; /* number of window extra bytes */ + user_handle_t cursor; /* default cursor */ + user_handle_t background; /* default background */ mod_handle_t instance; /* module instance */ client_ptr_t wndproc; /* class window proc */ }; @@ -3291,6 +3293,7 @@ enum caret_state VARARG(name,unicode_str); /* class name */ @REPLY client_ptr_t client_ptr; /* pointer to class in client address space */ + user_handle_t background; /* class default background */ @END diff --git a/server/trace.c b/server/trace.c index a3cc1f5aeec..9fb3b3f2b1c 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1658,8 +1658,9 @@ static void dump_varargs_class_info( const char *prefix, data_size_t size ) { const struct class_info *info = cur_data; - fprintf( stderr, "%s{atom=%#x,style=%#x,cls_extra=%u,win_extra=%u", - prefix, info->atom, info->style, info->cls_extra, info->win_extra ); + fprintf( stderr, "%s{atom=%#x,style=%#x,cls_extra=%u,win_extra=%u,cursor=%#x,background=%#x", + prefix, info->atom, info->style, info->cls_extra, info->win_extra, info->cursor, + info->background ); dump_uint64( ",instance=", &info->instance ); dump_uint64( ",wndproc=", &info->wndproc ); fputc( '}', stderr ); diff --git a/tools/make_requests b/tools/make_requests index e92fb10d8f9..3d15a10fbd4 100755 --- a/tools/make_requests +++ b/tools/make_requests @@ -68,7 +68,7 @@ my %formats = "struct thread_info" => [ 40, 8 ], "union udp_endpoint" => [ 32, 4 ], "struct user_apc" => [ 40, 8 ], - "struct class_info" => [ 32, 8 ], + "struct class_info" => [ 40, 8 ], ); my $file_header = -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10959