From: Rémi Bernon <rbernon@codeweavers.com> --- dlls/win32u/class.c | 55 ++++++++++++++++----------------------------- server/class.c | 10 +++++++++ server/protocol.def | 5 +++++ 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index ea814d8696b..1212e1c3e0c 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; @@ -563,6 +561,8 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam { req->local = class->local; req->style = wc->style; + req->cursor = wine_server_user_handle( wc->hCursor ); + req->background = wine_server_user_handle( wc->hbrBackground ); req->instance = wine_server_client_ptr( instance ); req->cls_extra = wc->cbClsExtra; req->win_extra = wc->cbWndExtra; @@ -601,8 +601,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 ); @@ -623,6 +621,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(); @@ -633,7 +632,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) @@ -646,8 +647,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 ); @@ -685,8 +686,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->cursor ); + wc->hbrBackground = wine_server_ptr_handle( class_shm->background ); wc->lpszMenuName = (WCHAR *)class->menu_name; wc->lpszClassName = name->Buffer; } @@ -836,6 +837,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; @@ -845,14 +853,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; @@ -863,15 +863,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; @@ -934,6 +925,8 @@ static ULONG_PTR get_class_long_shm( HWND hwnd, INT offset, UINT size, BOOL ansi case GCL_CBCLSEXTRA: ret = class_shm->cls_extra; break; case GCL_CBWNDEXTRA: ret = class_shm->win_extra; break; case GCLP_HMODULE: ret = class_shm->instance; break; + case GCLP_HCURSOR: ret = class_shm->cursor; break; + case GCLP_HBRBACKGROUND: ret = class_shm->background; break; default: valid = offset >= 0 && offset <= (INT)(class_shm->cls_extra - size); if (valid) memcpy( &ret, (char *)class_shm->extra + offset, size ); @@ -964,8 +957,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: @@ -985,8 +976,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: @@ -1004,12 +993,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 1faf8618ebc..59fc4aecc1e 100644 --- a/server/class.c +++ b/server/class.c @@ -239,6 +239,8 @@ DECL_HANDLER(create_class) shared->name_offset = name_offset; shared->name_len = name.len; shared->atom = base_atom; + shared->cursor = req->cursor; + shared->background = req->background; shared->instance = req->instance; shared->style = req->style; shared->wndproc = req->wndproc; @@ -315,6 +317,14 @@ DECL_HANDLER(set_class_info) reply->old_info = shared->wndproc; shared->wndproc = req->new_info; break; + case GCLP_HCURSOR: + reply->old_info = shared->cursor; + shared->cursor = req->new_info; + break; + case GCLP_HBRBACKGROUND: + reply->old_info = shared->background; + shared->background = req->new_info; + break; default: if (req->size > sizeof(req->new_info) || req->offset < 0 || req->offset > class->shared->cls_extra - (int)req->size) diff --git a/server/protocol.def b/server/protocol.def index a10e2c0ca08..4aab2d11cf1 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1045,6 +1045,8 @@ typedef volatile struct client_ptr_t wndproc; /* class window proc */ 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 */ data_size_t name_offset; /* offset in WCHAR of the unversioned class name, constant */ data_size_t name_len; /* len in bytes of the class name, constant */ @@ -3270,6 +3272,8 @@ enum caret_state int local; /* is it a local class? */ atom_t atom; /* class atom */ unsigned int style; /* class style */ + user_handle_t cursor; /* class default cursor */ + user_handle_t background; /* class default background */ mod_handle_t instance; /* module instance */ client_ptr_t client_ptr; /* pointer to class in client address space */ client_ptr_t wndproc; /* class window proc client pointer */ @@ -3290,6 +3294,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 -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10959