Release 940714

Thu Jul 14 17:50:45 1994  Bob Amstadt  (bob@pooh)

	* [Configure]
	Autodetects Linux version (if running Linux).

	* [loader/signal.c]
	New signals for Linux.

	* [loader/ldtlib.c]
	New structure field in sys call.

Sun Jul 10 19:31:34 1994  Olaf Flebbe  (olaf@dragon)

        * [load/resource.c] 
          fixed Memory (Resource) Leak.

        * [load/main.c] 
          fixed a printf.

Tue Jul 12 18:50:34 1994  Alexandre Julliard  (julliard@lamisun.epfl.ch)

	* [controls/desktop.c]
	Implemented desktop wallpaper (only 16 colors for now).

	* [controls/menu.c] [windows/nonclient.c]
	Preliminary work to allow multi-line menus.

	* [misc/main.c]
	No backing store on desktop window (not useful).

	* [objects/text.c]
	A few fixes to DrawText() to make underlines under mnemonic
	letters to look better.

	* [windows/graphics.c]
	More fixes to GRAPH_DrawArc(), and some fixes to Polygon().
	Implemented PolyPolygon() (partially working).

	* [windows/winpos.c]
	New function WINPOS_SendNCCalcSize().
	Cleaned up SetWindowPos() and added preliminary support for
	multi-line menus.

Mon Jul 11 19:15:51 1994  Miguel de Icaza  (miguel@sphinx)

	* [controls/edit.c]
	Changes to work as a library.

	* [if1632/callback.c] 
	Ifdefed module.

	* [if1632/relay.c]
	Changes to allow linking with WineLib.

	* [include/windows.h]
	Added macro WINELIB_UNIMP

	* [loader/library.c]
	When compiling WineLib, GetProcAddress is not implemented yet.

	* [loader/main.c]
	Added empty InitDLL when using WineLib.

	* [loader/ne_image.c]
	Some parts of the loader are needed for WineLib, ifdefed correctly

	* [misc/{audio.c,mcicda.c,mmaux.c,mmsystem.c]
	Disable compilation of module when compiling WineLib.

	* [toolkit/heap.c]
	Fixed small bug.  When passed an invalid handle WineLib would
	crash, now return NULL.

	* [toolkit/winmain.c]
	Call CreateNewTask in _WinMain.

Sun Jul 10 09:08:02 1994  David Metcalfe <david@prism.demon.co.uk>

	* [controls/edit.c] [controls/widget.c]
	More changes to improve compatibility with Windows' edit
	control.  Finished off tab stop support.

Mon Jul 11 21:05:02 MET DST 1994  Erik Bos <erik@hacktic.nl>

	* [if1632/relay.c]
	# of ordinals in shell.dll changed to 103.

	* [loader/signal.c]
	sti, cli will now be ignored.

	* [objects/brush.c]
	Added stub for GetSysColorBrush().
diff --git a/controls/desktop.c b/controls/desktop.c
index 183b2a2..e1f5d7f 100644
--- a/controls/desktop.c
+++ b/controls/desktop.c
@@ -6,10 +6,56 @@
 
 static char Copyright[] = "Copyright  Alexandre Julliard, 1994";
 
+#include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
 #include "win.h"
 #include "desktop.h"
+#include "prototypes.h"
+
+
+/***********************************************************************
+ *           DESKTOP_LoadBitmap
+ *
+ * Load a bitmap from a file. Used by SetDeskWallPaper().
+ */
+static HBITMAP DESKTOP_LoadBitmap( HDC hdc, char *filename )
+{
+    BITMAPFILEHEADER *fileHeader;
+    BITMAPINFO *bitmapInfo;
+    HBITMAP hbitmap;
+    char *unixFileName, *buffer;
+    int file;
+    long size;
+
+      /* Read all the file into memory */
+
+    if (!(unixFileName = GetUnixFileName( filename ))) return 0;
+    if ((file = open( unixFileName, O_RDONLY )) == -1) return 0;
+    size = lseek( file, 0, SEEK_END );
+    if (!(buffer = (char *)malloc( size )))
+    {
+	close( file );
+	return 0;
+    }
+    lseek( file, 0, SEEK_SET );
+    size = read( file, buffer, size );
+    close( file );
+    fileHeader = (BITMAPFILEHEADER *)buffer;
+    bitmapInfo = (BITMAPINFO *)(buffer + sizeof(BITMAPFILEHEADER));
+    
+      /* Check header content */
+    if ((fileHeader->bfType != 0x4d42) || (size < fileHeader->bfSize))
+    {
+	free( buffer );
+	return 0;
+    }
+    hbitmap = CreateDIBitmap( hdc, &bitmapInfo->bmiHeader, CBM_INIT,
+			      buffer + fileHeader->bfOffBits,
+			      bitmapInfo, DIB_RGB_COLORS );
+    free( buffer );
+    return hbitmap;
+}
 
 
 /***********************************************************************
@@ -20,12 +66,49 @@
 static LONG DESKTOP_DoEraseBkgnd( HWND hwnd, HDC hdc, DESKTOPINFO *infoPtr )
 {
     RECT rect;
-
-      /* Set colors in case pattern is a monochrome bitmap */
-    SetBkColor( hdc, RGB(0,0,0) );
-    SetTextColor( hdc, GetSysColor(COLOR_BACKGROUND) );
     GetClientRect( hwnd, &rect );    
-    FillRect( hdc, &rect, infoPtr->hbrushPattern );
+
+    /* Paint desktop pattern (only if wall paper does not cover everything) */
+
+    if (!infoPtr->hbitmapWallPaper || 
+	(!infoPtr->fTileWallPaper && (infoPtr->bitmapSize.cx < rect.right) &&
+	 (infoPtr->bitmapSize.cy < rect.bottom)))
+    {
+	  /* Set colors in case pattern is a monochrome bitmap */
+	SetBkColor( hdc, RGB(0,0,0) );
+	SetTextColor( hdc, GetSysColor(COLOR_BACKGROUND) );
+	FillRect( hdc, &rect, infoPtr->hbrushPattern );
+    }
+
+      /* Paint wall paper */
+
+    if (infoPtr->hbitmapWallPaper)
+    {
+	int x, y;
+	HDC hdcmem;
+
+	hdcmem = CreateCompatibleDC( hdc );
+	SelectObject( hdcmem, infoPtr->hbitmapWallPaper );
+	if (infoPtr->fTileWallPaper)
+	{
+	    for (y = 0; y < rect.bottom; y += infoPtr->bitmapSize.cy)
+		for (x = 0; x < rect.right; x += infoPtr->bitmapSize.cx)
+		    BitBlt( hdc, x, y,
+			    infoPtr->bitmapSize.cx, infoPtr->bitmapSize.cy,
+			    hdcmem, 0, 0, SRCCOPY );
+	}
+	else
+	{
+	    x = (rect.left + rect.right - infoPtr->bitmapSize.cx) / 2;
+	    y = (rect.top + rect.bottom - infoPtr->bitmapSize.cy) / 2;
+	    if (x < 0) x = 0;
+	    if (y < 0) y = 0;
+	    BitBlt( hdc, x, y, infoPtr->bitmapSize.cx, infoPtr->bitmapSize.cy,
+		    hdcmem, 0, 0, SRCCOPY );
+	}
+	DeleteDC( hdcmem );
+    }
+
     return 1;
 }
 
@@ -50,6 +133,7 @@
 	infoPtr->hbrushPattern = 0;
 	infoPtr->hbitmapWallPaper = 0;
 	SetDeskPattern();
+	SetDeskWallPaper( (LPSTR)-1 );
 	break;
 	
     case WM_ERASEBKGND:
@@ -77,6 +161,30 @@
  */
 BOOL SetDeskWallPaper( LPSTR filename )
 {
+    HBITMAP hbitmap;
+    HDC hdc;
+    char buffer[256];
+    WND *wndPtr = WIN_FindWndPtr( GetDesktopWindow() );
+    DESKTOPINFO *infoPtr = (DESKTOPINFO *)wndPtr->wExtra;
+
+    if (filename == (LPSTR)-1)
+    {
+	GetProfileString( "desktop", "WallPaper", "(None)", buffer, 256 );
+	filename = buffer;
+    }
+    hdc = GetDC( 0 );
+    hbitmap = DESKTOP_LoadBitmap( hdc, filename );
+    ReleaseDC( 0, hdc );
+    if (infoPtr->hbitmapWallPaper) DeleteObject( infoPtr->hbitmapWallPaper );
+    infoPtr->hbitmapWallPaper = hbitmap;
+    infoPtr->fTileWallPaper = GetProfileInt( "desktop", "TileWallPaper", 0 );
+    if (hbitmap)
+    {
+	BITMAP bmp;
+	GetObject( hbitmap, sizeof(bmp), (LPSTR)&bmp );
+	infoPtr->bitmapSize.cx = (bmp.bmWidth != 0) ? bmp.bmWidth : 1;
+	infoPtr->bitmapSize.cy = (bmp.bmHeight != 0) ? bmp.bmHeight : 1;
+    }
     return TRUE;
 }