Jacek Caban : win32u: Introduce get_desktop_window.
Alexandre Julliard
julliard at winehq.org
Wed Mar 9 16:08:44 CST 2022
Module: wine
Branch: master
Commit: 5df07a48a6fa8bf64246839050ca0782a813d17d
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5df07a48a6fa8bf64246839050ca0782a813d17d
Author: Jacek Caban <jacek at codeweavers.com>
Date: Wed Mar 9 15:20:01 2022 +0100
win32u: Introduce get_desktop_window.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/win32u/class.c | 8 ++++----
dlls/win32u/driver.c | 3 +--
dlls/win32u/win32u_private.h | 1 +
dlls/win32u/window.c | 14 ++++++--------
dlls/win32u/winstation.c | 9 +++++++++
5 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c
index 2652b908934..f0c372df12d 100644
--- a/dlls/win32u/class.c
+++ b/dlls/win32u/class.c
@@ -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;
diff --git a/dlls/win32u/driver.c b/dlls/win32u/driver.c
index 8e6263db60c..90b0ca75658 100644
--- a/dlls/win32u/driver.c
+++ b/dlls/win32u/driver.c
@@ -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" );
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index d5d77897749..f987f0099da 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -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;
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c
index 1de2d5bc68c..7ad75642f13 100644
--- a/dlls/win32u/window.c
+++ b/dlls/win32u/window.c
@@ -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:
diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c
index 02908fccd5a..49420066b15 100644
--- a/dlls/win32u/winstation.c
+++ b/dlls/win32u/winstation.c
@@ -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];
More information about the wine-cvs
mailing list