From: Tim Clem tclem@codeweavers.com
--- dlls/user32/tests/win.c | 1 - programs/explorer/desktop.c | 40 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index b29b1472283..7d16f0a6dc1 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -1816,7 +1816,6 @@ static void test_shell_window(void) HANDLE hthread;
orig_shell_window = GetShellWindow(); - todo_wine ok(orig_shell_window != NULL, "default desktop doesn't have a shell window\n");
hdesk = CreateDesktopA("winetest", NULL, NULL, 0, GENERIC_ALL, NULL); diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index 40077f6b4a9..ddec0b6fc38 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -1149,6 +1149,42 @@ static inline BOOL is_whitespace(WCHAR c) return c == ' ' || c == '\t'; }
+/* Set the shell window if appropriate for the current desktop. We should set + the shell window on the "Default" desktop on a visible window station, but + not for other desktops. */ +static void set_shell_window( HWND hwnd ) +{ + HWINSTA winsta; + USEROBJECTFLAGS flags; + HDESK desk; + WCHAR desk_name[MAX_PATH]; + HMODULE user32; + BOOL (WINAPI *pSetShellWindow)( HWND ); + + if (!(winsta = GetProcessWindowStation()) || + !GetUserObjectInformationW( winsta, UOI_FLAGS, &flags, sizeof(flags), NULL ) || + !(flags.dwFlags & WSF_VISIBLE)) + { + return; + } + + if (!(desk = GetThreadDesktop( GetCurrentThreadId() )) || + !GetUserObjectInformationW( desk, UOI_NAME, desk_name, ARRAY_SIZE( desk_name ), NULL ) || + wcscmp( desk_name, L"Default" )) + { + return; + } + + if ((user32 = LoadLibraryW( L"user32.dll" )) && + (pSetShellWindow = (void *)GetProcAddress( user32, "SetShellWindow" )) && + pSetShellWindow( hwnd )) + { + TRACE( "set shell window to %p\n", hwnd ); + } + else + WARN( "failed to set shell window\n" ); +} + /* main desktop management function */ void manage_desktop( WCHAR *arg ) { @@ -1269,6 +1305,10 @@ void manage_desktop( WCHAR *arg ) desktopshellbrowserwindow_init(); shellwindows_init();
+ /* Ideally we would set the window of an IShellView here, but we never + actually create one, so the desktop window itself will have to do. */ + set_shell_window( hwnd ); + /* run the desktop message loop */ if (hwnd) {