From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 22 +++++++++++++++++----- dlls/win32u/ntuser_private.h | 2 ++ dlls/win32u/window.c | 11 ++++++----- server/class.c | 2 +- server/user.h | 2 +- server/window.c | 2 +- 6 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index f92bee2ef08..cafd39f7fea 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -312,6 +312,22 @@ atom_t wine_server_add_atom( void *req, UNICODE_STRING *str ) return atom; }
+BOOL is_desktop_class( UNICODE_STRING *name ) +{ + static const WCHAR desktopW[] = {'#','3','2','7','6','9'}; + ATOM atom; + if ((atom = get_int_atom_value( name ))) return atom == DESKTOP_CLASS_ATOM; + return name->Length == sizeof(desktopW) && !wcsnicmp( name->Buffer, desktopW, ARRAY_SIZE(desktopW) ); +} + +BOOL is_message_class( UNICODE_STRING *name ) +{ + static const WCHAR messageW[] = {'M','e','s','s','a','g','e'}; + ATOM atom; + if ((atom = get_int_atom_value( name ))) return FALSE; + return name->Length == sizeof(messageW) && !wcsnicmp( name->Buffer, messageW, ARRAY_SIZE(messageW) ); +} + static unsigned int is_integral_atom( const WCHAR *atomstr, ULONG len, RTL_ATOM *ret_atom ) { RTL_ATOM atom; @@ -588,15 +604,11 @@ BOOL WINAPI NtUserUnregisterClass( UNICODE_STRING *name, HINSTANCE instance, ATOM WINAPI NtUserGetClassInfoEx( HINSTANCE instance, UNICODE_STRING *name, WNDCLASSEXW *wc, struct client_menu_name *menu_name, BOOL ansi ) { - static const WCHAR messageW[] = {'M','e','s','s','a','g','e'}; CLASS *class; ATOM atom;
/* create the desktop window to trigger builtin class registration */ - if (name->Buffer != (const WCHAR *)DESKTOP_CLASS_ATOM && - (IS_INTRESOURCE(name->Buffer) || name->Length != sizeof(messageW) || - wcsnicmp( name->Buffer, messageW, ARRAYSIZE(messageW) ))) - get_desktop_window(); + if (!is_desktop_class( name ) && !is_message_class( name )) get_desktop_window();
if (!(class = find_class( instance, name ))) return 0;
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 601cb784733..f5559c5ca4f 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -182,6 +182,8 @@ struct dce *get_class_dce( struct tagCLASS *class ); struct dce *set_class_dce( struct tagCLASS *class, struct dce *dce ); BOOL needs_ime_window( HWND hwnd ); extern atom_t wine_server_add_atom( void *req, UNICODE_STRING *str ); +extern BOOL is_desktop_class( UNICODE_STRING *name ); +extern BOOL is_message_class( UNICODE_STRING *name ); extern void register_builtin_classes(void); extern void register_desktop_class(void);
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 17625e9f52e..58bb27d75e4 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5413,7 +5413,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, { struct ntuser_thread_info *thread_info = NtUserGetThreadInfo();
- if (name->Buffer == (const WCHAR *)DESKTOP_CLASS_ATOM) + if (is_desktop_class( name )) { if (!thread_info->top_window) thread_info->top_window = HandleToUlong( full_parent ? full_parent : handle ); else assert( full_parent == UlongToHandle( thread_info->top_window )); @@ -5542,7 +5542,10 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, RECT surface_rect; WND *win;
- static const WCHAR messageW[] = {'M','e','s','s','a','g','e'}; + TRACE( "ex_style %#x, class_name %s, version %s, window_name %s, style %#x, x %u, y %u, cx %u, cy %u, " + "parent %p, menu %p, class_instance %p, params %p, flags %#x, instance %p, unk %u, ansi %u\n", + ex_style, debugstr_us(class_name), debugstr_us(version), debugstr_us(window_name), style, x, y, cx, cy, + parent, menu, class_instance, params, flags, instance, unk, ansi );
cs.lpCreateParams = params; cs.hInstance = instance ? instance : class_instance; @@ -5586,9 +5589,7 @@ HWND WINAPI NtUserCreateWindowEx( DWORD ex_style, UNICODE_STRING *class_name, }
/* are we creating the desktop or HWND_MESSAGE parent itself? */ - if (class_name->Buffer != (LPCWSTR)DESKTOP_CLASS_ATOM && - (class_name->Length != sizeof(messageW) || - wcsnicmp( class_name->Buffer, messageW, ARRAYSIZE(messageW) ))) + if (!is_desktop_class( class_name ) && !is_message_class( class_name )) { if (get_process_layout() & LAYOUT_RTL) cs.dwExStyle |= WS_EX_LAYOUTRTL; parent = get_desktop_window(); diff --git a/server/class.c b/server/class.c index ab89b4dd4d7..c98c171e035 100644 --- a/server/class.c +++ b/server/class.c @@ -134,7 +134,7 @@ int is_desktop_class( struct window_class *class ) return (class->atom == DESKTOP_ATOM && !class->local); }
-int is_hwnd_message_class( struct window_class *class ) +int is_message_class( struct window_class *class ) { static const WCHAR messageW[] = {'M','e','s','s','a','g','e'}; static const struct unicode_str name = { messageW, sizeof(messageW) }; diff --git a/server/user.h b/server/user.h index ee0042b8755..0ebda06b49b 100644 --- a/server/user.h +++ b/server/user.h @@ -192,7 +192,7 @@ extern struct window_class *grab_class( struct process *process, atom_t atom, mod_handle_t instance, int *extra_bytes ); extern void release_class( struct window_class *class ); extern int is_desktop_class( struct window_class *class ); -extern int is_hwnd_message_class( struct window_class *class ); +extern int is_message_class( struct window_class *class ); extern int get_class_style( struct window_class *class ); extern atom_t get_class_atom( struct window_class *class ); extern client_ptr_t get_class_client_ptr( struct window_class *class ); diff --git a/server/window.c b/server/window.c index 58b510c2eb0..e237d40a153 100644 --- a/server/window.c +++ b/server/window.c @@ -631,7 +631,7 @@ static struct window *create_window( struct window *parent, struct window *owner { if (is_desktop_class( class )) parent = desktop->top_window; /* use existing desktop if any */ - else if (is_hwnd_message_class( class )) + else if (is_message_class( class )) /* use desktop window if message window is already created */ parent = desktop->msg_window ? desktop->top_window : NULL; else if (!(parent = desktop->top_window)) /* must already have a desktop then */