diff --git a/reactos/subsys/win32k/ntuser/desktop.c b/reactos/subsys/win32k/ntuser/desktop.c index 9c89b6976b8..85dc431b9ff 100644 --- a/reactos/subsys/win32k/ntuser/desktop.c +++ b/reactos/subsys/win32k/ntuser/desktop.c @@ -1227,35 +1227,118 @@ NtUserPaintDesktop(HDC hDC) sz.cx = DeskWin->WindowRect.right - DeskWin->WindowRect.left; sz.cy = DeskWin->WindowRect.bottom - DeskWin->WindowRect.top; - - - x = (sz.cx / 2) - (WinSta->cxWallpaper / 2); - y = (sz.cy / 2) - (WinSta->cyWallpaper / 2); - + + if(WinSta->WallpaperMode == wmStretch || + WinSta->WallpaperMode == wmTile) + { + x = 0; + y = 0; + } + else + { + x = (sz.cx / 2) - (WinSta->cxWallpaper / 2); + y = (sz.cy / 2) - (WinSta->cyWallpaper / 2); + } + hWallpaperDC = NtGdiCreateCompatibleDC(hDC); if(hWallpaperDC != NULL) { HBITMAP hOldBitmap; - + if(x > 0 || y > 0) { - /* FIXME - clip out the bitmap */ - PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush); - NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); - NtGdiSelectObject(hDC, PreviousBrush); + /* FIXME - clip out the bitmap + can be replaced with "NtGdiPatBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, PATCOPY | DSTINVERT);" + once we support DSTINVERT */ + PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush); + NtGdiPatBlt(hDC, Rect.left, Rect.top, Rect.right, Rect.bottom, PATCOPY); + NtGdiSelectObject(hDC, PreviousBrush); + } + + //Do not fill the background after it is painted no matter the size of the picture + doPatBlt = FALSE; + + hOldBitmap = NtGdiSelectObject(hWallpaperDC, WinSta->hbmWallpaper); + + if(WinSta->WallpaperMode == wmStretch) + { +#if 0 //Broken Stretch Code + /* Fix me, stretch the bitmap to fit the screen. I'm not smart enough to do this :( */ + BITMAPINFO bmINFO; + LPVOID pBits; + bmINFO.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + /* Get bits */ + NtGdiGetDIBits(hDC, + WinSta->hbmWallpaper, + 0, + WinSta->cyWallpaper, + NULL, // what goes here? + &bmINFO, + DIB_RGB_COLORS); + + bmINFO.bmiHeader.biCompression = BI_RGB; + + pBits = ExAllocatePool(PagedPool,bmINFO.bmiHeader.biSizeImage); + + if(pBits == NULL) + { + doPatBlt = TRUE; + } + else + { + + NtGdiGetDIBits(hDC, + WinSta->hbmWallpaper, + 0, + WinSta->cyWallpaper, + (LPVOID)pBits, // what goes here? + &bmINFO, + DIB_RGB_COLORS); + DPRINT1("Before Draw\n"); + + /* Stretch it to fit the screen */ + NtGdiStretchDIBits(hDC, + 0, + 0, + Rect.right, + Rect.bottom, + 0, + 0, + WinSta->cxWallpaper, + WinSta->cyWallpaper, + (LPVOID)pBits, // get this from NtGdiGetDiBits? + &bmINFO, // get this from NtGdiGetDiBits? + DIB_RGB_COLORS, + SRCCOPY); + ExFreePool(pBits); + } +#else + /* Draw nothing */ + doPatBlt = TRUE; +#endif //Broken Stretch Code + } + else if(WinSta->WallpaperMode == wmTile) + { + + for(y = 0; y < Rect.bottom; y += WinSta->cyWallpaper) + { + for(x = 0; x < Rect.right; x += WinSta->cxWallpaper) + { + NtGdiBitBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, hWallpaperDC, 0, 0, SRCCOPY); + } + } } else - doPatBlt = FALSE; - - hOldBitmap = NtGdiSelectObject(hWallpaperDC, WinSta->hbmWallpaper); - NtGdiBitBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, hWallpaperDC, 0, 0, SRCCOPY); - NtGdiSelectObject(hWallpaperDC, hOldBitmap); - + { + NtGdiBitBlt(hDC, x, y, WinSta->cxWallpaper, WinSta->cyWallpaper, hWallpaperDC, 0, 0, SRCCOPY); + } + NtGdiSelectObject(hWallpaperDC, hOldBitmap); NtGdiDeleteDC(hWallpaperDC); } } } + /* Back ground is set to none, clear the screen */ if (doPatBlt) { PreviousBrush = NtGdiSelectObject(hDC, DesktopBrush);