Release 0.5

Sun Jan  2 12:38:53 1994  David Metcalfe <david@prism.demon.co.uk>

	* [windows/class.c]
	Implemented GetClassName and GetClassInfo.

	* [windows/caret.c]
	Various improvements to text caret code.

Fri Dec 31 15:22:22 1993  John Brezak <brezak@apollo.hp.com>

	* [misc/comm.c]
	Patches to work with NetBSD.

Thu Dec 30 12:11:55 1993  John Richardson <jrichard@cs.uml.edu>

	* [objects/bitblt.c] Added StretchBlt().

Tue Jan  4 05:22:07 1994  julliard@di.epfl.ch (Alexandre Julliard)

	* [misc/user.c]
	Added creation of system message queue.

	* [objects/bitmap.c] [objects/dcvalues.c] [windows/dc.c]
	Added DC size fields into DC structure.		

	* [objects/clipping.c]
	Bug fix in CLIPPING_IntersectRect().

	* [windows/class.c]
	Allocate a DCE instead of a DC for CS_CLASSDC classes.

	* [windows/clipping.c]
	Fixed GetUpdateRect() and GetUpdateRgn() to clip to the client area.

	* [windows/dce.c]
	Implemented GetDCEx() and GetWindowDC().

	* [windows/defwnd.c]
	Implemented WM_WINDOWPOSCHANGED handling.

	* [windows/event.c]
	Preliminary support for Xlib event handling instead of Xt callbacks.
	Changed MSG_AddMsg() calls to hardware_event() or PostMessage().

	* [windows/message.c]
	Preliminary support for multiple message queues.
	Implemented hardware_event() to store messages into the system queue.
	Implemented Get/SetTaskQueue().
	Better WM_PAINT and WM_TIMER handling.
	Changes to use Xlib instead of Xt for events.

	* [windows/painting.c]
	Use GetDCEx() to retrieve the DC, to get a correct visible region.

	* [windows/timer.c]
	Moved the timer procedure callback into DispatchMessage().
	Changed implementation to get rid of Xt timeouts.  Timer checking
	is now done inside GetMessage().

	* [windows/win.c]
	Allocate a DCE instead of a DC for CS_OWNDC windows.
	Replaced Xt calls with Xlib calls.
	Moved window positioning functions into windows/winpos.c

	* [windows/winpos.c]  (New file)
	Rewritten most of the window positioning functions.
	Implemented SetWindowPos() and MapWindowPoints().

Jan 3, 94 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [if1632/user.spec]
	Bad arguments description for function SetDlgItemText.

	* [objects/text.c]
	Function DrawText now handle DT_CALCRECT request.

	* [misc/message.c]
	Message boxes now use DrawText with DT_CALCRECT.

	* [windows/graphics.c]
	Bug fix in function FrameRect, (it was using PEN instead of BRUSH).

	* [windows/win.c]
	Bug fix for flags in function ShowWindow.
	More accurate WM_SIZE generated by function ShowWindow.

	* [controls/listbox.c]
	More code for LBS_MULTIPLESEL.
	More code for LBS_MULTICOLUMN.

	* [include/windows.h]
	Bad define for MF_SEPARATOR.

	* [controls/menu.c]
	New functions: PopMenuWndProc() with 'glues',
	CreatePopupMenu(), AppendMenu(), InsertMenu(), RemoveMenu(), 
	DeleteMenu(), ModifyMenu(), TrackPopupMenu().
	Code in stubs: CreateMenu(), DestroyMenu(). 

Sat Jan  1 10:22:43 1994  Bob Amstadt  (bob@pooh)

	* loader/wine.c: Added support for relocation types 5 and 6.

Mon Dec 27 11:06:03 1993  Erik Bos (erik@trashcan.hacktic.nl)

	* [misc/comm.c]
	new functions: BuildCommDCB(), OpenComm(), CloseComm(),
	SetCommBreak(), ClearCommBreak(), EscapeCommFunction(), FlushComm(),
	GetCommError(), SetCommEventMask(), GetCommEventMask(),
	SetCommState(), GetCommState(), TransmitCommChar(), ReadComm(), 
	WriteComm().

Wed Dec 22 13:00:15 1993  David Metcalfe <david@prism.demon.co.uk>

	* [windows/caret.c]
	Implemented text caret functions.

Tue Dec 21 06:13:58 1993  julliard@di.epfl.ch (Alexandre Julliard)

	* [loader/wine.c]
	Bug fix in LoadImage().

	* [objects/bitblt.c] [objects/clipping.c] [objects/text.c]
	  [windows/dc.c] [windows/dce.c] [windows/graphics.c]
	Modified graphics calls to take into account the DC origin.

	* [windows/defwnd.c]
	Added preliminary WM_NCCALCSIZE handling.

	* [windows/event.c]
	Send WM_NCCALCSIZE message on resize event.

	* [windows/win.c]
	Send WM_NCCALCSIZE message in CreateWindow().
	Realize widgets at creation time (should prevent problems with
	unrealized widgets).

Dec 19, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/static.c]
	Send mouse & keyboard message received to its parent.

	* [controls/scroll.c]
	Send keyboard message received to its parent.

	* [controls/listbox.c]
	Add Navigation keys .
	ListBox now use VSCROLL & HSCROLL instead of children.
	Alpha version of LBS_MULTIPLESEL.
	Alpha version of LBS_MULTICOLUMN.

	* [controls/combo.c]
	Add Navigation keys on closed ComboBox.
	Remove useless 'COMBOBOX_CreateComboBox' function.

Mon Dec 19 20:39:34 1993  Erik Bos (erik@trashcan.hacktic.nl)

	* [loader/wine.
	LoadImage() modified to use FindFile().

	* [misc/file.c]
	SetErrorMode added

	* [misc/dos_fs.c]
	bug fixes.

Dec 13, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [memory/global.c]
	bug fix in GlobalGetFreeSegment : good ptr in 'g_prev'.

	* [sysres.dll]
	preliminary version of a 'glass of wine' bitmap

	* [windows/event.c]
	New function 'GetCapture'.

	* [controls/scroll.c]
	Remove useless 'SCROLLBAR_CreateScrollBar' function.

	* [controls/listbox.c]
	Remove useless 'LISTBOX_CreateListBox' function.

Mon Dec 13 13:51:00 1993  David Metcalfe <david@prism.demon.co.uk>

	* [objects/font.c]
	Corrected bugs in GetCharWidth().

	* [windows/event.c]
	Modified EVENT_key to send Windows virtual key codes for
	WM_KEYDOWN and WM_KEYUP messages, and a WM_CHAR message
	for printable characters.

Wed Dec 08 19:20:00 1993  Karl Guenter Wuensch (hn324wu@unidui.uni-duisburg.de)

	* [windows/graphics.c]
	Added Polyline and Polygon

Mon Dec 13 14:51:54 1993  Erik Bos (erik@trashcan.hacktic.nl)

	* [controls/listbox.c]
	ListBoxDirectory() modified to use dos_fs.c's functions to
	access files&|drives.

Sat Dec 04 17:04:23 1993  Erik Bos (erik@trashcan.hacktic.nl)

       	* [misc/dos_fs.c]
       	Added FindFile() to search a file in a dos/unix style path.
	
	* [misc/file.c]
	New Win31 functions: OpenFile, _lcreate, _llseek, GetTempDrive,
	GetTempFileName, GetWindowsDirectory, GetSystemDirectory,
	GetDriveType.			   

       	* [misc/int21.c]
       	Modified.

Wed Dec  1 16:20:45 1993  Miguel de Icaza  (miguel@roxanne.nuclecu.unam.mx)

        * [misc/profile.c]
        The Profile functions now return the correct values. They now
        implement all the features described in the SDK.

Tue Nov 30 13:55:27 1993  Bob Amstadt  (bob at amscons)

	* [loader/selector.c]
	Rewrote selector aliasing routines to use System V IPC
	routine to alias memory segments.

Nov 28, 93 martin2@trgcorp.solucorp.qc.ca (Martin Ayotte)

	* [controls/listbox.c]
	More consistency in functions using wIndexes

	* [controls/scroll.c]
	New function : ShowScrollBar().

	* [loader/cursor.c] ... New file
	Move cursor functions from [loader/resource.c].
	New function : ClipCursor().
	New function : GetClipCursor().
	New function : CreateCursor().
	SetCursor() now working using gloabal variable 'winHasCursor'.

	*[object/palette.c]
	New stub only : SelectPalette().
	New stub only : RealizePalette().

	*[win/event.c]
	New function : EVENT_enter_notify(),
		update 'winHasCursor' and send WM_SETCURSOR.

	*[win/defwnd.c]
	Add processing of WM_SETCURSOR message.

	*[win/win.c]
	New members in WND structure : hCursor, hWndVScroll & hWndHScroll. 
	CreateWindowEx() now create children for WM_HSCROLL & WM_VSCROLL.
	New function ClientToScreen().
	New function ScreenToClient().

Mon Nov 25 18:25:40 1993  Erik Bos (erik@trashcan.hacktic.nl)

       	* [files.h / regfunc.h / misc/dos.c]
       	Removed.

       	* [misc/dos_fs.c]
       	Added support for loading dosdrive cfg from wine.ini.

       	* [misc/int21.c]
       	Modified.


Wed Nov 24 11:37:33 1993  julliard@disuns2.epfl.ch (Alexandre Julliard)

	* [include/atom.h] [memory/atom.c]
	Implemented atoms.

	* [windows/class.c]
	Modified RegisterClass() to use atoms.
	Implemented CS_GLOBALCLASS style.

	* [windows/message.c]
	Implemented RegisterWindowMessage().

	* [loader/resource.c]
	Bug fix in LoadResource().

	* [windows/dialog.c]
	Modified CreateDialogParam() to use Find/LoadResource().
diff --git a/objects/Imakefile b/objects/Imakefile
new file mode 100644
index 0000000..458761d
--- /dev/null
+++ b/objects/Imakefile
@@ -0,0 +1,43 @@
+#include "../Wine.tmpl"
+
+MODULE = objects
+
+SRCS = \
+	bitmap.c \
+	brush.c \
+	font.c \
+	gdiobj.c \
+	palette.c \
+	pen.c \
+	dib.c \
+	region.c \
+	text.c \
+	dcvalues.c \
+	clipping.c \
+	bitblt.c \
+	linedda.c \
+	color.c
+
+OBJS = \
+	bitmap.o \
+	brush.o \
+	font.o \
+	gdiobj.o \
+	palette.o \
+	pen.o \
+	dib.o \
+	region.o \
+	text.o \
+	dcvalues.o \
+	clipping.o \
+	bitblt.o \
+	linedda.o \
+	color.o
+
+WineRelocatableTarget($(TOP)/$(MODULE),,$(OBJS))
+DependTarget()
+CleanTarget()
+
+includes::
+
+install::
diff --git a/objects/bitblt.c b/objects/bitblt.c
index 53e9ba1..c4ed6bc 100644
--- a/objects/bitblt.c
+++ b/objects/bitblt.c
@@ -38,10 +38,10 @@
     else rop = (rop & 0x03) | ((rop >> 4) & 0x0c);
     XSetFunction( XT_display, dc->u.x.gc, DC_XROPfunction[rop] );
 
-    x1 = XLPTODP( dc, left );
-    x2 = XLPTODP( dc, left + width );
-    y1 = YLPTODP( dc, top );
-    y2 = YLPTODP( dc, top + height );
+    x1 = dc->w.DCOrgX + XLPTODP( dc, left );
+    x2 = dc->w.DCOrgX + XLPTODP( dc, left + width );
+    y1 = dc->w.DCOrgY + YLPTODP( dc, top );
+    y2 = dc->w.DCOrgY + YLPTODP( dc, top + height );
     XFillRectangle( XT_display, dc->u.x.drawable, dc->u.x.gc,
 		   MIN(x1,x2), MIN(y1,y2), abs(x2-x1), abs(y2-y1) );
     return TRUE;
@@ -78,14 +78,14 @@
     dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC );
     if (!dcSrc) return FALSE;
 
-    xs1 = XLPTODP( dcSrc, xSrc );
-    xs2 = XLPTODP( dcSrc, xSrc + width );
-    ys1 = YLPTODP( dcSrc, ySrc );
-    ys2 = YLPTODP( dcSrc, ySrc + height );
-    xd1 = XLPTODP( dcDest, xDest );
-    xd2 = XLPTODP( dcDest, xDest + width );
-    yd1 = YLPTODP( dcDest, yDest );
-    yd2 = YLPTODP( dcDest, yDest + height );
+    xs1 = dcSrc->w.DCOrgX + XLPTODP( dcSrc, xSrc );
+    xs2 = dcSrc->w.DCOrgX + XLPTODP( dcSrc, xSrc + width );
+    ys1 = dcSrc->w.DCOrgY + YLPTODP( dcSrc, ySrc );
+    ys2 = dcSrc->w.DCOrgY + YLPTODP( dcSrc, ySrc + height );
+    xd1 = dcDest->w.DCOrgX + XLPTODP( dcDest, xDest );
+    xd2 = dcDest->w.DCOrgX + XLPTODP( dcDest, xDest + width );
+    yd1 = dcDest->w.DCOrgY + YLPTODP( dcDest, yDest );
+    yd2 = dcDest->w.DCOrgY + YLPTODP( dcDest, yDest + height );
 
     if ((abs(xs2-xs1) != abs(xd2-xd1)) || (abs(ys2-ys1) != abs(yd2-yd1)))
 	return FALSE;  /* Should call StretchBlt here */
@@ -109,3 +109,78 @@
     }
     return TRUE;
 }
+
+
+
+/***********************************************************************
+ *           StrechBlt    (GDI.35)
+ */
+BOOL StrechBlt( HDC hdcDest, short xDest, short yDest, short widthDest, short heightDest,
+               HDC hdcSrc, short xSrc, short ySrc, short widthSrc, short heightSrc, DWORD rop )
+{
+    int xs1, xs2, ys1, ys2;
+    int xd1, xd2, yd1, yd2;
+    DC *dcDest, *dcSrc;
+
+/*#ifdef DEBUG_GDI     */
+
+    printf( "StrechBlt: %d %d,%d %dx%d %d %d,%d %dx%d %08x\n",
+           hdcDest, xDest, yDest, widthDest, heightDest, hdcSrc, xSrc, 
+           ySrc, widthSrc, heightSrc, rop );
+/*#endif */
+
+
+
+    if ((rop & 0xcc0000) == ((rop & 0x330000) << 2))
+        return PatBlt( hdcDest, xDest, yDest, widthDest, heightDest, rop );
+
+    printf("here\n");
+
+    rop >>= 16;
+    if ((rop & 0x0f) != (rop >> 4))
+    {
+        printf( "BitBlt: Unimplemented ROP %02x\n", rop );
+        return FALSE;
+    }
+
+    printf("here2\n");
+    
+    dcDest = (DC *) GDI_GetObjPtr( hdcDest, DC_MAGIC );
+    if (!dcDest) return FALSE;
+    dcSrc = (DC *) GDI_GetObjPtr( hdcSrc, DC_MAGIC );
+    if (!dcSrc) return FALSE;
+
+    xs1 = XLPTODP( dcSrc, xSrc );
+    xs2 = XLPTODP( dcSrc, xSrc + widthSrc );
+    ys1 = YLPTODP( dcSrc, ySrc );
+    ys2 = YLPTODP( dcSrc, ySrc + heightSrc );
+    xd1 = XLPTODP( dcDest, xDest );
+    xd2 = XLPTODP( dcDest, xDest + widthDest );
+    yd1 = YLPTODP( dcDest, yDest );
+    yd2 = YLPTODP( dcDest, yDest + heightDest );
+
+    DC_SetupGCForText( dcDest );
+    XSetFunction( XT_display, dcDest->u.x.gc, DC_XROPfunction[rop & 0x0f] );
+
+    if (dcSrc->w.bitsPerPixel == dcDest->w.bitsPerPixel)
+    {
+            printf("XCopyArea\n");
+        XCopyArea( XT_display, dcSrc->u.x.drawable,
+                   dcDest->u.x.drawable, dcDest->u.x.gc,
+                   MIN(xs1,xs2), MIN(ys1,ys2), abs(xd2-xd1), abs(yd2-yd1),
+                   MIN(xd1,xd2), MIN(yd1,yd2) );
+    }
+    else
+    {
+            printf("XCopyPlane\n");
+        if (dcSrc->w.bitsPerPixel != 1) return FALSE;
+        XCopyPlane( XT_display, dcSrc->u.x.drawable,
+                    dcDest->u.x.drawable, dcDest->u.x.gc,
+                    MIN(xs1,xs2), MIN(ys1,ys2), abs(xd2-xd1), abs(yd2-yd1),
+                    MIN(xd1,xd2), MIN(yd1,yd2), 1 );
+    }
+    return TRUE;
+
+
+}
+
diff --git a/objects/bitmap.c b/objects/bitmap.c
index 9de4c1c..ffec3e9 100644
--- a/objects/bitmap.c
+++ b/objects/bitmap.c
@@ -46,6 +46,7 @@
 	if (tmpPixmap)
 	{
 	    bitmapGC[i] = XCreateGC( XT_display, tmpPixmap, 0, NULL );
+	    XSetGraphicsExposures( XT_display, bitmapGC[i], False );
 	    XFreePixmap( XT_display, tmpPixmap );
 	}
 	else bitmapGC[i] = 0;
@@ -355,6 +356,8 @@
 				        DefaultRootWindow( XT_display ), 
 				        bmp->bmWidth, bmp->bmHeight,
 				        bmp->bmBitsPixel );
+    dc->w.DCSizeX      = bmp->bmWidth;
+    dc->w.DCSizeY      = bmp->bmHeight;
     BITMAP_CopyToPixmap( bmp, dc->u.x.drawable,
 			 0, 0, bmp->bmWidth, bmp->bmHeight );
 
diff --git a/objects/clipping.c b/objects/clipping.c
index ec9de9c..5776eb8 100644
--- a/objects/clipping.c
+++ b/objects/clipping.c
@@ -11,9 +11,32 @@
 
 
 /***********************************************************************
+ *           CLIPPING_SetDeviceClipping
+ *
+ * Set the clip region of the physical device.
+ */
+void CLIPPING_SetDeviceClipping( DC * dc )
+{
+    if (dc->w.hGCClipRgn)
+    {
+	RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr(dc->w.hGCClipRgn, REGION_MAGIC);
+	XSetClipMask( XT_display, dc->u.x.gc, obj->region.pixmap );
+	XSetClipOrigin( XT_display, dc->u.x.gc,
+		        dc->w.DCOrgX + obj->region.box.left,
+		        dc->w.DCOrgY + obj->region.box.top );
+    }
+    else
+    {
+	XSetClipMask( XT_display, dc->u.x.gc, None );
+	XSetClipOrigin( XT_display, dc->u.x.gc, dc->w.DCOrgX, dc->w.DCOrgY );
+    }
+}
+
+
+/***********************************************************************
  *           CLIPPING_UpdateGCRegion
  *
- * Update the GC clip region when the ClipRgn of VisRgn have changed.
+ * Update the GC clip region when the ClipRgn or VisRgn have changed.
  */
 static void CLIPPING_UpdateGCRegion( DC * dc )
 {
@@ -36,19 +59,7 @@
 	else
 	    CombineRgn( dc->w.hGCClipRgn, dc->w.hClipRgn, dc->w.hVisRgn, RGN_AND );
     }
-    
-    if (dc->w.hGCClipRgn)
-    {
-	RGNOBJ *obj = (RGNOBJ *) GDI_GetObjPtr( dc->w.hGCClipRgn, REGION_MAGIC );
-	XSetClipMask( XT_display, dc->u.x.gc, obj->region.pixmap );
-	XSetClipOrigin( XT_display, dc->u.x.gc,
-		        obj->region.box.left, obj->region.box.top );
-    }
-    else
-    {
-	XSetClipMask( XT_display, dc->u.x.gc, None );
-	XSetClipOrigin( XT_display, dc->u.x.gc, 0, 0 );
-    }	
+    CLIPPING_SetDeviceClipping( dc );
 }
 
 
@@ -157,26 +168,40 @@
 int CLIPPING_IntersectRect( DC * dc, HRGN * hrgn, short left, short top,
 			    short right, short bottom, int exclude )
 {
-    HRGN tempRgn, newRgn;
+    HRGN tempRgn = 0, prevRgn = 0, newRgn = 0;
     RGNOBJ *newObj, *prevObj;
     int retval;
 
-    if (!*hrgn) return NULLREGION;
-    if (!(newRgn = CreateRectRgn( 0, 0, 0, 0))) return ERROR;
-    if (!(tempRgn = CreateRectRgn( left, top, right, bottom )))
+    if (!*hrgn)
     {
-	DeleteObject( newRgn );
-	return ERROR;
+	if (!(*hrgn = CreateRectRgn( 0, 0, dc->w.DCSizeX, dc->w.DCSizeY )))
+	    goto Error;
+	prevRgn = *hrgn;
     }
+    if (!(newRgn = CreateRectRgn( 0, 0, 0, 0))) goto Error;
+    if (!(tempRgn = CreateRectRgn( left, top, right, bottom ))) goto Error;
+
     retval = CombineRgn( newRgn, *hrgn, tempRgn, exclude ? RGN_DIFF : RGN_AND);
+    if (retval == ERROR) goto Error;
+
     newObj = (RGNOBJ *) GDI_GetObjPtr( newRgn, REGION_MAGIC );
     prevObj = (RGNOBJ *) GDI_GetObjPtr( *hrgn, REGION_MAGIC );
     if (newObj && prevObj) newObj->header.hNext = prevObj->header.hNext;
     DeleteObject( tempRgn );
-    DeleteObject( *hrgn );
+    if (*hrgn) DeleteObject( *hrgn );
     *hrgn = newRgn;    
     CLIPPING_UpdateGCRegion( dc );
     return retval;
+
+ Error:
+    if (tempRgn) DeleteObject( tempRgn );
+    if (newRgn) DeleteObject( newRgn );
+    if (prevRgn)
+    {
+	DeleteObject( prevRgn );
+	*hrgn = 0;
+    }
+    return ERROR;
 }
 
 
@@ -292,13 +317,9 @@
     if (dc->w.hGCClipRgn) return GetRgnBox( dc->w.hGCClipRgn, rect );
     else
     {
-	Window root;
-	int width, height, x, y, border, depth;
-	XGetGeometry( XT_display, dc->u.x.drawable, &root, &x, &y, 
-		      &width, &height, &border, &depth );
 	rect->top = rect->left = 0;
-	rect->right  = width & 0xffff;
-	rect->bottom = height & 0xffff;
+	rect->right = dc->w.DCSizeX;
+	rect->bottom = dc->w.DCSizeY;
 	return SIMPLEREGION;
     }
 }
diff --git a/objects/dcvalues.c b/objects/dcvalues.c
index b496e2e..73c98aa 100644
--- a/objects/dcvalues.c
+++ b/objects/dcvalues.c
@@ -45,6 +45,8 @@
     MM_TEXT,                /* MapMode */
     0,                      /* DCOrgX */
     0,                      /* DCOrgY */
+    0,                      /* DCSizeX */
+    0,                      /* DCSizeY */
     0,                      /* CursPosX */
     0,                      /* CursPosY */
     0,                      /* WndOrgX */
diff --git a/objects/font.c b/objects/font.c
index 1299a26..10bc76b 100644
--- a/objects/font.c
+++ b/objects/font.c
@@ -331,6 +331,36 @@
 }
 
 
+/***********************************************************************/
+
+#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
+			     (((cs)->rbearing|(cs)->lbearing| \
+			       (cs)->ascent|(cs)->descent) == 0))
+
+/* 
+ * CI_GET_CHAR_INFO - return the charinfo struct for the indicated 8bit
+ * character.  If the character is in the column and exists, then return the
+ * appropriate metrics (note that fonts with common per-character metrics will
+ * return min_bounds).  If none of these hold true, try again with the default
+ * char.
+ */
+#define CI_GET_CHAR_INFO(fs,col,def,cs) \
+{ \
+    cs = def; \
+    if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+	if (fs->per_char == NULL) { \
+	    cs = &fs->min_bounds; \
+	} else { \
+	    cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
+	    if (CI_NONEXISTCHAR(cs)) cs = def; \
+	} \
+    } \
+}
+
+#define CI_GET_DEFAULT_INFO(fs,cs) \
+  CI_GET_CHAR_INFO(fs, fs->default_char, NULL, cs)
+
+
 /***********************************************************************
  *           GetCharWidth    (GDI.350)
  */
@@ -338,8 +368,7 @@
 {
     int i, j;
     XFontStruct *xfont;
-    XCharStruct *charPtr;
-    int default_width;
+    XCharStruct *cs, *def;
 
     DC *dc = (DC *)GDI_GetObjPtr(hdc, DC_MAGIC);
     if (!dc) return FALSE;
@@ -353,15 +382,12 @@
 	return TRUE;
     }
 
-    charPtr = xfont->per_char;
-    default_width = (charPtr + xfont->default_char)->width;
+    CI_GET_DEFAULT_INFO(xfont, def);
 	
     for (i = wFirstChar, j = 0; i <= wLastChar; i++, j++)
     {
-	if (i < xfont->min_char_or_byte2 || i > xfont->max_char_or_byte2)
-	    *(lpBuffer + j) = default_width;
-	else
-	    *(lpBuffer + j) = charPtr->width;
+	CI_GET_CHAR_INFO(xfont, i, def, cs);
+	*(lpBuffer + j) = cs->width;
     }
     return TRUE;
 }
diff --git a/objects/gdiobj.c b/objects/gdiobj.c
index 32bb4b8..cc539a4 100644
--- a/objects/gdiobj.c
+++ b/objects/gdiobj.c
@@ -153,7 +153,6 @@
     s = (struct segment_descriptor_s *)GetNextSegment( 0, 0x10000 );
     if (s == NULL) return FALSE;
     HEAP_Init( &GDI_Heap, s->base_addr, GDI_HEAP_SIZE );
-    free(s);
 
       /* Create default palette */
 
@@ -200,8 +199,11 @@
     GDIOBJHDR * obj;
     HANDLE handle = GDI_HEAP_ALLOC( GMEM_MOVEABLE, size );
     if (!handle) return 0;
-    
     obj = (GDIOBJHDR *) GDI_HEAP_ADDR( handle );
+    if (obj == NULL) {
+    	printf("GDI_AllocObject // Error trying to get GDI_HEAD_ADDR !\n");
+    	return 0;
+    	}
     obj->hNext   = 0;
     obj->wMagic  = magic;
     obj->dwCount = ++count;
diff --git a/objects/palette.c b/objects/palette.c
index 3b101b2..511cf3f 100644
--- a/objects/palette.c
+++ b/objects/palette.c
@@ -177,3 +177,21 @@
     memcpy( buffer, &palette->logpalette.palNumEntries, count );
     return count;
 }
+
+
+/***********************************************************************
+ *           SelectPalette    (USER.282)
+ */
+HPALETTE SelectPalette(HDC hDC, HPALETTE hPal, BOOL bForceBackground)
+{
+    return (HPALETTE)NULL;
+}
+
+/***********************************************************************
+ *           RealizePalette    (USER.283)
+ */
+int RealizePalette(HDC hDC)
+{
+    return 0;
+}
+
diff --git a/objects/region.c b/objects/region.c
index 08274ca..3a7b9ef 100644
--- a/objects/region.c
+++ b/objects/region.c
@@ -31,6 +31,7 @@
 	XFreePixmap( XT_display, tmpPixmap );
 	if (!regionGC) return FALSE;
 	XSetForeground( XT_display, regionGC, 1 );
+	XSetGraphicsExposures( XT_display, regionGC, False );
 	return TRUE;
     }
     else return FALSE;
diff --git a/objects/text.c b/objects/text.c
index bbb2740..07aef58 100644
--- a/objects/text.c
+++ b/objects/text.c
@@ -229,7 +229,8 @@
 	    else if (flags & DT_BOTTOM) y = rect->bottom - size.cy;
 	}
 
-	if (!TextOut(hdc, x, y, line, len)) return 0;
+	if (!(flags & DT_CALCRECT))
+	    if (!TextOut(hdc, x, y, line, len)) return 0;
 	if (prefix_offset != -1)
 	{
 	    MoveTo(hdc, x + prefix_x, y + size.cy);
@@ -247,7 +248,7 @@
 	}
     }
     while (strPtr);
-
+    if (flags & DT_CALCRECT) rect->bottom = y;
     return 1;
 }
 
@@ -314,10 +315,10 @@
     {
 	if (dc->w.backgroundMode == TRANSPARENT)
 	    XDrawString( XT_display, dc->u.x.drawable, dc->u.x.gc, 
-			 x, y, str, count );
+			 dc->w.DCOrgX + x, dc->w.DCOrgY + y, str, count );
 	else
 	    XDrawImageString( XT_display, dc->u.x.drawable, dc->u.x.gc,
-			      x, y, str, count );
+			      dc->w.DCOrgX + x, dc->w.DCOrgY + y, str, count );
     }
     else
     {
@@ -340,14 +341,15 @@
 
 	    if (dc->w.backgroundMode == TRANSPARENT)
 		XDrawString( XT_display, dc->u.x.drawable, dc->u.x.gc,
-			     xchar, y, p, 1 );
+			     dc->w.DCOrgX + xchar, dc->w.DCOrgY + y, p, 1 );
 	    else
 	    {
 		XDrawImageString( XT_display, dc->u.x.drawable, dc->u.x.gc,
-				  xchar, y, p, 1 );
+				  dc->w.DCOrgX + xchar, dc->w.DCOrgY + y, p, 1 );
 		XSetForeground( XT_display, dc->u.x.gc, dc->w.backgroundPixel);
 		XFillRectangle( XT_display, dc->u.x.drawable, dc->u.x.gc,
-			        xchar + charStr->width, y - font->ascent,
+			        dc->w.DCOrgX + xchar + charStr->width,
+			        dc->w.DCOrgY + y - font->ascent,
 			        extraWidth, font->ascent + font->descent );
 		XSetForeground( XT_display, dc->u.x.gc, dc->w.textPixel );
 	    }
@@ -368,7 +370,8 @@
 	XSetLineAttributes( XT_display, dc->u.x.gc, lineWidth,
 			    LineSolid, CapRound, JoinBevel ); 
 	XDrawLine( XT_display, dc->u.x.drawable, dc->u.x.gc,
-		   x, y + linePos, x + info.width, y + linePos );
+		   dc->w.DCOrgX + x, dc->w.DCOrgY + y + linePos,
+		   dc->w.DCOrgX + x + info.width, dc->w.DCOrgY + y + linePos );
     }
     if (dc->u.x.font.metrics.tmStruckOut)
     {
@@ -380,7 +383,8 @@
 	XSetLineAttributes( XT_display, dc->u.x.gc, lineAscent + lineDescent,
 			    LineSolid, CapRound, JoinBevel ); 
 	XDrawLine( XT_display, dc->u.x.drawable, dc->u.x.gc,
-		   x, y - lineAscent, x + info.width, y - lineAscent );
+		   dc->w.DCOrgX + x, dc->w.DCOrgY + y - lineAscent,
+		   dc->w.DCOrgX + x + info.width, dc->w.DCOrgY + y - lineAscent );
     }
     
     return TRUE;