From: Gabriel Ivăncescu gabrielopcode@gmail.com
It can be substantially faster in some cases. Notepad++ (with several plugins) start up goes down from around ~1.03 sec to ~0.61 sec on my machine (with wineprefix active).
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/win32u/ntuser_private.h | 1 + dlls/win32u/winstation.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 3b6cab5bdc9..0cffa8b2208 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -127,6 +127,7 @@ struct user_thread_info UINT spy_indent; /* Current spy indent */ BOOL clipping_cursor; /* thread is currently clipping */ DWORD clipping_reset; /* time when clipping was last reset */ + signed char cached_is_virtual_desktop; /* ternary value: zero = unknown, negative = FALSE, positive = TRUE */ };
C_ASSERT( sizeof(struct user_thread_info) <= sizeof(((TEB *)0)->Win32ClientInfo) ); diff --git a/dlls/win32u/winstation.c b/dlls/win32u/winstation.c index 9df27517a43..70179d3c8f6 100644 --- a/dlls/win32u/winstation.c +++ b/dlls/win32u/winstation.c @@ -42,12 +42,21 @@ WINE_DECLARE_DEBUG_CHANNEL(win);
BOOL is_virtual_desktop(void) { - HANDLE desktop = NtUserGetThreadDesktop( GetCurrentThreadId() ); + struct user_thread_info *thread_info = get_user_thread_info(); USEROBJECTFLAGS flags = {0}; + HANDLE desktop; DWORD len; + BOOL ret; + + if (thread_info->cached_is_virtual_desktop) + return thread_info->cached_is_virtual_desktop > 0;
+ desktop = NtUserGetThreadDesktop( GetCurrentThreadId() ); if (!NtUserGetObjectInformation( desktop, UOI_FLAGS, &flags, sizeof(flags), &len )) return FALSE; - return !!(flags.dwFlags & DF_WINE_VIRTUAL_DESKTOP); + ret = !!(flags.dwFlags & DF_WINE_VIRTUAL_DESKTOP); + + thread_info->cached_is_virtual_desktop = ret ? 1 : -1; + return ret; }
/*********************************************************************** @@ -261,6 +270,7 @@ BOOL WINAPI NtUserSetThreadDesktop( HDESK handle ) { struct user_thread_info *thread_info = get_user_thread_info(); struct user_key_state_info *key_state_info = thread_info->key_state; + thread_info->cached_is_virtual_desktop = 0; thread_info->client_info.top_window = 0; thread_info->client_info.msg_window = 0; if (key_state_info) key_state_info->time = 0;