diff --git a/dlls/user32/desktop.c b/dlls/user32/desktop.c index bc9125235b9..d22e732fd5b 100644 --- a/dlls/user32/desktop.c +++ b/dlls/user32/desktop.c @@ -117,6 +117,8 @@ LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lP ATOM atom; WCHAR buffer[37]; + if (GetAncestor( hwnd, GA_PARENT )) return FALSE; /* refuse to create non-desktop window */ + sprintfW( buffer, guid_formatW, guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] ); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index 275b93ca7bf..e29153a2758 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -2086,6 +2086,9 @@ HWND WINAPI GetDesktopWindow(void) SERVER_END_REQ; } + /* wait for the desktop process to be ready */ + SendMessageW( thread_info->top_window, WM_NULL, 0, 0 ); + if (!thread_info->top_window || !USER_Driver->pCreateDesktopWindow( thread_info->top_window )) ERR( "failed to create desktop window\n" ); diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c index db6a355b4f4..474e93e5a17 100644 --- a/programs/explorer/desktop.c +++ b/programs/explorer/desktop.c @@ -799,7 +799,7 @@ void manage_desktop( WCHAR *arg ) HDESK desktop = 0; GUID guid; MSG msg; - HWND hwnd, msg_hwnd; + HWND hwnd; HMODULE graphics_driver; unsigned int width, height; WCHAR *cmdline = NULL, *driver = NULL; @@ -856,12 +856,12 @@ void manage_desktop( WCHAR *arg ) hwnd = CreateWindowExW( 0, DESKTOP_CLASS_ATOM, NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, 0, &guid ); - /* create the HWND_MESSAGE parent */ - msg_hwnd = CreateWindowExW( 0, messageW, NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, - 0, 0, 100, 100, 0, 0, 0, NULL ); - - if (hwnd == GetDesktopWindow()) + if (hwnd) { + /* create the HWND_MESSAGE parent */ + CreateWindowExW( 0, messageW, NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, + 0, 0, 100, 100, 0, 0, 0, NULL ); + using_root = !desktop || !create_desktop( graphics_driver, name, width, height ); SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_wnd_proc ); SendMessageW( hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW( 0, MAKEINTRESOURCEW(OIC_WINLOGO))); @@ -891,13 +891,6 @@ void manage_desktop( WCHAR *arg ) } } } - else - { - DestroyWindow( hwnd ); /* someone beat us to it */ - hwnd = 0; - } - - if (GetAncestor( msg_hwnd, GA_PARENT )) DestroyWindow( msg_hwnd ); /* someone beat us to it */ /* if we have a command line, execute it */ if (cmdline)