win32u: Introduce get_desktop_window.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2022-03-09 15:20:01 +01:00 committed by Alexandre Julliard
parent 516249001f
commit 5df07a48a6
5 changed files with 21 additions and 14 deletions

View File

@ -285,7 +285,7 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *nam
BOOL ret;
/* create the desktop window to trigger builtin class registration */
if (!is_builtin && user_callbacks) user_callbacks->pGetDesktopWindow();
if (!is_builtin) get_desktop_window();
if (wc->cbSize != sizeof(*wc) || wc->cbClsExtra < 0 || wc->cbWndExtra < 0 ||
(!is_builtin && wc->hInstance == user32_module)) /* we can't register a class for user32 */
@ -383,8 +383,8 @@ BOOL WINAPI NtUserUnregisterClass( UNICODE_STRING *name, HINSTANCE instance,
{
CLASS *class = NULL;
if (user_callbacks) /* create the desktop window to trigger builtin class registration */
user_callbacks->pGetDesktopWindow();
/* create the desktop window to trigger builtin class registration */
get_desktop_window();
SERVER_START_REQ( destroy_class )
{
@ -423,7 +423,7 @@ ATOM WINAPI NtUserGetClassInfoEx( HINSTANCE instance, UNICODE_STRING *name, WNDC
if (name->Buffer != (const WCHAR *)DESKTOP_CLASS_ATOM &&
(IS_INTRESOURCE(name->Buffer) || name->Length != sizeof(messageW) ||
wcsnicmp( name->Buffer, messageW, ARRAYSIZE(messageW) )))
user_callbacks->pGetDesktopWindow();
get_desktop_window();
if (!(class = find_class( instance, name ))) return 0;

View File

@ -64,8 +64,7 @@ const struct gdi_dc_funcs *get_display_driver(void)
{
if (user_driver == &lazy_load_driver)
{
if (!user_callbacks || !user_callbacks->pGetDesktopWindow() ||
user_driver == &lazy_load_driver)
if (!get_desktop_window() || user_driver == &lazy_load_driver)
{
static struct user_driver_funcs empty_funcs;
WARN( "failed to load the display driver, falling back to null driver\n" );

View File

@ -298,6 +298,7 @@ extern void user_check_not_lock(void) DECLSPEC_HIDDEN;
/* window.c */
struct tagWND;
extern HWND get_desktop_window(void) DECLSPEC_HIDDEN;
extern HWND is_current_thread_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern void flush_window_surfaces( BOOL idle ) DECLSPEC_HIDDEN;
extern DWORD get_window_long( HWND hwnd, INT offset ) DECLSPEC_HIDDEN;

View File

@ -163,8 +163,7 @@ static HWND get_hwnd_message_parent(void)
{
struct user_thread_info *thread_info = get_user_thread_info();
if (!thread_info->msg_window && user_callbacks)
user_callbacks->pGetDesktopWindow(); /* trigger creation */
if (!thread_info->msg_window) get_desktop_window(); /* trigger creation */
return thread_info->msg_window;
}
@ -186,8 +185,7 @@ static HWND get_full_window_handle( HWND hwnd )
if (win == WND_DESKTOP)
{
if (user_callbacks && LOWORD(hwnd) == LOWORD(user_callbacks->pGetDesktopWindow()))
return user_callbacks->pGetDesktopWindow();
if (LOWORD(hwnd) == LOWORD(get_desktop_window())) return get_desktop_window();
else return get_hwnd_message_parent();
}
@ -619,7 +617,7 @@ static BOOL is_window_visible( HWND hwnd )
{
for (i = 0; list[i+1]; i++)
if (!(get_window_long( list[i], GWL_STYLE ) & WS_VISIBLE)) break;
retval = !list[i+1] && (list[i] == user_callbacks->pGetDesktopWindow()); /* top message window isn't visible */
retval = !list[i+1] && (list[i] == get_desktop_window()); /* top message window isn't visible */
}
free( list );
return retval;
@ -648,7 +646,7 @@ static BOOL is_window_drawable( HWND hwnd, BOOL icon )
for (i = 0; list[i+1]; i++)
if ((get_window_long( list[i], GWL_STYLE ) & (WS_VISIBLE|WS_MINIMIZE)) != WS_VISIBLE)
break;
retval = !list[i+1] && (list[i] == user_callbacks->pGetDesktopWindow()); /* top message window isn't visible */
retval = !list[i+1] && (list[i] == get_desktop_window()); /* top message window isn't visible */
}
free( list );
return retval;
@ -689,7 +687,7 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans
if (offset == GWLP_HWNDPARENT)
{
HWND parent = NtUserGetAncestor( hwnd, GA_PARENT );
if (user_callbacks && parent == user_callbacks->pGetDesktopWindow())
if (parent == get_desktop_window())
parent = get_window_relative( hwnd, GW_OWNER );
return (ULONG_PTR)parent;
}
@ -706,7 +704,7 @@ static LONG_PTR get_window_long_size( HWND hwnd, INT offset, UINT size, BOOL ans
{
case GWL_STYLE:
retval = WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN; /* message parent is not visible */
if (user_callbacks && get_full_window_handle( hwnd ) == user_callbacks->pGetDesktopWindow())
if (get_full_window_handle( hwnd ) == get_desktop_window())
retval |= WS_VISIBLE;
return retval;
case GWL_EXSTYLE:

View File

@ -388,6 +388,15 @@ BOOL WINAPI NtUserSetObjectInformation( HANDLE handle, INT index, void *info, DW
return ret;
}
HWND get_desktop_window(void)
{
struct user_thread_info *thread_info = get_user_thread_info();
if (thread_info->top_window) return thread_info->top_window;
if (!user_callbacks) return 0;
return user_callbacks->pGetDesktopWindow();
}
static HANDLE get_winstations_dir_handle(void)
{
char bufferA[64];