From: Rémi Bernon rbernon@codeweavers.com
--- dlls/win32u/class.c | 22 +++++++++++++++++----- dlls/win32u/ntuser_private.h | 2 ++ dlls/win32u/window.c | 8 ++------ server/class.c | 2 +- server/user.h | 2 +- server/window.c | 2 +- 6 files changed, 24 insertions(+), 14 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index c62e920b77e..a34d14e6f8d 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -302,6 +302,22 @@ ATOM get_int_atom_value( UNICODE_STRING *name ) return ret; }
+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) ); +} + /*********************************************************************** * get_class_ptr */ @@ -537,15 +553,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 33b5cdc3b27..d2ad0660c3c 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -182,6 +182,8 @@ void get_winproc_params( struct win_proc_params *params, BOOL fixup_ansi_dst ); 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 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 08db9cab0bd..13ec161bdd3 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -5280,7 +5280,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 )); @@ -5410,8 +5410,6 @@ 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'}; - cs.lpCreateParams = params; cs.hInstance = instance ? instance : class_instance; cs.hMenu = menu; @@ -5454,9 +5452,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 3231f366b26..dc94c83f804 100644 --- a/server/class.c +++ b/server/class.c @@ -133,7 +133,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 e2e9d5cc485..1c82d337676 100644 --- a/server/window.c +++ b/server/window.c @@ -627,7 +627,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 */