From b650372b86cbacc7441425c2e0673d296ab89e42 Mon Sep 17 00:00:00 2001
From: Alexandre Julliard <julliard@winehq.org>
Date: Sat, 19 Apr 2003 21:27:19 +0000
Subject: [PATCH] Don't bother sending WM_NCCREATE to the desktop window, this
 doesn't work anyway (spotted by Uwe Bonnes).

---
 controls/desktop.c    | 18 +++---------------
 dlls/ttydrv/wnd.c     | 43 ++++++++++++++++++++++---------------------
 dlls/x11drv/desktop.c |  7 +++++++
 dlls/x11drv/window.c  |  5 ++---
 4 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/controls/desktop.c b/controls/desktop.c
index 689a46fde80..9dd5423ad0e 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -116,18 +116,8 @@ static HBITMAP DESKTOP_LoadBitmap( HDC hdc, const char *filename )
  */
 static LRESULT WINAPI DesktopWndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
 {
-    LRESULT retvalue = 0;
-
-    if (message == WM_NCCREATE)
-    {
-        hbrushPattern = 0;
-        hbitmapWallPaper = 0;
-        SetDeskPattern();
-        SetDeskWallPaper( (LPSTR)-1 );
-        retvalue = 1;
-    }
-    /* all other messages are ignored */
-    return retvalue;
+    /* all messages are ignored */
+    return 0;
 }
 
 /***********************************************************************
@@ -192,9 +182,7 @@ BOOL WINAPI PaintDesktop(HDC hdc)
  */
 BOOL16 WINAPI SetDeskPattern(void)
 {
-    char buffer[100];
-    GetProfileStringA( "desktop", "Pattern", "(None)", buffer, 100 );
-    return DESKTOP_SetPattern( buffer );
+    return SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE );
 }
 
 
diff --git a/dlls/ttydrv/wnd.c b/dlls/ttydrv/wnd.c
index b62f0d4d454..e94098bc30d 100644
--- a/dlls/ttydrv/wnd.c
+++ b/dlls/ttydrv/wnd.c
@@ -44,42 +44,43 @@ BOOL TTYDRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
     BOOL ret;
     HWND hwndLinkAfter;
     CBT_CREATEWNDA cbtc;
-
-#ifdef WINE_CURSES
     WND *wndPtr = WIN_GetPtr( hwnd );
-    WINDOW *window;
-    INT cellWidth=8, cellHeight=8; /* FIXME: Hardcoded */
 
     TRACE("(%p)\n", hwnd);
 
+    if (!wndPtr->parent)  /* desktop window */
+    {
+        wndPtr->pDriverData = root_window;
+        WIN_ReleasePtr( wndPtr );
+        return TRUE;
+    }
+
+#ifdef WINE_CURSES
     /* Only create top-level windows */
     if (!(wndPtr->dwStyle & WS_CHILD))
     {
-        if (!wndPtr->parent)  /* desktop */
-            window = root_window;
-        else
-        {
-            int x = wndPtr->rectWindow.left;
-            int y = wndPtr->rectWindow.top;
-            int cx = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
-            int cy = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
-
-            window = subwin( root_window, cy/cellHeight, cx/cellWidth,
-                             y/cellHeight, x/cellWidth);
-            werase(window);
-            wrefresh(window);
-        }
+        WINDOW *window;
+        const INT cellWidth=8, cellHeight=8; /* FIXME: Hardcoded */
+
+        int x = wndPtr->rectWindow.left;
+        int y = wndPtr->rectWindow.top;
+        int cx = wndPtr->rectWindow.right - wndPtr->rectWindow.left;
+        int cy = wndPtr->rectWindow.bottom - wndPtr->rectWindow.top;
+
+        window = subwin( root_window, cy/cellHeight, cx/cellWidth,
+                         y/cellHeight, x/cellWidth);
+        werase(window);
+        wrefresh(window);
         wndPtr->pDriverData = window;
     }
-    WIN_ReleasePtr( wndPtr );
 #else /* defined(WINE_CURSES) */
     FIXME("(%x): stub\n", hwnd);
 #endif /* defined(WINE_CURSES) */
+    WIN_ReleasePtr( wndPtr );
 
     /* Call the WH_CBT hook */
 
-    hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
- ? HWND_BOTTOM : HWND_TOP;
+    hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) ? HWND_BOTTOM : HWND_TOP;
 
     cbtc.lpcs = cs;
     cbtc.hwndInsertAfter = hwndLinkAfter;
diff --git a/dlls/x11drv/desktop.c b/dlls/x11drv/desktop.c
index ce97fd595bd..3dfa4878ad6 100644
--- a/dlls/x11drv/desktop.c
+++ b/dlls/x11drv/desktop.c
@@ -36,6 +36,11 @@ static LRESULT WINAPI desktop_winproc( HWND hwnd, UINT message, WPARAM wParam, L
 {
     switch(message)
     {
+    case WM_NCCREATE:
+        SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE );
+        SetDeskWallPaper( (LPSTR)-1 );
+        return TRUE;
+
     case WM_ERASEBKGND:
         PaintDesktop( (HDC)wParam );
         ValidateRect( hwnd, NULL );
@@ -79,6 +84,8 @@ static DWORD CALLBACK desktop_thread( LPVOID driver_data )
     XMapWindow( display, root_window );
     wine_tsx11_unlock();
 
+    SendMessageW( hwnd, WM_NCCREATE, 0, 0 /* should be CREATESTRUCT */ );
+
     while (GetMessageW( &msg, hwnd, 0, 0 )) DispatchMessageW( &msg );
     return 0;
 }
diff --git a/dlls/x11drv/window.c b/dlls/x11drv/window.c
index 30613ab91ce..302f8a76f77 100644
--- a/dlls/x11drv/window.c
+++ b/dlls/x11drv/window.c
@@ -612,7 +612,7 @@ void X11DRV_register_window( Display *display, HWND hwnd, struct x11drv_win_data
 /**********************************************************************
  *		create_desktop
  */
-static void create_desktop( Display *display, WND *wndPtr, CREATESTRUCTA *cs )
+static void create_desktop( Display *display, WND *wndPtr )
 {
     X11DRV_WND_DATA *data = wndPtr->pDriverData;
 
@@ -640,7 +640,6 @@ static void create_desktop( Display *display, WND *wndPtr, CREATESTRUCTA *cs )
     SetPropA( wndPtr->hwndSelf, client_window_atom, (HANDLE)root_window );
     SetPropA( wndPtr->hwndSelf, "__wine_x11_visual_id", (HANDLE)XVisualIDFromVisual(visual) );
 
-    SendMessageW( wndPtr->hwndSelf, WM_NCCREATE, 0, (LPARAM)cs );
     if (root_window != DefaultRootWindow(display)) X11DRV_create_desktop_thread();
 }
 
@@ -899,7 +898,7 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
 
     if (!wndPtr->parent)
     {
-        create_desktop( display, wndPtr, cs );
+        create_desktop( display, wndPtr );
         WIN_ReleasePtr( wndPtr );
         return TRUE;
     }
-- 
GitLab