From: Paul Gofman pgofman@codeweavers.com
And use those to track first use instead of first_window parameter. --- dlls/user32/tests/win.c | 14 +++++++++----- dlls/win32u/class.c | 1 + dlls/win32u/win32u_private.h | 1 + dlls/win32u/window.c | 32 ++++++++++++++++++++++++++------ 4 files changed, 37 insertions(+), 11 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 6073e087cb4..693a95f3d72 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -31,6 +31,7 @@ #include "wingdi.h" #include "winuser.h" #include "winreg.h" +#include "winternl.h"
#include "wine/test.h"
@@ -13693,18 +13694,21 @@ static void test_startupinfo_showwindow_proc( int test_id ) { WS_OVERLAPPED, TRUE }, /* owned window */ { WS_POPUP | WS_CAPTION, TRUE }, /* owned window */ }; + + RTL_USER_PROCESS_PARAMETERS *up = NtCurrentTeb()->Peb->ProcessParameters; BOOL bval, expected; - STARTUPINFOW sa; unsigned int i; DWORD style; HWND parent, hwnd;
- GetStartupInfoW( &sa ); + winetest_push_context( "test %d", test_id );
- winetest_push_context( "show %u, test %d", sa.wShowWindow, test_id ); + ok( up->dwFlags & STARTF_USESHOWWINDOW, "got %#lx.\n", up->dwFlags ); + ok( up->wShowWindow == SW_HIDE, "got %lu.\n.", up->wShowWindow );
- ok( sa.dwFlags & STARTF_USESHOWWINDOW, "got %#lx.\n", sa.dwFlags ); - ok( sa.wShowWindow == SW_HIDE, "got %u.\n.", sa.wShowWindow ); + /* Startup window parameters are fetched early and current values don't affect behaviour. */ + up->dwFlags = 0; + up->wShowWindow = SW_SHOW;
/* First test windows which are not affected by startup info. ShowWindow() called for those doesn't count as * consuming startup info, it is still used with the next applicable window. diff --git a/dlls/win32u/class.c b/dlls/win32u/class.c index 9cc5b6402aa..dc1a42b381d 100644 --- a/dlls/win32u/class.c +++ b/dlls/win32u/class.c @@ -249,6 +249,7 @@ static void init_user(void) { NtQuerySystemInformation( SystemBasicInformation, &system_info, sizeof(system_info), NULL );
+ init_startup_info(); shared_session_init(); gdi_init(); sysparams_init(); diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index ee76854c7e4..983e097187b 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -301,6 +301,7 @@ extern HWND get_progman_window(void); extern HWND get_taskman_window(void); extern BOOL is_client_surface_window( struct client_surface *surface, HWND hwnd ); extern HICON get_window_icon_info( HWND hwnd, UINT type, HICON icon, ICONINFO *ret ); +extern void init_startup_info(void);
/* to release pointers retrieved by win_get_ptr */ static inline void release_win_ptr( struct tagWND *ptr ) diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index e053adf0112..9d2a8efe381 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -53,6 +53,29 @@ static void *client_objects[MAX_USER_HANDLES]; #define PLACE_MAX 0x0002 #define PLACE_RECT 0x0004
+static volatile unsigned int startup_info_flags; +static unsigned int startup_show_window; + +static unsigned int set_startup_info_flags( unsigned int mask, unsigned int flags ) +{ + unsigned int prev, new; + + do + { + prev = startup_info_flags; + new = (prev & ~mask) | flags; + } while (InterlockedCompareExchange( (LONG volatile *)&startup_info_flags, new, prev ) != prev ); + return prev; +} + +void init_startup_info(void) +{ + RTL_USER_PROCESS_PARAMETERS *p = NtCurrentTeb()->Peb->ProcessParameters; + + startup_show_window = p->wShowWindow; + set_startup_info_flags( ~0u, p->dwFlags ); +} + /*********************************************************************** * alloc_user_handle */ @@ -4724,7 +4747,6 @@ void update_window_state( HWND hwnd ) */ static BOOL show_window( HWND hwnd, INT cmd ) { - static volatile LONG first_window = 1; WND *win; HWND parent; DWORD style = get_window_long( hwnd, GWL_STYLE ), new_style; @@ -4740,13 +4762,11 @@ static BOOL show_window( HWND hwnd, INT cmd ) if ((!(style & (WS_POPUP | WS_CHILD)) || ((style & (WS_POPUP | WS_CHILD | WS_CAPTION)) == (WS_POPUP | WS_CAPTION))) && !get_window_relative( hwnd, GW_OWNER ) - && InterlockedExchange( &first_window, 0 )) + && set_startup_info_flags( STARTF_USESHOWWINDOW, 0 ) & STARTF_USESHOWWINDOW) { - RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters; - - if (params->dwFlags & STARTF_USESHOWWINDOW && (cmd == SW_SHOW || cmd == SW_SHOWNORMAL || cmd == SW_SHOWDEFAULT)) + if (cmd == SW_SHOW || cmd == SW_SHOWNORMAL || cmd == SW_SHOWDEFAULT) { - cmd = params->wShowWindow; + cmd = startup_show_window; TRACE( "hwnd=%p, using cmd %d from startup info.\n", hwnd, cmd ); } }