#FEATURE by sr
authorsr
Mon, 22 Oct 2018 14:05:45 +0200
changeset 8525 b7dcc1de2b59
parent 8524 d5cb3cda12b2
child 8526 9dd89edb266a
#FEATURE by sr support (hopefully) stable native file dialog the switch to the new implementation is not yet done will be there within the next checkin after some tests and more comments class: WinWorkstation added: #nativeFileDialogWithTitle:defaultFilename:owningViewId:filterString:filterIndex:doSave: #primCloseNativeFileDialogByDataAddress:threadHandleAddress: #primGetNativeFileDialogResultByDataAddress: #primNativeFileDialogWithTitle:defaultFilename:owningViewId:filterString:filterIndex:doSave: comment/format in: #nativeFileDialogTargetFileOrNilByDataAddress:
WinWorkstation.st
--- a/WinWorkstation.st	Mon Oct 22 09:48:03 2018 +0200
+++ b/WinWorkstation.st	Mon Oct 22 14:05:45 2018 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
 COPYRIGHT (c) 1996 by Claus Gittinger
 	      All Rights Reserved
@@ -85,7 +87,7 @@
 #define LATE_GENERATE_EXPOSE              /* get update region from stx thread */
 #define xxNO_CLEAR_FOR_WM_PAINT           /* do not fill exposed areas with bgColor */
 #define xxLATE_CLEAR_FOR_WM_PAINT         /* fill exposed areas with bgColor in ST/X thread (instead of in event-thread) */
-                                          /* seems to be needed to avoid DC conflicts */
+					  /* seems to be needed to avoid DC conflicts */
 
 #if 0 /* DOES NOT WORK */
 # define CACHE_LAST_PEN                  /* remember last pen in gcData */
@@ -347,8 +349,8 @@
 
 struct gcData {
     union {
-        HDC         __hDC;
-        struct gcData *__nextFree;
+	HDC         __hDC;
+	struct gcData *__nextFree;
     } u;
     HWND        hWnd;
     HBITMAP     hBitmap;
@@ -613,12 +615,12 @@
 
 #define INFOFPRINTF(__x__)                 \
     if (@global(InfoPrinting) == true) { \
-        console_fprintf __x__;           \
+	console_fprintf __x__;           \
     }
 
 #define DEBUGFPRINTF(__x__)                 \
     if (@global(InfoPrinting) == true) { \
-        console_fprintf __x__;           \
+	console_fprintf __x__;           \
     }
 
 #define BR_SOLID       0
@@ -753,47 +755,47 @@
 #define LI_NATIVEWIN    0x0004
 
 typedef struct {
-        HCURSOR         hCursor;
-        HBRUSH          viewBgBrush;  /* if that is nil, it has a solid bg color */
-        COLORREF        viewBgColor;
-        int             eventMask;
-        short           flag;         /* LI_ - flags bits */
-        short           minWidth;
-        short           maxWidth;
-        short           minHeight;
-        short           maxHeight;
-        short           currentMonitorWidth;
-        short           currentMonitorHeight;
-        short           bw;
-        unsigned char   iconified;
-        unsigned char   viewGravity;
-        unsigned char   unmapping;
-#if 0
-        short           bgOffsX;      /* bg-pattern offset */
-        short           bgOffsY;      /* bg-pattern offset */
-#endif
-        short           mouseX;       /* last mouseX */
-        short           mouseY;       /* last mouseY */
-        COLORREF        bdColor;
+	HCURSOR         hCursor;
+	HBRUSH          viewBgBrush;  /* if that is nil, it has a solid bg color */
+	COLORREF        viewBgColor;
+	int             eventMask;
+	short           flag;         /* LI_ - flags bits */
+	short           minWidth;
+	short           maxWidth;
+	short           minHeight;
+	short           maxHeight;
+	short           currentMonitorWidth;
+	short           currentMonitorHeight;
+	short           bw;
+	unsigned char   iconified;
+	unsigned char   viewGravity;
+	unsigned char   unmapping;
+#if 0
+	short           bgOffsX;      /* bg-pattern offset */
+	short           bgOffsY;      /* bg-pattern offset */
+#endif
+	short           mouseX;       /* last mouseX */
+	short           mouseY;       /* last mouseY */
+	COLORREF        bdColor;
 } localWindowInfo;
 typedef localWindowInfo *plocalWindowInfo;
 
 typedef struct createWindowInfo {
-        localWindowInfo *localWindowInfo;  /* in param */
-        HANDLE          newWinHandle;      /* out param */
-        wchar_t         *windowName;       /* in params */
-        wchar_t         *className;
-        int             winStyleBits;
-        int             winStyleBitsEx;
-        HANDLE          parentHandle;
-        int             x;
-        int             y;
-        int             dx;
-        int             dy;
-        HANDLE          hCreateEvent;
-        short           infoWasRead;
-        unsigned short  sequenceNr;
-        unsigned        errCode;
+	localWindowInfo *localWindowInfo;  /* in param */
+	HANDLE          newWinHandle;      /* out param */
+	wchar_t         *windowName;       /* in params */
+	wchar_t         *className;
+	int             winStyleBits;
+	int             winStyleBitsEx;
+	HANDLE          parentHandle;
+	int             x;
+	int             y;
+	int             dx;
+	int             dy;
+	HANDLE          hCreateEvent;
+	short           infoWasRead;
+	unsigned short  sequenceNr;
+	unsigned        errCode;
 } createWindowInfo;
 
 #define INVALIDATED_CWI 0xFFFF             /* seqNr for invalidated CWI */
@@ -808,111 +810,111 @@
 # define GWL_LOCALINFO  GWLP_USERDATA
 
 # define SETLOCALWINDOWINFOPTR(__hWnd__,__ptr__) \
-        SetWindowLongPtr(__hWnd__, GWL_LOCALINFO , (LONG_PTR)__ptr__)
+	SetWindowLongPtr(__hWnd__, GWL_LOCALINFO , (LONG_PTR)__ptr__)
 
 # define GETLOCALWINDOWINFOPTR(__hWnd__) \
-        ((localWindowInfo *)GetWindowLongPtr(__hWnd__, GWL_LOCALINFO))
+	((localWindowInfo *)GetWindowLongPtr(__hWnd__, GWL_LOCALINFO))
 
 #else
 
 # define GWL_LOCALINFO  GWL_USERDATA
 
 # define SETLOCALWINDOWINFOPTR(__hWnd__,__ptr__) \
-        SetWindowLong(__hWnd__, GWL_LOCALINFO , (DWORD)__ptr__)
+	SetWindowLong(__hWnd__, GWL_LOCALINFO , (DWORD)__ptr__)
 
 # define GETLOCALWINDOWINFOPTR(__hWnd__) \
-        ((localWindowInfo *)GetWindowLong(__hWnd__, GWL_LOCALINFO))
+	((localWindowInfo *)GetWindowLong(__hWnd__, GWL_LOCALINFO))
 
 #endif
 
 #define SetWindow_Cursor(__hWnd__, __hCurs__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor = __hCurs__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor = __hCurs__) : 0)
 
 #define GetWindow_Cursor(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->hCursor : 0)
 
 #define SetWindow_viewBgColor(__hWnd__, __viewBgColor__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor = __viewBgColor__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor = __viewBgColor__) : 0)
 
 #define GetWindow_viewBgColor(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgColor : 0)
 
 #define SetWindow_bdColor(__hWnd__, __bdColor__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor = __bdColor__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor = __bdColor__) : 0)
 
 #define GetWindow_bdColor(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bdColor : 0)
 
 #define SetWindow_iconified(__hWnd__, __iconified__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->iconified = __iconified__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->iconified = __iconified__) : 0)
 
 #define GetWindow_iconified(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->iconified : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->iconified : 0)
 
 #define SetWindow_unmapping(__hWnd__, __unmapping__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping = __unmapping__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping = __unmapping__) : 0)
 
 #define GetWindow_unmapping(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->unmapping : 0)
 
 #define SetWindow_mouseX(__hWnd__, __mouseX__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX = __mouseX__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX = __mouseX__) : 0)
 
 #define GetWindow_mouseX(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseX : 0)
 
 #define SetWindow_mouseY(__hWnd__, __mouseY__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY = __mouseY__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY = __mouseY__) : 0)
 
 #define GetWindow_mouseY(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->mouseY : 0)
 
 #define SetWindow_mouseXY(__hWnd__, __mouseX__, __mouseY__) \
-        { SetWindow_mouseX(__hWnd__, __mouseX__); SetWindow_mouseY(__hWnd__, __mouseY__); }
+	{ SetWindow_mouseX(__hWnd__, __mouseX__); SetWindow_mouseY(__hWnd__, __mouseY__); }
 
 #define SetWindow_viewBgBrush(__hWnd__, __viewBgBrush__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush = __viewBgBrush__) : (HBRUSH)0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush = __viewBgBrush__) : (HBRUSH)0)
 
 #define GetWindow_viewBgBrush(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush : (HBRUSH)0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->viewBgBrush : (HBRUSH)0)
 
 #define SetWindow_bw(__hWnd__, __bw__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bw = __bw__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->bw = __bw__) : 0)
 
 #define GetWindow_bw(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bw : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->bw : 0)
 
 #define GetWindow_paintInfoPtr(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? &(GETLOCALWINDOWINFOPTR(__hWnd__)->paintInfo) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? &(GETLOCALWINDOWINFOPTR(__hWnd__)->paintInfo) : 0)
 
 #define SetWindow_flag(__hWnd__, __flag__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->flag = __flag__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->flag = __flag__) : 0)
 
 #define GetWindow_flag(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->flag : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? GETLOCALWINDOWINFOPTR(__hWnd__)->flag : 0)
 
 #define GetWindow_eventMask(__hWnd__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->eventMask) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->eventMask) : 0)
 
 #define SetWindow_currentMonitorWidth(__hWnd__, __width__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorWidth = __width__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorWidth = __width__) : 0)
 
 #define SetWindow_currentMonitorHeight(__hWnd__, __height__) \
-        (GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorHeight = __height__) : 0)
+	(GETLOCALWINDOWINFOPTR(__hWnd__) ? (GETLOCALWINDOWINFOPTR(__hWnd__)->currentMonitorHeight = __height__) : 0)
 
 
 struct queuedEvent {
-        struct queuedEvent     *ev_next;
-        int                     count;
-        int                     ev_flag;
-        HWND                    ev_hWnd;
-        UINT                    ev_message;
-        UINT                    ev_wParam;
-        INT                     ev_arg1;
-        INT                     ev_arg2;
-        INT                     ev_arg3;
-        INT                     ev_arg4;
-        UINT                    ev_time;
+	struct queuedEvent     *ev_next;
+	int                     count;
+	int                     ev_flag;
+	HWND                    ev_hWnd;
+	UINT                    ev_message;
+	UINT                    ev_wParam;
+	INT                     ev_arg1;
+	INT                     ev_arg2;
+	INT                     ev_arg3;
+	INT                     ev_arg4;
+	UINT                    ev_time;
 };
 
 #define ev_x    ev_arg1
@@ -935,14 +937,65 @@
 #define BITBLT_OR               SRCPAINT
 
 typedef struct registerHotKeyInfo {
-        HANDLE       hwnd;          /* in param */
-        int          hotKeyId;      /* in param */
-        unsigned int modifier;      /* in param */
-        unsigned int virtualKey;    /* in params */
-        int          finished;      /* out param */
-        int          errorCode;     /* out param */
+	HANDLE       hwnd;          /* in param */
+	int          hotKeyId;      /* in param */
+	unsigned int modifier;      /* in param */
+	unsigned int virtualKey;    /* in params */
+	int          finished;      /* out param */
+	int          errorCode;     /* out param */
 } registerHotKeyInfo;
 
+typedef struct fileDialogDataStruct {
+    wchar_t filename[MAX_PATH];
+    wchar_t title[MAX_PATH];
+    HWND owningWindow;
+    wchar_t filter[MAX_PATH];
+    int filterIndex;
+    BOOL trueForSave;
+    wchar_t targetFilename[MAX_PATH];
+
+    BOOL fileDialogDidReturn;
+} fileDialogData;
+
+DWORD WINAPI OpenFileDialog(fileDialogData *pFdd) {
+    BOOL hasResult;
+    OPENFILENAMEW ofn;
+    ZeroMemory(&ofn, sizeof(ofn));
+
+    ofn.lStructSize = sizeof(OPENFILENAMEW);
+    ofn.lpstrFile = pFdd->filename;
+    ofn.nMaxFile = MAX_PATH;
+    ofn.lpstrTitle = pFdd->title;
+    ofn.lpstrFilter = pFdd->filter;
+    ofn.nFilterIndex = pFdd->filterIndex;
+    ofn.hwndOwner = pFdd->owningWindow;
+
+    if (pFdd->trueForSave) {
+	ofn.Flags = OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
+	hasResult = GetSaveFileNameW(&ofn);
+    } else {
+	ofn.Flags = OFN_FILEMUSTEXIST;
+	hasResult = GetOpenFileNameW(&ofn);
+    }
+
+    if (!hasResult) {
+	ZeroMemory(&pFdd->filename, sizeof(pFdd->filename));
+    }
+
+    pFdd->fileDialogDidReturn = TRUE;
+
+    return 0;
+}
+
+HANDLE openFileDialogInNewThread(fileDialogData *pFdd) {
+    HANDLE fileDialogThread = CreateThread(NULL, 0, OpenFileDialog, pFdd, 0, NULL);
+    if (fileDialogThread == INVALID_HANDLE_VALUE) {
+	printf("error: could not create thread for native file dialog: %d\n", GetLastError());
+    }
+
+    return fileDialogThread;
+}
+
 %}
 ! !
 
@@ -1102,82 +1155,82 @@
 #ifdef DEBUGMASK
 static void
 printMask(int mask) {
-        if (mask & KeyPressMask)        console_printf("KeyPressMask\n");
-        if (mask & KeyReleaseMask)      console_printf("KeyReleaseMask\n");
-        if (mask & ButtonPressMask)     console_printf("ButtonPressMask\n");
-        if (mask & ButtonReleaseMask)   console_printf("ButtonReleaseMask\n");
-        if (mask & ButtonMotionMask)    console_printf("ButtonMotionMask\n");
-        if (mask & PointerMotionMask)   console_printf("PointerMotionMask\n");
-        if (mask & ExposureMask)        console_printf("ExposureMask\n");
-        if (mask & FocusChangeMask)     console_printf("FocusChangeMask\n");
-        if (mask & EnterWindowMask)     console_printf("EnterWindowMask\n");
-        if (mask & LeaveWindowMask)     console_printf("LeaveWindowMask\n");
-        if (mask & KeymapStateMask)     console_printf("KeymapStateMask\n");
-        if (mask & VisibilityChangeMask)console_printf("VisibilityChangeMask\n");
-        if (mask & StructureNotifyMask) console_printf("StructureNotifyMask\n");
-        if (mask & ResizeRedirectMask)  console_printf("ResizeRedirectMask\n");
-        if (mask & PropertyChangeMask)  console_printf("PropertyChangeMask\n");
-        if (mask & ColormapChangeMask)  console_printf("ColormapChangeMask\n");
+	if (mask & KeyPressMask)        console_printf("KeyPressMask\n");
+	if (mask & KeyReleaseMask)      console_printf("KeyReleaseMask\n");
+	if (mask & ButtonPressMask)     console_printf("ButtonPressMask\n");
+	if (mask & ButtonReleaseMask)   console_printf("ButtonReleaseMask\n");
+	if (mask & ButtonMotionMask)    console_printf("ButtonMotionMask\n");
+	if (mask & PointerMotionMask)   console_printf("PointerMotionMask\n");
+	if (mask & ExposureMask)        console_printf("ExposureMask\n");
+	if (mask & FocusChangeMask)     console_printf("FocusChangeMask\n");
+	if (mask & EnterWindowMask)     console_printf("EnterWindowMask\n");
+	if (mask & LeaveWindowMask)     console_printf("LeaveWindowMask\n");
+	if (mask & KeymapStateMask)     console_printf("KeymapStateMask\n");
+	if (mask & VisibilityChangeMask)console_printf("VisibilityChangeMask\n");
+	if (mask & StructureNotifyMask) console_printf("StructureNotifyMask\n");
+	if (mask & ResizeRedirectMask)  console_printf("ResizeRedirectMask\n");
+	if (mask & PropertyChangeMask)  console_printf("PropertyChangeMask\n");
+	if (mask & ColormapChangeMask)  console_printf("ColormapChangeMask\n");
 }
 #endif
 
 static int
 st2RGB(int color, struct gcData *gcData)
 {
-        if (gcData && gcData->bitmapColorBitCount == 1) {
-            return (color ? WhitePixel : BlackPixel);
-        }
+	if (gcData && gcData->bitmapColorBitCount == 1) {
+	    return (color ? WhitePixel : BlackPixel);
+	}
 #ifdef ALWAYSTRUECOLOR
-        return (color & 0xffffff);
-#else
-        if (__depth < 15) {
-            return 0;
-        } else {
-            if ((__depth == 16) || (__depth == 15)) {
-                int ib = (color & 0x1f) << 3;
-                int ig = ((color >> 5) & 0x3f) << 2;
-                int ir = ((color >> 11) & 0x1f) << 3;
-                ir |= 7;
-                ig |= 3;
-                ib |= 7;
-                return RGB(ir,ig,ib);
-            }
-            return (color & 0xffffff);
-        }
+	return (color & 0xffffff);
+#else
+	if (__depth < 15) {
+	    return 0;
+	} else {
+	    if ((__depth == 16) || (__depth == 15)) {
+		int ib = (color & 0x1f) << 3;
+		int ig = ((color >> 5) & 0x3f) << 2;
+		int ir = ((color >> 11) & 0x1f) << 3;
+		ir |= 7;
+		ig |= 3;
+		ib |= 7;
+		return RGB(ir,ig,ib);
+	    }
+	    return (color & 0xffffff);
+	}
 #endif
 }
 
 static int
 RGB2st(int r, int g, int b)
 {
-        int ir,ig,ib,id;
+	int ir,ig,ib,id;
 
 #ifdef ALWAYSTRUECOLOR
-        ir = (r >> 8) & 0xff;
-        ig = (g >> 8) & 0xff;
-        ib = (b >> 8) & 0xff;
-
-        id = RGB( ir, ig, ib);
-#else
-        if (__depth < 15) {
-            id = 0;
-        } else {
-            if ((__depth == 16) || (__depth == 15)) {
-                ir = (r >> 11) & 0x1f;
-                ig = (g >> 10) & 0x3f;
-                ib = (b >> 11) & 0x1f;
-
-                id = ( ir << 11 ) | ( ig << 5 ) | ib;
-            } else {
-                ir = (r >> 8) & 0xff;
-                ig = (g >> 8) & 0xff;
-                ib = (b >> 8) & 0xff;
-
-                id = RGB( ir, ig, ib);
-            }
-        }
-#endif
-        return id;
+	ir = (r >> 8) & 0xff;
+	ig = (g >> 8) & 0xff;
+	ib = (b >> 8) & 0xff;
+
+	id = RGB( ir, ig, ib);
+#else
+	if (__depth < 15) {
+	    id = 0;
+	} else {
+	    if ((__depth == 16) || (__depth == 15)) {
+		ir = (r >> 11) & 0x1f;
+		ig = (g >> 10) & 0x3f;
+		ib = (b >> 11) & 0x1f;
+
+		id = ( ir << 11 ) | ( ig << 5 ) | ib;
+	    } else {
+		ir = (r >> 8) & 0xff;
+		ig = (g >> 8) & 0xff;
+		ib = (b >> 8) & 0xff;
+
+		id = RGB( ir, ig, ib);
+	    }
+	}
+#endif
+	return id;
 }
 
 #if 0
@@ -1187,13 +1240,13 @@
 static HWND
 GetTopParent(HWND hwnd)
 {
-        HWND lastParent = hWnd;
-        HWND nextParent;
-
-        while (nextParent = GetParent(lastParent)) {
-            lastParent = nextParent;
-        }
-        return lastParent;
+	HWND lastParent = hWnd;
+	HWND nextParent;
+
+	while (nextParent = GetParent(lastParent)) {
+	    lastParent = nextParent;
+	}
+	return lastParent;
 }
 #endif
 
@@ -1205,7 +1258,7 @@
     int r = DeleteObject(o);
 
     if (r == 0)
-        console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteObject %x [%d]\n", o, lineNr);
+	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteObject %x [%d]\n", o, lineNr);
     return r;
 }
 
@@ -1218,8 +1271,8 @@
 {
 #ifdef CACHE_LAST_TMP_FONT
     if (f == __tmpDC_hfont) {
-        SelectObject(__tmpDC, __tmpDC_prev_hfont);
-        __tmpDC_hfont = NULL;
+	SelectObject(__tmpDC, __tmpDC_prev_hfont);
+	__tmpDC_hfont = NULL;
     }
 #endif
     _DeleteObject(f, lineNr);
@@ -1229,11 +1282,11 @@
 _DeleteBrush(HBRUSH br, int lineNr)
 {
     if ((br != __whiteBrush) && (br != __blackBrush)) {
-        int r = DeleteObject(br);
-
-        if (r == 0)
-            console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush %x [%d]\n", br, lineNr);
-        return r;
+	int r = DeleteObject(br);
+
+	if (r == 0)
+	    console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush %x [%d]\n", br, lineNr);
+	return r;
     }
     return 1;
 }
@@ -1242,11 +1295,11 @@
 _DeletePen(HPEN p, int lineNr)
 {
     if ((p != __whitePen) && (p != __blackPen)) {
-        int r = DeleteObject(p);
-
-        if (r == 0)
-            console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen %x [%d]\n", p, lineNr);
-        return r;
+	int r = DeleteObject(p);
+
+	if (r == 0)
+	    console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen %x [%d]\n", p, lineNr);
+	return r;
     }
     return 1;
 }
@@ -1259,17 +1312,17 @@
     int i, r;
 
     if ((p == __whitePen) || (p == __blackPen)) {
-        return 1; /* not deleted, but OK */
+	return 1; /* not deleted, but OK */
     }
     for (i=0; i<NUM_PEN_CACHED;i++) {
-        if (__penCache[i].pen == p) {
-            return 1; /* not deleted, but OK */
-        }
+	if (__penCache[i].pen == p) {
+	    return 1; /* not deleted, but OK */
+	}
     }
     r = DeleteObject(p);
 
     if (r == 0)
-        console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen2 %x [%d]\n", p, lineNr);
+	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeletePen2 %x [%d]\n", p, lineNr);
     return r;
 }
 
@@ -1285,17 +1338,17 @@
     int i, r;
 
     for (i=0; i<NUM_BRUSH_CACHED;i++) {
-        if (__brushCache[i].brush == br) {
-            return 1; /* not deleted, but OK */
-        }
+	if (__brushCache[i].brush == br) {
+	    return 1; /* not deleted, but OK */
+	}
     }
     if ((br == __whiteBrush) || (br == __blackBrush)) {
-        return 1; /* not deleted, but OK */
+	return 1; /* not deleted, but OK */
     }
     r = DeleteObject(br);
 
     if (r == 0)
-        console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush2 %x [%d]\n", br, lineNr);
+	console_fprintf(stderr, "WinWorkstation [warning]: ERROR in DeleteBrush2 %x [%d]\n", br, lineNr);
     return r;
 }
 
@@ -1309,15 +1362,15 @@
     struct gcData *gcData;
 
     if (gcDataFreeList) {
-        gcData = gcDataFreeList;
-        gcDataFreeList = gcData->u.__nextFree;
-        gcDataNumFree--;
-    } else {
-        gcData = (struct gcData *) malloc(sizeof(struct gcData));
-        if (! gcData) {
-            console_fprintf(stderr, "WinWorkstat [warning]: failed to allocate gcData\n");
-            return 0;
-        }
+	gcData = gcDataFreeList;
+	gcDataFreeList = gcData->u.__nextFree;
+	gcDataNumFree--;
+    } else {
+	gcData = (struct gcData *) malloc(sizeof(struct gcData));
+	if (! gcData) {
+	    console_fprintf(stderr, "WinWorkstat [warning]: failed to allocate gcData\n");
+	    return 0;
+	}
     }
 
     memset(gcData, 0, sizeof(struct gcData));
@@ -1338,18 +1391,18 @@
 freeGcData(struct gcData *gcData)
 {
     if (gcDataNumFree < NUM_FREE_GC) {
-        gcData->u.__nextFree = gcDataFreeList;
-        gcDataFreeList = gcData;
-        gcDataNumFree++;
-    } else {
-        free(gcData);
+	gcData->u.__nextFree = gcDataFreeList;
+	gcDataFreeList = gcData;
+	gcDataNumFree++;
+    } else {
+	free(gcData);
     }
 }
 
 #ifdef CACHE_LAST_DC
 # define FLUSH_CACHED_DC(__gcData__) \
     if (lastGcData == __gcData__) {  \
-        _releaseDC(lastGcData);      \
+	_releaseDC(lastGcData);      \
     }
 #else
 # define FLUSH_CACHED_DC(x)     /* */
@@ -1358,12 +1411,12 @@
 #ifdef CACHE_LAST_PEN
 # define FLUSH_CACHED_PEN(__gcData__) \
     if (__gcData__->hPen) {           \
-        if (__gcData__->save_hPen) {  \
-            SelectObject(__gcData__->_hDC, __gcData__->save_hPen); \
-            __gcData__->save_hPen = 0;   \
-        } \
-        _DeletePenIfNotInCache(__gcData__->hPen, __LINE__); \
-        __gcData__->hPen = 0; \
+	if (__gcData__->save_hPen) {  \
+	    SelectObject(__gcData__->_hDC, __gcData__->save_hPen); \
+	    __gcData__->save_hPen = 0;   \
+	} \
+	_DeletePenIfNotInCache(__gcData__->hPen, __LINE__); \
+	__gcData__->hPen = 0; \
     }
 #else
 # define FLUSH_CACHED_PEN(x)    /* */
@@ -1372,12 +1425,12 @@
 #ifdef CACHE_LAST_BRUSH
 # define FLUSH_CACHED_BRUSH(__gcData__) \
     if (__gcData__->hBrush) {           \
-        if (__gcData__->save_hBrush) {  \
-            SelectObject(__gcData__->_hDC, __gcData__->save_hBrush); \
-            __gcData__->save_hBrush = 0;   \
-        } \
-        _DeleteBrushIfNotInCache(__gcData__->hBrush, __LINE__); \
-        __gcData__->hBrush = 0; \
+	if (__gcData__->save_hBrush) {  \
+	    SelectObject(__gcData__->_hDC, __gcData__->save_hBrush); \
+	    __gcData__->save_hBrush = 0;   \
+	} \
+	_DeleteBrushIfNotInCache(__gcData__->hBrush, __LINE__); \
+	__gcData__->hBrush = 0; \
     }
 #else
 # define FLUSH_CACHED_BRUSH(x)    /* */
@@ -1389,55 +1442,55 @@
     HDC hDC = gcData->_hDC;
 
     if (gcData->doNotCacheOrRelease ) {
-        return;
+	return;
     }
 
     if (gcData->save_hPen) {
-        SelectObject(hDC, gcData->save_hPen);
-        gcData->save_hPen = 0;
+	SelectObject(hDC, gcData->save_hPen);
+	gcData->save_hPen = 0;
     }
     if (gcData->save_hBrush) {
-        SelectObject(hDC, gcData->save_hBrush);
-        gcData->save_hBrush = 0;
+	SelectObject(hDC, gcData->save_hBrush);
+	gcData->save_hBrush = 0;
     }
     if (gcData->save_hFont) {
-        SelectObject(hDC, gcData->save_hFont);
-        gcData->save_hFont = 0;
+	SelectObject(hDC, gcData->save_hFont);
+	gcData->save_hFont = 0;
     }
 
     if (gcData->hWnd) {
-        if (hDC) {
-            ReleaseDC(gcData->hWnd, hDC);
+	if (hDC) {
+	    ReleaseDC(gcData->hWnd, hDC);
 #ifdef CACHE_LAST_WM_PAINT_DC
-            if (hDC == last_wm_paint_dc) {
-                last_wm_paint_dc = last_wm_paint_win = 0;
+	    if (hDC == last_wm_paint_dc) {
+		last_wm_paint_dc = last_wm_paint_win = 0;
 # ifdef DEBUG_DC_REUSE
-                console_fprintf(stderr, "WinWorkstation [info]: Oops - releasing bg_paint-dc\n");
-# endif
-            }
-#endif
-        }
+		console_fprintf(stderr, "WinWorkstation [info]: Oops - releasing bg_paint-dc\n");
+# endif
+	    }
+#endif
+	}
     } else if (gcData->hBitmap) {
-        SelectObject(hDC, gcData->save_hBitmap);
-        DeleteDC(hDC);
+	SelectObject(hDC, gcData->save_hBitmap);
+	DeleteDC(hDC);
     }
     gcData->_hDC = 0;
 
 #ifdef CACHE_LAST_DC
     if (lastGcData == gcData) {
-        lastGcData = 0;
+	lastGcData = 0;
     }
 #endif
 #ifdef CACHE_LAST_PEN
     if (gcData->hPen) {
-        _DeletePenIfNotInCache(gcData->hPen, __LINE__);
-        gcData->hPen = 0;
+	_DeletePenIfNotInCache(gcData->hPen, __LINE__);
+	gcData->hPen = 0;
     }
 #endif
 #ifdef CACHE_LAST_BRUSH
     if (gcData->hBrush) {
-        _DeleteBrushIfNotInCache(gcData->hBrush, __LINE__);
-        gcData->hBrush = 0;
+	_DeleteBrushIfNotInCache(gcData->hBrush, __LINE__);
+	gcData->hBrush = 0;
     }
 #endif
 }
@@ -1449,82 +1502,82 @@
     int currThreadId;
 
     if (gcData->doNotCacheOrRelease ) {
-        return gcData->_hDC;
+	return gcData->_hDC;
     }
 
 #ifdef CACHE_LAST_DC
     currThreadId = GetCurrentThreadId();
 
     if (lastGcData) {
-        if ((lastGcData == gcData)
-         && (lastGcHWIN == gcData->hWnd)
-         && (lastGcHBITMAP == gcData->hBitmap)
-         && (lastGcOwnerThreadID == currThreadId)
-         && gcData->_hDC
-        ) {
+	if ((lastGcData == gcData)
+	 && (lastGcHWIN == gcData->hWnd)
+	 && (lastGcHBITMAP == gcData->hBitmap)
+	 && (lastGcOwnerThreadID == currThreadId)
+	 && gcData->_hDC
+	) {
 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
-            if (last_wm_paint_dc == gcData->_hDC) {
+	    if (last_wm_paint_dc == gcData->_hDC) {
 #  ifdef DEBUG_DC_REUSE
-                console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
+		console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
 #  endif
-                last_wm_paint_dc = last_wm_paint_win = 0;
-            }
-# endif
-            return gcData->_hDC;
-        }
-
-        _releaseDC(lastGcData);
-        lastGcData = 0;
+		last_wm_paint_dc = last_wm_paint_win = 0;
+	    }
+# endif
+	    return gcData->_hDC;
+	}
+
+	_releaseDC(lastGcData);
+	lastGcData = 0;
     }
 #endif
 
     hDC = 0;
     if (gcData->hWnd != 0) {
-        if (gcData->hWnd == __rootWin) {
-            hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_WINDOW);
-        } else if (gcData->clipByChildren) {
-            //gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_CLIPCHILDREN);
-            hDC = gcData->_hDC = GetDC(gcData->hWnd);
-        } else  {
-            hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_PARENTCLIP);
-        }
+	if (gcData->hWnd == __rootWin) {
+	    hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_WINDOW);
+	} else if (gcData->clipByChildren) {
+	    //gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_CLIPCHILDREN);
+	    hDC = gcData->_hDC = GetDC(gcData->hWnd);
+	} else  {
+	    hDC = gcData->_hDC = GetDCEx(gcData->hWnd, 0, DCX_PARENTCLIP);
+	}
     } else if (gcData->hBitmap) {
-        hDC = gcData->_hDC = CreateCompatibleDC(__tmpDC);
-        gcData->save_hBitmap = SelectObject(gcData->_hDC,gcData->hBitmap);
+	hDC = gcData->_hDC = CreateCompatibleDC(__tmpDC);
+	gcData->save_hBitmap = SelectObject(gcData->_hDC,gcData->hBitmap);
     }
     gcData->bkMode = BK_UNDEF;
 
     if (hDC) {
-        SetTextColor(hDC, gcData->fgColor);
-        SetBkColor(hDC, gcData->bgColor);
-
-        if (gcData->rop2)
-            SetROP2(hDC, gcData->rop2);
-
-        if (gcData->clipping) {
-            HRGN region = CreateRectRgn( gcData->clipX, gcData->clipY,
-                                         gcData->clipX + gcData->clipW,
-                                         gcData->clipY + gcData->clipH);
-            if (region == NULL ) {
-                console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
-            } else {
-                if (SelectClipRgn(hDC, region) == ERROR ) {
-                    DPRINTF(("WinWorkstat [warning]: select clipping region failed\n" ));
-                }
-                _DeleteObject(region, __LINE__);
-            }
-        } else {
-            SelectClipRgn(hDC, NULL);
-        }
-
-        if (gcData->hFont) {
-            HFONT prevFont;
-
-            prevFont = SelectObject(hDC, gcData->hFont);
-            if (! gcData->save_hFont) {
-                gcData->save_hFont = prevFont;
-            }
-        }
+	SetTextColor(hDC, gcData->fgColor);
+	SetBkColor(hDC, gcData->bgColor);
+
+	if (gcData->rop2)
+	    SetROP2(hDC, gcData->rop2);
+
+	if (gcData->clipping) {
+	    HRGN region = CreateRectRgn( gcData->clipX, gcData->clipY,
+					 gcData->clipX + gcData->clipW,
+					 gcData->clipY + gcData->clipH);
+	    if (region == NULL ) {
+		console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
+	    } else {
+		if (SelectClipRgn(hDC, region) == ERROR ) {
+		    DPRINTF(("WinWorkstat [warning]: select clipping region failed\n" ));
+		}
+		_DeleteObject(region, __LINE__);
+	    }
+	} else {
+	    SelectClipRgn(hDC, NULL);
+	}
+
+	if (gcData->hFont) {
+	    HFONT prevFont;
+
+	    prevFont = SelectObject(hDC, gcData->hFont);
+	    if (! gcData->save_hFont) {
+		gcData->save_hFont = prevFont;
+	    }
+	}
     }
 
 #ifdef CACHE_LAST_DC
@@ -1538,9 +1591,9 @@
 # ifdef CACHE_LAST_WM_PAINT_DC /* DDD */
     if (last_wm_paint_dc == hDC) {
 #  ifdef DEBUG_DC_REUSE
-        console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
+	console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
 #  endif
-        last_wm_paint_dc = last_wm_paint_win = 0;
+	last_wm_paint_dc = last_wm_paint_win = 0;
     }
 # endif
 #endif
@@ -1556,62 +1609,62 @@
 
 #ifdef CACHE_LAST_BRUSH
     if (hBrush = gcData->hBrush) {
-        if (! gcData->save_hBrush) {
-            gcData->save_hBrush = SelectObject(gcData->_hDC, hBrush);
-        }
-        return hBrush;
+	if (! gcData->save_hBrush) {
+	    gcData->save_hBrush = SelectObject(gcData->_hDC, hBrush);
+	}
+	return hBrush;
     }
 #endif
     if (gcData->hMask) {
-        hBrush = CreatePatternBrush(gcData->hMask);
-        SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
-        RESPRINTF(("CreatePatternBrush %x\n",gcData->hMask));
-    } else {
-        if (gcData->fgColor == BlackPixel) {
-            hBrush = __blackBrush;
-        } else if (gcData->fgColor == WhitePixel) {
-            hBrush = __whiteBrush;
-        } else {
+	hBrush = CreatePatternBrush(gcData->hMask);
+	SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
+	RESPRINTF(("CreatePatternBrush %x\n",gcData->hMask));
+    } else {
+	if (gcData->fgColor == BlackPixel) {
+	    hBrush = __blackBrush;
+	} else if (gcData->fgColor == WhitePixel) {
+	    hBrush = __whiteBrush;
+	} else {
 #ifdef CACHE_BRUSH
-            {
-                int i;
-
-                for (i=0; i<NUM_BRUSH_CACHED; i++) {
-                    if (__brushCache[i].clr == gcData->fgColor) {
-                        hBrush = __brushCache[i].brush;
-                        /*
-                         * move it up in the cache
-                         */
-                        if (i > 0) {
-                            HBRUSH t = __brushCache[i-1].brush;
-                            int c = __brushCache[i-1].clr;
-
-                            __brushCache[i-1].brush = hBrush;
-                            __brushCache[i-1].clr = gcData->fgColor;
-                            __brushCache[i].brush = t;
-                            __brushCache[i].clr = c;
-                        }
+	    {
+		int i;
+
+		for (i=0; i<NUM_BRUSH_CACHED; i++) {
+		    if (__brushCache[i].clr == gcData->fgColor) {
+			hBrush = __brushCache[i].brush;
+			/*
+			 * move it up in the cache
+			 */
+			if (i > 0) {
+			    HBRUSH t = __brushCache[i-1].brush;
+			    int c = __brushCache[i-1].clr;
+
+			    __brushCache[i-1].brush = hBrush;
+			    __brushCache[i-1].clr = gcData->fgColor;
+			    __brushCache[i].brush = t;
+			    __brushCache[i].clr = c;
+			}
 # ifdef CACHE_LAST_BRUSH
-                        prevBrush = SelectObject(gcData->_hDC, hBrush);
-                        if (! gcData->save_hBrush) {
-                            gcData->save_hBrush = prevBrush;
-                        }
-                        gcData->hBrush = hBrush;
-# endif
-                        return hBrush;
-                    }
-                }
-            }
+			prevBrush = SelectObject(gcData->_hDC, hBrush);
+			if (! gcData->save_hBrush) {
+			    gcData->save_hBrush = prevBrush;
+			}
+			gcData->hBrush = hBrush;
+# endif
+			return hBrush;
+		    }
+		}
+	    }
 #endif /* BRUSH_CACHE */
-            hBrush = CreateSolidBrush(gcData->fgColor);
-            RESPRINTF(("CreateSolidBrush %x\n",gcData->fgColor));
-        }
+	    hBrush = CreateSolidBrush(gcData->fgColor);
+	    RESPRINTF(("CreateSolidBrush %x\n",gcData->fgColor));
+	}
     }
     gcData->hBrush = hBrush;
 
     prevBrush = SelectObject(gcData->_hDC, hBrush);
     if (! gcData->save_hBrush) {
-        gcData->save_hBrush = prevBrush;
+	gcData->save_hBrush = prevBrush;
     }
     return hBrush;
 }
@@ -1625,8 +1678,8 @@
     HBRUSH hBrush = gcData->hBrush;
 
     if (gcData->save_hBrush) {
-        SelectObject(hDC, gcData->save_hBrush);
-        gcData->save_hBrush = NULL;
+	SelectObject(hDC, gcData->save_hBrush);
+	gcData->save_hBrush = NULL;
     }
     _DeleteBrushIfNotInCache(hBrush, __LINE__);
     gcData->hBrush = 0;
@@ -1643,69 +1696,69 @@
 
 #ifdef CACHE_LAST_PEN
     if (hPen = gcData->hPen) {
-        if (! gcData->save_hPen) {
-            gcData->save_hPen = SelectObject(gcData->_hDC, hPen);
-        }
-        return hPen;
+	if (! gcData->save_hPen) {
+	    gcData->save_hPen = SelectObject(gcData->_hDC, hPen);
+	}
+	return hPen;
     }
 #endif
 
     if (((gcData->lStyle & PS_STYLE_MASK) == PS_SOLID)
      && (gcData->hMask == 0)
      && (gcData->lineWidth <= 1)) {
-        if (gcData->fgColor == BlackPixel) {
-            gcData->hPen = hPen = __blackPen;
-            prevPen = SelectObject(hDC, hPen);
-            if (! gcData->save_hPen) {
-                gcData->save_hPen = prevPen;
-            }
-            return hPen;
-        }
-        if (gcData->fgColor == WhitePixel) {
-            gcData->hPen = hPen = __whitePen;
-            prevPen = SelectObject(hDC, hPen);
-            if (! gcData->save_hPen) {
-                gcData->save_hPen = prevPen;
-            }
-            return hPen;
-        }
+	if (gcData->fgColor == BlackPixel) {
+	    gcData->hPen = hPen = __blackPen;
+	    prevPen = SelectObject(hDC, hPen);
+	    if (! gcData->save_hPen) {
+		gcData->save_hPen = prevPen;
+	    }
+	    return hPen;
+	}
+	if (gcData->fgColor == WhitePixel) {
+	    gcData->hPen = hPen = __whitePen;
+	    prevPen = SelectObject(hDC, hPen);
+	    if (! gcData->save_hPen) {
+		gcData->save_hPen = prevPen;
+	    }
+	    return hPen;
+	}
 
 #ifdef CACHE_PEN
-        {
-            int i;
-
-            for (i=0; i<NUM_PEN_CACHED; i++) {
-                if (__penCache[i].clr == gcData->fgColor) {
-                    hPen = __penCache[i].pen;
-                    /*
-                     * move it up in the cache
-                     */
-                    if (i > 0) {
-                        HPEN t = __penCache[i-1].pen;
-                        int c = __penCache[i-1].clr;
-
-                        __penCache[i-1].pen = hPen;
-                        __penCache[i-1].clr = gcData->fgColor;
-                        __penCache[i].pen = t;
-                        __penCache[i].clr = c;
-                    }
-
-                    gcData->hPen = hPen;
-                    prevPen = SelectObject(hDC, hPen);
-                    if (! gcData->save_hPen) {
-                        gcData->save_hPen = prevPen;
-                    }
-                    return hPen;
-                }
-            }
-        }
+	{
+	    int i;
+
+	    for (i=0; i<NUM_PEN_CACHED; i++) {
+		if (__penCache[i].clr == gcData->fgColor) {
+		    hPen = __penCache[i].pen;
+		    /*
+		     * move it up in the cache
+		     */
+		    if (i > 0) {
+			HPEN t = __penCache[i-1].pen;
+			int c = __penCache[i-1].clr;
+
+			__penCache[i-1].pen = hPen;
+			__penCache[i-1].clr = gcData->fgColor;
+			__penCache[i].pen = t;
+			__penCache[i].clr = c;
+		    }
+
+		    gcData->hPen = hPen;
+		    prevPen = SelectObject(hDC, hPen);
+		    if (! gcData->save_hPen) {
+			gcData->save_hPen = prevPen;
+		    }
+		    return hPen;
+		}
+	    }
+	}
 #endif /* PEN_CACHE */
     }
 
     hPen = (HPEN) 0;
     lw = gcData->lineWidth;
     if (lw == 0) {
-        lw = 1;
+	lw = 1;
     }
 
     /*
@@ -1713,49 +1766,49 @@
      * and also non-solid lines with any lineWidth.
      */
     if (gcData->hMask) {
-        Brush.lbStyle = BS_PATTERN;
-        Brush.lbHatch = (ULONG_PTR)(gcData->hMask);
-        Brush.lbColor = gcData->fgColor;
-    } else {
-        Brush.lbStyle = BS_SOLID;
-        Brush.lbHatch = (ULONG_PTR)0;
-        Brush.lbColor = gcData->fgColor;
-
-        hPen = (HPEN) 0;
+	Brush.lbStyle = BS_PATTERN;
+	Brush.lbHatch = (ULONG_PTR)(gcData->hMask);
+	Brush.lbColor = gcData->fgColor;
+    } else {
+	Brush.lbStyle = BS_SOLID;
+	Brush.lbHatch = (ULONG_PTR)0;
+	Brush.lbColor = gcData->fgColor;
+
+	hPen = (HPEN) 0;
 
 #if USE_OLD_CREATE_PEN
-        hPen = CreatePen((gcData->lStyle & PS_STYLE_MASK), lw, gcData->fgColor);
-
-        RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
-                    gcData->lStyle,
-                    lw, gcData->lineWidth,
-                    gcData->fgColor, gcData->hMask));
-#endif
-
-        SetBkMode(hDC, TRANSPARENT);
-        gcData->bkMode = BK_TRANSPARENT;
-
-        if (! hPen) {
-            hPen = ExtCreatePen(PS_GEOMETRIC | gcData->lStyle,
-                            lw, /* gcData->lineWidth, */
-                            &Brush,
-                            0, 0);
-
-            RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
-                        gcData->lStyle,
-                        lw, gcData->lineWidth,
-                        gcData->fgColor, gcData->hMask));
-
-            if (gcData->hMask) {
-                SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
-            }
-        }
+	hPen = CreatePen((gcData->lStyle & PS_STYLE_MASK), lw, gcData->fgColor);
+
+	RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
+		    gcData->lStyle,
+		    lw, gcData->lineWidth,
+		    gcData->fgColor, gcData->hMask));
+#endif
+
+	SetBkMode(hDC, TRANSPARENT);
+	gcData->bkMode = BK_TRANSPARENT;
+
+	if (! hPen) {
+	    hPen = ExtCreatePen(PS_GEOMETRIC | gcData->lStyle,
+			    lw, /* gcData->lineWidth, */
+			    &Brush,
+			    0, 0);
+
+	    RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
+			gcData->lStyle,
+			lw, gcData->lineWidth,
+			gcData->fgColor, gcData->hMask));
+
+	    if (gcData->hMask) {
+		SetBrushOrgEx(hDC, gcData->maskOrgX, gcData->maskOrgY, 0);
+	    }
+	}
     }
 
     gcData->hPen = hPen;
     prevPen = SelectObject(hDC, hPen);
     if (! gcData->save_hPen) {
-        gcData->save_hPen = prevPen;
+	gcData->save_hPen = prevPen;
     }
 
 #ifdef CACHE_PEN
@@ -1765,28 +1818,28 @@
     if (((gcData->lStyle & PS_STYLE_MASK) == PS_SOLID)
      && (gcData->hMask == 0)
      && (gcData->lineWidth <= 1)) {
-        int i;
-
-        /*
-         * search for an empty slot
-         */
-        for (i=0; i<NUM_PEN_CACHED; i++) {
-            if (__penCache[i].pen == 0) {
-                __penCache[i].clr = gcData->fgColor;
-                __penCache[i].pen = hPen;
-                break;
-            }
-        }
-        if (i == NUM_PEN_CACHED) {
-            /*
-             * replace last in penCache
-             */
-            HPEN t = __penCache[NUM_PEN_CACHED - 1].pen;
-
-            __penCache[NUM_PEN_CACHED - 1].pen = hPen;
-            __penCache[NUM_PEN_CACHED - 1].clr = gcData->fgColor;
-            _DeletePen(t, __LINE__);
-        }
+	int i;
+
+	/*
+	 * search for an empty slot
+	 */
+	for (i=0; i<NUM_PEN_CACHED; i++) {
+	    if (__penCache[i].pen == 0) {
+		__penCache[i].clr = gcData->fgColor;
+		__penCache[i].pen = hPen;
+		break;
+	    }
+	}
+	if (i == NUM_PEN_CACHED) {
+	    /*
+	     * replace last in penCache
+	     */
+	    HPEN t = __penCache[NUM_PEN_CACHED - 1].pen;
+
+	    __penCache[NUM_PEN_CACHED - 1].pen = hPen;
+	    __penCache[NUM_PEN_CACHED - 1].clr = gcData->fgColor;
+	    _DeletePen(t, __LINE__);
+	}
     }
 #endif
 
@@ -1802,8 +1855,8 @@
     HPEN hPen;
 
     if (gcData->save_hPen) {
-        SelectObject(hDC, gcData->save_hPen);
-        gcData->save_hPen = NULL;
+	SelectObject(hDC, gcData->save_hPen);
+	gcData->save_hPen = NULL;
     }
     hPen = gcData->hPen;
     _DeletePenIfNotInCache(hPen, __LINE__);
@@ -1821,36 +1874,36 @@
 #ifdef LOCK_DEBUG
     lockCountEvents++;
     if (lockCountEvents != 1) {
-        console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 1 in lock\n", lockCountEvents);
-        lockCountEvents = 1;
+	console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 1 in lock\n", lockCountEvents);
+	lockCountEvents = 1;
     }
 #endif
 
     switch (dwWaitResult) {
-        case WAIT_OBJECT_0:
-            hEventsMutexOwner = whoIsLocking;
-            return (TRUE);
-
-        case WAIT_ABANDONED:
-            console_fprintf(stderr, "WinWorkstation [warning]: lockEvent abandoned (was owned by %s)\n",
-                        (hEventsMutexOwner ? hEventsMutexOwner : "NONE"));
-            hEventsMutexOwner = whoIsLocking;
-            return (TRUE);
-
-        case WAIT_TIMEOUT:
-            console_fprintf(stderr, "WinWorkstation [warning]: lockEvent timeout (owned by %s)\n",
-                        (hEventsMutexOwner ? hEventsMutexOwner : "NONE") );
-            break;
-
-        default:
-            {
-                unsigned errCode = GetLastError();
-
-                console_fprintf(stderr, "WinWorkstation [error]: lockEvent error (owned by %s) rslt=0x%x err=0x%x\n",
-                            (hEventsMutexOwner ? hEventsMutexOwner : "NONE"),
-                            dwWaitResult, errCode );
-            }
-            break;
+	case WAIT_OBJECT_0:
+	    hEventsMutexOwner = whoIsLocking;
+	    return (TRUE);
+
+	case WAIT_ABANDONED:
+	    console_fprintf(stderr, "WinWorkstation [warning]: lockEvent abandoned (was owned by %s)\n",
+			(hEventsMutexOwner ? hEventsMutexOwner : "NONE"));
+	    hEventsMutexOwner = whoIsLocking;
+	    return (TRUE);
+
+	case WAIT_TIMEOUT:
+	    console_fprintf(stderr, "WinWorkstation [warning]: lockEvent timeout (owned by %s)\n",
+			(hEventsMutexOwner ? hEventsMutexOwner : "NONE") );
+	    break;
+
+	default:
+	    {
+		unsigned errCode = GetLastError();
+
+		console_fprintf(stderr, "WinWorkstation [error]: lockEvent error (owned by %s) rslt=0x%x err=0x%x\n",
+			    (hEventsMutexOwner ? hEventsMutexOwner : "NONE"),
+			    dwWaitResult, errCode );
+	    }
+	    break;
     }
     return (FALSE);
 }
@@ -1860,8 +1913,8 @@
 #ifdef LOCK_DEBUG
     lockCountEvents--;
     if (lockCountEvents != 0) {
-        console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 0 in unlock\n", lockCountEvents);
-        lockCountEvents = 0;
+	console_fprintf(stderr, "WinWorkstation [warning]: lockCountEvents (%d) != 0 in unlock\n", lockCountEvents);
+	lockCountEvents = 0;
     }
 #endif
     if (! ReleaseMutex(hEventsMutex)) {
@@ -1881,11 +1934,11 @@
 
     bulk = (struct queuedEvent *) malloc(EV_CHUNK_SZ);
     if (bulk == 0) {
-        console_fprintf(stderr, "WinWorkstation [warning]: no memory for dispatchqueue\n");
-        return 0;
+	console_fprintf(stderr, "WinWorkstation [warning]: no memory for dispatchqueue\n");
+	return 0;
     }
     for (i=1; i<EV_CHUNK_CNT; i++) {
-        bulk[i-1].ev_next = &(bulk[i]);
+	bulk[i-1].ev_next = &(bulk[i]);
     }
     bulk[EV_CHUNK_CNT-1].ev_next = (struct queuedEvent *)0;
     eventFreeList = bulk;
@@ -1907,25 +1960,25 @@
     /* get an event struct
     */
     while (! eventFreeList) {
-        if (repeatCount++ >= 5) {
-            /* throw away sorry */
-            console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
-            return;
-        }
-        console_fprintf(stderr, "WinWorkstation [warning]: wait for event memory (%d)\n", repeatCount);
-        WaitForSingleObject( hNeverTriggered, 100L );
+	if (repeatCount++ >= 5) {
+	    /* throw away sorry */
+	    console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
+	    return;
+	}
+	console_fprintf(stderr, "WinWorkstation [warning]: wait for event memory (%d)\n", repeatCount);
+	WaitForSingleObject( hNeverTriggered, 100L );
     }
     if (! lockEvents("enqEvent")) {
-        console_fprintf(stderr, "WinWorkstation [error]: event throw away (lock problem)\n");
-        return;
+	console_fprintf(stderr, "WinWorkstation [error]: event throw away (lock problem)\n");
+	return;
     }
 
     ev = eventFreeList;
 
     if (! ev) {
-        console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
-        unlockEvents();
-        return;
+	console_fprintf(stderr, "WinWorkstation [error]: event throw away (memory problem)\n");
+	unlockEvents();
+	return;
     }
     eventFreeList  = ev->ev_next;
     ev->ev_flag    = flag;
@@ -1941,16 +1994,16 @@
     ev->ev_next    = (struct queuedEvent *) 0;
 
     if (eventQueueTail) {
-        eventQueueTail->ev_next = ev;
-    } else {
-        eventQueueHead = ev;
+	eventQueueTail->ev_next = ev;
+    } else {
+	eventQueueHead = ev;
     }
     eventQueueTail = ev;
 
     unlockEvents();
 
     if (eventQueueHead == ev) {
-        SetEvent(hInputEvent);
+	SetEvent(hInputEvent);
     }
 
 #if 0
@@ -1965,104 +2018,104 @@
     char * freeArg2 = NULL;
 
     if (mask != ~0) {
-        PRINTF(("deqEvent mask:%x\n",mask));
+	PRINTF(("deqEvent mask:%x\n",mask));
     }
     if (hWnd) {
-        PRINTF(("deqEvent hWnd:%x\n",hWnd));
+	PRINTF(("deqEvent hWnd:%x\n",hWnd));
     }
 
   again:
 
     if (! eventQueueHead)
-        return (0);
+	return (0);
 
     if (! lockEvents("deqEvent")) {
-        return (0);
+	return (0);
     }
 
     TH_DPRINTF(("TDEQ\n"));
     ev = eventQueueHead;
 
     if (! ev) {
-        unlockEvents();
-        return (0);
+	unlockEvents();
+	return (0);
     }
     eventQueueHead = ev->ev_next;
 
     if (! eventQueueHead) {
-        eventQueueTail = (struct queuedEvent *) 0;
+	eventQueueTail = (struct queuedEvent *) 0;
     }
 
     if (ev->count != -1) {
-        static int anyGoodEventReceived = 1;
-
-        if (eventempfcount != ev->count) {
-            if (anyGoodEventReceived) {
-                console_fprintf(stderr, "WinWorkstation [warning]: lost event (eventcount error %d <-> %d)\n",
-                                 eventempfcount, ev->count);
-            }
-            eventempfcount = ev->count;
-            anyGoodEventReceived = 0;
-        } else {
-            anyGoodEventReceived = 1;
-        }
-        eventempfcount++;
+	static int anyGoodEventReceived = 1;
+
+	if (eventempfcount != ev->count) {
+	    if (anyGoodEventReceived) {
+		console_fprintf(stderr, "WinWorkstation [warning]: lost event (eventcount error %d <-> %d)\n",
+				 eventempfcount, ev->count);
+	    }
+	    eventempfcount = ev->count;
+	    anyGoodEventReceived = 0;
+	} else {
+	    anyGoodEventReceived = 1;
+	}
+	eventempfcount++;
     }
 
     if (ev->ev_message == WM_DESTROY) {
-        /*
-         * arg2 is the localInfoPtr
-         * (which is already cleared in the wind-structure)
-         * it must be freed by the stx-process ('cause it was malloc'd by it)
-         */
-        if (ev->ev_arg2) {
-            freeArg2 = (char *) ev->ev_arg2;
-            ev->ev_arg2 = 0;
-        }
+	/*
+	 * arg2 is the localInfoPtr
+	 * (which is already cleared in the wind-structure)
+	 * it must be freed by the stx-process ('cause it was malloc'd by it)
+	 */
+	if (ev->ev_arg2) {
+	    freeArg2 = (char *) ev->ev_arg2;
+	    ev->ev_arg2 = 0;
+	}
 
 #ifdef TOPWINDOWCLASS
 
 FALSCH: nochmals in QUEUE -> (ev_arg2 != 0) arg2 freed !!!
 
-        if (ev->ev_arg1) {
-            if (UnregisterClass((char*)ev->ev_arg1,(HANDLE) __getHInstance())) {
-                /*console_printf("UnregisterClass %s ok.\n",(char*)ev->ev_arg1);*/
-
-            } else {
-                /* noch einmal in die queue
-                */
-                if (ev->ev_arg2++ < 100) {
-                    ev->ev_next = (struct queuedEvent *)0;
-                    ev->count   = eventsendcount++;
-
-                    if (eventQueueTail) {
-                        eventQueueTail->ev_next = ev;
-                    } else {
-                        eventQueueHead = ev;
-                    }
-                    eventQueueTail = ev;
-                    unlockEvents();
-
-                    if (freeArg2) {
-                        free (freeArg2);
-                        freeArg2 = NULL;
-                    }
-
-                    if (ev->ev_arg2 > 98) {
-                        console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed. Wait 1 sec.\n",(char*)ev->ev_arg1);
-                        sleep(1);
-                    } else {
-                        sleep(0);
-                    }
-                    goto again;
-                }
-                /* fail evtl. später ändern und in st verzögert aufrufen
-                */
-                console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
-            }
-            free((char*)ev->ev_arg1);
-            ev->ev_arg1 = 0;
-        }
+	if (ev->ev_arg1) {
+	    if (UnregisterClass((char*)ev->ev_arg1,(HANDLE) __getHInstance())) {
+		/*console_printf("UnregisterClass %s ok.\n",(char*)ev->ev_arg1);*/
+
+	    } else {
+		/* noch einmal in die queue
+		*/
+		if (ev->ev_arg2++ < 100) {
+		    ev->ev_next = (struct queuedEvent *)0;
+		    ev->count   = eventsendcount++;
+
+		    if (eventQueueTail) {
+			eventQueueTail->ev_next = ev;
+		    } else {
+			eventQueueHead = ev;
+		    }
+		    eventQueueTail = ev;
+		    unlockEvents();
+
+		    if (freeArg2) {
+			free (freeArg2);
+			freeArg2 = NULL;
+		    }
+
+		    if (ev->ev_arg2 > 98) {
+			console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed. Wait 1 sec.\n",(char*)ev->ev_arg1);
+			sleep(1);
+		    } else {
+			sleep(0);
+		    }
+		    goto again;
+		}
+		/* fail evtl. später ändern und in st verzögert aufrufen
+		*/
+		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
+	    }
+	    free((char*)ev->ev_arg1);
+	    ev->ev_arg1 = 0;
+	}
 #endif
     }
 
@@ -2073,7 +2126,7 @@
     unlockEvents();
 
     if (freeArg2) {
-        free (freeArg2);
+	free (freeArg2);
     }
     return (1);
 }
@@ -2081,122 +2134,122 @@
 static void
 __clearRectangles(HWND hWnd, int numRects, RECT *pRect)
 {
-        HDC dc;
-        HBRUSH br;
-        int bgClr;
-        int isPrivateBrush = 0;
+	HDC dc;
+	HBRUSH br;
+	int bgClr;
+	int isPrivateBrush = 0;
 
 # ifdef CACHE_LAST_WM_PAINT_DC
-        AQUIRE_PAINT_MUTEX;
-
-        if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
-            dc = last_wm_paint_dc;
-        } else {
-            if (last_wm_paint_dc) {
+	AQUIRE_PAINT_MUTEX;
+
+	if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
+	    dc = last_wm_paint_dc;
+	} else {
+	    if (last_wm_paint_dc) {
 #  ifdef CACHE_LAST_DC
-                if (lastGcData && (lastGcData->_hDC == last_wm_paint_dc)) {
+		if (lastGcData && (lastGcData->_hDC == last_wm_paint_dc)) {
 #   ifdef DEBUG_DC_REUSE
-                    console_fprintf(stderr, "WinWorkstation [info]: Oops - release lastGcData [%d]\n", __LINE__);
+		    console_fprintf(stderr, "WinWorkstation [info]: Oops - release lastGcData [%d]\n", __LINE__);
 #   endif
-                    _releaseDC(lastGcData);
-                } else {
-                    ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
-                }
+		    _releaseDC(lastGcData);
+		} else {
+		    ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
+		}
 #  else
-                ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
+		ReleaseDC(last_wm_paint_win, last_wm_paint_dc);
 #  endif /* CACHE_LAST_DC */
-            }
-            dc = GetDC(hWnd);
-            last_wm_paint_dc = dc;
-            last_wm_paint_win = hWnd;
-        }
+	    }
+	    dc = GetDC(hWnd);
+	    last_wm_paint_dc = dc;
+	    last_wm_paint_win = hWnd;
+	}
 # else
-        dc = (HDC)GetDC(hWnd);
+	dc = (HDC)GetDC(hWnd);
 # endif /* CACHE_LAST_WM_PAINT_DC */
 
 # ifdef CACHE_LAST_DC
-        if (lastGcData && (lastGcData->_hDC == dc)) {
+	if (lastGcData && (lastGcData->_hDC == dc)) {
 #  ifdef DEBUG_DC_REUSE
-            console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
+	    console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc reuse [%d]\n", __LINE__);
 #  endif
-            if ((lastGcData->rop2 != R2_COPYPEN)
-             || (lastGcData->bitbltrop2 != BITBLT_COPY)) {
-                console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc not in Copy mode\n");
-            }
-            lastGcData = 0;
-        }
-# endif
-
-        br = GetWindow_viewBgBrush(hWnd);
-        if (! br) {
-            bgClr = GetWindow_viewBgColor(hWnd);
+	    if ((lastGcData->rop2 != R2_COPYPEN)
+	     || (lastGcData->bitbltrop2 != BITBLT_COPY)) {
+		console_fprintf(stderr, "WinWorkstation [info]: Oops wm_paint_dc not in Copy mode\n");
+	    }
+	    lastGcData = 0;
+	}
+# endif
+
+	br = GetWindow_viewBgBrush(hWnd);
+	if (! br) {
+	    bgClr = GetWindow_viewBgColor(hWnd);
 
 # ifdef CACHE_LAST_WM_PAINT_BRUSH
-            if (last_wm_paint_brush
-             && (last_wm_paint_brush_clr == bgClr)) {
-                br = last_wm_paint_brush;
-            } else {
-                if (bgClr == WhitePixel) {
-                    br = __whiteBrush;
-                } else if (bgClr == BlackPixel) {
-                    br = __blackBrush;
-                } else {
-                    if (last_wm_paint_brush) {
-                        _DeleteBrush(last_wm_paint_brush, __LINE__);
-                    }
-                    last_wm_paint_brush = br = CreateSolidBrush(bgClr);
-                    last_wm_paint_brush_clr = bgClr;
-                    isPrivateBrush = 1;
-                }
-            }
+	    if (last_wm_paint_brush
+	     && (last_wm_paint_brush_clr == bgClr)) {
+		br = last_wm_paint_brush;
+	    } else {
+		if (bgClr == WhitePixel) {
+		    br = __whiteBrush;
+		} else if (bgClr == BlackPixel) {
+		    br = __blackBrush;
+		} else {
+		    if (last_wm_paint_brush) {
+			_DeleteBrush(last_wm_paint_brush, __LINE__);
+		    }
+		    last_wm_paint_brush = br = CreateSolidBrush(bgClr);
+		    last_wm_paint_brush_clr = bgClr;
+		    isPrivateBrush = 1;
+		}
+	    }
 # else
-            br = CreateSolidBrush(bgClr);
-            isPrivateBrush = 1;
-# endif
-        }
-
-        if (! br) {
-            console_fprintf(stderr, "WinWorkstation [info]: no brush\n");
-        }
-
-        if (br) {
-            int i;
-
-            SelectClipRgn(dc, NULL);
-
-            for (i=0; i<numRects; i++) {
-                /*
-                 * always clear - even if not interested in exposes
-                 */
-                FillRect(dc, &(pRect[i]), br);
-            }
-        }
+	    br = CreateSolidBrush(bgClr);
+	    isPrivateBrush = 1;
+# endif
+	}
+
+	if (! br) {
+	    console_fprintf(stderr, "WinWorkstation [info]: no brush\n");
+	}
+
+	if (br) {
+	    int i;
+
+	    SelectClipRgn(dc, NULL);
+
+	    for (i=0; i<numRects; i++) {
+		/*
+		 * always clear - even if not interested in exposes
+		 */
+		FillRect(dc, &(pRect[i]), br);
+	    }
+	}
 
 # ifndef CACHE_LAST_WM_PAINT_BRUSH
-        if (isPrivateBrush) {
-            _DeleteBrush(br, __LINE__);
-        }
+	if (isPrivateBrush) {
+	    _DeleteBrush(br, __LINE__);
+	}
 # endif
 
 # ifndef CACHE_LAST_WM_PAINT_DC
-        ReleaseDC(hWnd, dc);
+	ReleaseDC(hWnd, dc);
 # endif
 
 # if defined(CACHE_LAST_WM_PAINT_DC)
-        RELEASE_PAINT_MUTEX
+	RELEASE_PAINT_MUTEX
 # endif
 }
 
 static void
 __clearWindow(HWND hWnd, int x, int y, int w, int h)
 {
-        RECT rect;
-
-        rect.left = x;
-        rect.top = y;
-        rect.right = x + w;
-        rect.bottom = y + h;
-        __clearRectangles(hWnd, 1, &rect);
+	RECT rect;
+
+	rect.left = x;
+	rect.top = y;
+	rect.right = x + w;
+	rect.bottom = y + h;
+	__clearRectangles(hWnd, 1, &rect);
 }
 
 
@@ -2210,128 +2263,128 @@
 static int
 __generateExposes(HWND hWnd, HRGN hRgnInOrNull, int msgType, int doClear)
 {
-        RECT updRect;
-        HRGN updRgn = 0;
-        int numRects, ret, n, i;
-        int wantExpose;
-        RECT *pRect;
-        union {
-            RGNDATA rgnData;
-            char    bytes[512];
-        } data;
-
-        wantExpose = 0;
-
-        if( msgType >= 0 )
-            wantExpose = (GetWindow_eventMask(hWnd) & ExposureMask);
-
-        if (hRgnInOrNull) {
-            updRgn = hRgnInOrNull;
-        } else {
-            PAINTSTRUCT ps;
-
-            /*
-             * fetch the update region, even if ExposureMask is empty.
-             */
-            updRgn = CreateRectRgn(0, 0, 0, 0);
-            ret = GetUpdateRgn(hWnd, updRgn, FALSE);
-
-#if 0
-            BeginPaint(hWnd, &ps);
-            /* store the rectangle required for image bit reversal */
-            /* updateRect = ps.rcPaint;   */
-            EndPaint(hWnd, &ps);
-#endif
-            switch (ret) {
-                case ERROR:
-                    console_fprintf(stderr, "WinWorkstation [info]: errregion\n");
-                    return -1;
-                case NULLREGION:
-                    DDDDPRINTF(("nullregion\n"));
-                    _DeleteObject(updRgn, __LINE__);
-                    return 0;
-                case SIMPLEREGION:
-                case COMPLEXREGION:
-                    break;
-            }
-        }
-        n = GetRegionData(updRgn, sizeof(data), &(data.rgnData));
-
-        /*
-         * the MS-doc states: n==1
-         * but this is not true
-         */
-        if ((n >= sizeof(RGNDATA))
-         && (n <= sizeof(data))
-         && (data.rgnData.rdh.iType == RDH_RECTANGLES))  {
-            /* ok, got the region */
-            numRects = data.rgnData.rdh.nCount;
-            pRect = (RECT *)(data.rgnData.Buffer);
-            DDDDPRINTF(("region numRects=%d\n", numRects));
-        } else {
-            /* a big region ... */
-            GetRgnBox(updRgn, &updRect);
-            numRects = 1;
-            pRect = &updRect;
-            DPRINTF(("very complex region (need:%d have:%d) bounds=%d,%d -> %d,%d\n",
-                     n, sizeof(data),
-                     updRect.left, updRect.top,
-                     updRect.right, updRect.bottom));
-            if (((updRect.right - updRect.left) <= 0)
-             || ((updRect.bottom - updRect.top) <= 0)) {
-                numRects = 0;
-            }
-        }
-
-        if (numRects) {
-            if (doClear) {
-                __clearRectangles(hWnd, numRects, pRect);
-            }
+	RECT updRect;
+	HRGN updRgn = 0;
+	int numRects, ret, n, i;
+	int wantExpose;
+	RECT *pRect;
+	union {
+	    RGNDATA rgnData;
+	    char    bytes[512];
+	} data;
+
+	wantExpose = 0;
+
+	if( msgType >= 0 )
+	    wantExpose = (GetWindow_eventMask(hWnd) & ExposureMask);
+
+	if (hRgnInOrNull) {
+	    updRgn = hRgnInOrNull;
+	} else {
+	    PAINTSTRUCT ps;
+
+	    /*
+	     * fetch the update region, even if ExposureMask is empty.
+	     */
+	    updRgn = CreateRectRgn(0, 0, 0, 0);
+	    ret = GetUpdateRgn(hWnd, updRgn, FALSE);
+
+#if 0
+	    BeginPaint(hWnd, &ps);
+	    /* store the rectangle required for image bit reversal */
+	    /* updateRect = ps.rcPaint;   */
+	    EndPaint(hWnd, &ps);
+#endif
+	    switch (ret) {
+		case ERROR:
+		    console_fprintf(stderr, "WinWorkstation [info]: errregion\n");
+		    return -1;
+		case NULLREGION:
+		    DDDDPRINTF(("nullregion\n"));
+		    _DeleteObject(updRgn, __LINE__);
+		    return 0;
+		case SIMPLEREGION:
+		case COMPLEXREGION:
+		    break;
+	    }
+	}
+	n = GetRegionData(updRgn, sizeof(data), &(data.rgnData));
+
+	/*
+	 * the MS-doc states: n==1
+	 * but this is not true
+	 */
+	if ((n >= sizeof(RGNDATA))
+	 && (n <= sizeof(data))
+	 && (data.rgnData.rdh.iType == RDH_RECTANGLES))  {
+	    /* ok, got the region */
+	    numRects = data.rgnData.rdh.nCount;
+	    pRect = (RECT *)(data.rgnData.Buffer);
+	    DDDDPRINTF(("region numRects=%d\n", numRects));
+	} else {
+	    /* a big region ... */
+	    GetRgnBox(updRgn, &updRect);
+	    numRects = 1;
+	    pRect = &updRect;
+	    DPRINTF(("very complex region (need:%d have:%d) bounds=%d,%d -> %d,%d\n",
+		     n, sizeof(data),
+		     updRect.left, updRect.top,
+		     updRect.right, updRect.bottom));
+	    if (((updRect.right - updRect.left) <= 0)
+	     || ((updRect.bottom - updRect.top) <= 0)) {
+		numRects = 0;
+	    }
+	}
+
+	if (numRects) {
+	    if (doClear) {
+		__clearRectangles(hWnd, numRects, pRect);
+	    }
 
 #ifndef PRE_21_NOV
-        for (i=0; i < numRects; i++) {
-            ValidateRect( hWnd, &pRect[i] );
-        }
+	for (i=0; i < numRects; i++) {
+	    ValidateRect( hWnd, &pRect[i] );
+	}
 #endif
 
 #ifdef DEBUG_COLORIZE_WM_PAINT_RECTS1
-            {
-                HDC hDC;
-                HBRUSH hBrush;
-
-                hBrush = CreateSolidBrush(BlackPixel);
-                hDC = GetWindowDC(hWnd);
-                SelectClipRgn(hDC, NULL);
-                for (i=0; i<numRects; i++) {
-                    FillRect(hDC, &(pRect[i]), hBrush);
-                }
-                _DeleteBrush(hBrush, __LINE__);
-                ReleaseDC(hWnd, hDC);
-            }
-#endif
-
-            if (wantExpose) {
-                for (i=0; i<numRects; i++) {
-                    int final = 0;
-
-                    if ((msgType == __WM_GEXPOSE)
-                     && (i == (numRects - 1))) {
-                        final = 1;
-                    }
-                    enqEvent(ExposureMask, hWnd, msgType, final,
-                             (pRect[i].left), (pRect[i].top),
-                             (pRect[i].right - pRect[i].left),
-                             (pRect[i].bottom - pRect[i].top),
-                             EV_NOTIME);
-                }
-            }
-        }
-
-        if (updRgn && (updRgn != hRgnInOrNull)) {
-            _DeleteObject(updRgn, __LINE__);
-        }
-
-        return numRects;
+	    {
+		HDC hDC;
+		HBRUSH hBrush;
+
+		hBrush = CreateSolidBrush(BlackPixel);
+		hDC = GetWindowDC(hWnd);
+		SelectClipRgn(hDC, NULL);
+		for (i=0; i<numRects; i++) {
+		    FillRect(hDC, &(pRect[i]), hBrush);
+		}
+		_DeleteBrush(hBrush, __LINE__);
+		ReleaseDC(hWnd, hDC);
+	    }
+#endif
+
+	    if (wantExpose) {
+		for (i=0; i<numRects; i++) {
+		    int final = 0;
+
+		    if ((msgType == __WM_GEXPOSE)
+		     && (i == (numRects - 1))) {
+			final = 1;
+		    }
+		    enqEvent(ExposureMask, hWnd, msgType, final,
+			     (pRect[i].left), (pRect[i].top),
+			     (pRect[i].right - pRect[i].left),
+			     (pRect[i].bottom - pRect[i].top),
+			     EV_NOTIME);
+		}
+	    }
+	}
+
+	if (updRgn && (updRgn != hRgnInOrNull)) {
+	    _DeleteObject(updRgn, __LINE__);
+	}
+
+	return numRects;
 }
 
 #ifdef THIS_DOES_NOT_AVOID_DOUBLE_REPAINTS
@@ -2339,14 +2392,14 @@
 BOOL CALLBACK
 recursiveExposeGenerator(HWND hChild, LPARAM param)
 {
-        __generateExposes(hChild, NULL, param, 0);
-        return TRUE;
+	__generateExposes(hChild, NULL, param, 0);
+	return TRUE;
 }
 
 static void
 __generateRecursiveExposes(HWND hWnd, int msgType)
 {
-        EnumChildWindows(hWnd, recursiveExposeGenerator, msgType);
+	EnumChildWindows(hWnd, recursiveExposeGenerator, msgType);
 }
 
 #endif /* sigh */
@@ -2358,27 +2411,27 @@
     int modifiers = 0;
 
     if (GetKeyState(VK_SHIFT) & 0x8000)
-        modifiers |= ShiftMask;
+	modifiers |= ShiftMask;
     if (GetKeyState(VK_CONTROL) & 0x8000)
-        modifiers |= ControlMask;
+	modifiers |= ControlMask;
 #if 0
     if (GetKeyState(VK_RMENU) & 0x8000)
-        modifiers |= RightAltMask;
+	modifiers |= RightAltMask;
     if (GetKeyState(VK_LMENU) & 0x8000)
-        modifiers |= LeftAltMask;
+	modifiers |= LeftAltMask;
 #else
     if (GetKeyState(VK_MENU) & 0x8000)
-        modifiers |= LeftAltMask;
+	modifiers |= LeftAltMask;
 #endif
     if (GetKeyState(VK_LBUTTON) & 0x8000)
-        modifiers |= Button1Mask;
+	modifiers |= Button1Mask;
     if (GetKeyState(VK_MBUTTON) & 0x8000)
-        modifiers |= Button2Mask;
+	modifiers |= Button2Mask;
     if (GetKeyState(VK_RBUTTON) & 0x8000)
-        modifiers |= Button3Mask;
+	modifiers |= Button3Mask;
 
     if ((modifiers & AnyButtonMask) == 0) {
-        __eatingMouseEvents = 0;
+	__eatingMouseEvents = 0;
     }
     return modifiers;
 }
@@ -2392,9 +2445,9 @@
 # define MustHandleButtonEvent()\
     (((__currentCapture == CAPTURE_NONE)       \
      && (   (GetKeyState(VK_LBUTTON) & 0x8000) \
-         || (GetKeyState(VK_MBUTTON) & 0x8000) \
-         || (GetKeyState(VK_RBUTTON) & 0x8000) \
-        )                                      \
+	 || (GetKeyState(VK_MBUTTON) & 0x8000) \
+	 || (GetKeyState(VK_RBUTTON) & 0x8000) \
+	)                                      \
     ) ? 0 : 1)
 
 #else
@@ -2418,109 +2471,109 @@
     int gravity;
 
     if (lI = GETLOCALWINDOWINFOPTR(hChild)) {
-        if ((gravity = lI->viewGravity) != GRAVITY_NONE) {
-            RECT oldChildRct, oldChildWinRct;
-            RECT newChildRct;
-            int deltaW, deltaH;
-            int anyChange = 0;
-
-            /*
-             * get its current bounds ...
-             */
-            GetClientRect(hChild, &oldChildRct);
-            deltaW = iP->newW - iP->currW;
-            deltaH = iP->newH - iP->currH;
-
-            GetWindowRect(hChild, &oldChildWinRct);
-            oldChildRct.left = oldChildWinRct.left - iP->parentWinX;
-            oldChildRct.top =  oldChildWinRct.top - iP->parentWinY;
-
-            newChildRct = oldChildRct;
-            switch (gravity) {
-#if 0
-                case GRAVITY_N:
-                    console_fprintf(stderr, "WinWorkstation [info]: Child %x: North gravity\n", hChild);
-                    /*
-                     * shift to the bottom, for a constant
-                     * distance from the bottom edge;
-                     */
-                    newChildRct.bottom += deltaH;
-                    anyChange = 1;
-                    break;
-
-                case GRAVITY_W:
-                    console_fprintf(stderr, "WinWorkstation [info]: Child %x: West gravity\n", hChild);
-                    /*
-                     * shift to the right, for a constant
-                     * distance from the right edge;
-                     */
-                    newChildRct.right += deltaW;
-                    anyChange = 1;
-                    break;
-#endif
-                case GRAVITY_S:
-                    console_fprintf(stderr, "WinWorkstation [info]: Child %x: South gravity\n", hChild);
-                    /*
-                     * shift to the bottom, for a constant
-                     * distance from the bottom edge;
-                     */
-                    newChildRct.top += deltaH;
-                    newChildRct.bottom  += deltaH;
-                    anyChange = 1;
-                    break;
-
-                case GRAVITY_E:
-                    console_fprintf(stderr, "WinWorkstation [info]: Child %x: East gravity\n", hChild);
-                    /*
-                     * shift to the right, for a constant
-                     * distance from the right edge;
-                     */
-                    newChildRct.right += deltaW;
-                    newChildRct.left  += deltaW;
-                    anyChange = 1;
-                    break;
-
-                case GRAVITY_SE:
-                    console_fprintf(stderr, "WinWorkstation [info]: Child %x: SouthEast gravity\n", hChild);
-                    /*
-                     * shift to the bottom-right, for a constant
-                     * distance from the bottom-right edge;
-                     */
-                    newChildRct.right += deltaW;
-                    newChildRct.left  += deltaW;
-                    newChildRct.top += deltaH;
-                    newChildRct.bottom  += deltaH;
-                    anyChange = 1;
-                    break;
-
-                default:
-                    DPRINTF(("Child %x: other gravity\n", hChild));
-                    break;
-            }
-
-            if (anyChange) {
-                if ((newChildRct.left < 0)
-                 || (newChildRct.top < 0)
-                 || (newChildRct.right >= iP->newW)
-                 || (newChildRct.bottom >= iP->newH)) {
-                    console_fprintf(stderr, "WinWorkstation [info]: dont move child to: %d/%d -> %d/%d\n",
-                                    newChildRct.left, newChildRct.top,
-                                    newChildRct.right, newChildRct.bottom);
-                } else {
-                    console_fprintf(stderr, "WinWorkstation [info]: move child from %d/%d->%d/%d to: %d/%d->%d/%d\n",
-                                    oldChildRct.left, oldChildRct.top,
-                                    oldChildRct.right, oldChildRct.bottom,
-                                    newChildRct.left, newChildRct.top,
-                                    newChildRct.right, newChildRct.bottom);
-
-                    SetWindowPos(hChild, (HWND)0,
-                                 newChildRct.left, newChildRct.top,
-                                 0, 0,
-                                 /* SWP_NOSENDCHANGING | */
-                                 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
-                }
-            }
-        }
+	if ((gravity = lI->viewGravity) != GRAVITY_NONE) {
+	    RECT oldChildRct, oldChildWinRct;
+	    RECT newChildRct;
+	    int deltaW, deltaH;
+	    int anyChange = 0;
+
+	    /*
+	     * get its current bounds ...
+	     */
+	    GetClientRect(hChild, &oldChildRct);
+	    deltaW = iP->newW - iP->currW;
+	    deltaH = iP->newH - iP->currH;
+
+	    GetWindowRect(hChild, &oldChildWinRct);
+	    oldChildRct.left = oldChildWinRct.left - iP->parentWinX;
+	    oldChildRct.top =  oldChildWinRct.top - iP->parentWinY;
+
+	    newChildRct = oldChildRct;
+	    switch (gravity) {
+#if 0
+		case GRAVITY_N:
+		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: North gravity\n", hChild);
+		    /*
+		     * shift to the bottom, for a constant
+		     * distance from the bottom edge;
+		     */
+		    newChildRct.bottom += deltaH;
+		    anyChange = 1;
+		    break;
+
+		case GRAVITY_W:
+		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: West gravity\n", hChild);
+		    /*
+		     * shift to the right, for a constant
+		     * distance from the right edge;
+		     */
+		    newChildRct.right += deltaW;
+		    anyChange = 1;
+		    break;
+#endif
+		case GRAVITY_S:
+		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: South gravity\n", hChild);
+		    /*
+		     * shift to the bottom, for a constant
+		     * distance from the bottom edge;
+		     */
+		    newChildRct.top += deltaH;
+		    newChildRct.bottom  += deltaH;
+		    anyChange = 1;
+		    break;
+
+		case GRAVITY_E:
+		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: East gravity\n", hChild);
+		    /*
+		     * shift to the right, for a constant
+		     * distance from the right edge;
+		     */
+		    newChildRct.right += deltaW;
+		    newChildRct.left  += deltaW;
+		    anyChange = 1;
+		    break;
+
+		case GRAVITY_SE:
+		    console_fprintf(stderr, "WinWorkstation [info]: Child %x: SouthEast gravity\n", hChild);
+		    /*
+		     * shift to the bottom-right, for a constant
+		     * distance from the bottom-right edge;
+		     */
+		    newChildRct.right += deltaW;
+		    newChildRct.left  += deltaW;
+		    newChildRct.top += deltaH;
+		    newChildRct.bottom  += deltaH;
+		    anyChange = 1;
+		    break;
+
+		default:
+		    DPRINTF(("Child %x: other gravity\n", hChild));
+		    break;
+	    }
+
+	    if (anyChange) {
+		if ((newChildRct.left < 0)
+		 || (newChildRct.top < 0)
+		 || (newChildRct.right >= iP->newW)
+		 || (newChildRct.bottom >= iP->newH)) {
+		    console_fprintf(stderr, "WinWorkstation [info]: dont move child to: %d/%d -> %d/%d\n",
+				    newChildRct.left, newChildRct.top,
+				    newChildRct.right, newChildRct.bottom);
+		} else {
+		    console_fprintf(stderr, "WinWorkstation [info]: move child from %d/%d->%d/%d to: %d/%d->%d/%d\n",
+				    oldChildRct.left, oldChildRct.top,
+				    oldChildRct.right, oldChildRct.bottom,
+				    newChildRct.left, newChildRct.top,
+				    newChildRct.right, newChildRct.bottom);
+
+		    SetWindowPos(hChild, (HWND)0,
+				 newChildRct.left, newChildRct.top,
+				 0, 0,
+				 /* SWP_NOSENDCHANGING | */
+				 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);
+		}
+	    }
+	}
     }
     return TRUE;
 }
@@ -2533,19 +2586,19 @@
     wchar_t *wcp = out;
 
     while ((nMax > 1) && cp && *cp) {
-        *wcp++ = *cp++;
-        nMax--;
+	*wcp++ = *cp++;
+	nMax--;
     }
     *wcp = 0;
 }
 
 static int
 winEventProcessing(
-        HWND hWnd,         /* window handle                   */
-        UINT message,      /* type of message                 */
-        UINT wParam,       /* additional information          */
-        INT lParam,        /* additional information          */
-        int *pDefault
+	HWND hWnd,         /* window handle                   */
+	UINT message,      /* type of message                 */
+	UINT wParam,       /* additional information          */
+	INT lParam,        /* additional information          */
+	int *pDefault
     ) {
     int curButton;
     int x, y, w, h;
@@ -2558,1974 +2611,1974 @@
     evTime = lastMSGTime;
     lastMSGTime = 0;
     if (evTime == 0) {
-        lastMSGTime = GetTickCount();
+	lastMSGTime = GetTickCount();
     }
 
 /*
     EVENT_PRINTF(("winEvent hWin=0x%x message=0x%x wP=0x%x lP=0x%x\n",
-                        hWnd, message, wParam, lParam));
+			hWnd, message, wParam, lParam));
 */
 
     if (hWnd) {
-        if (message != WM_MOUSEMOVE) {
-            lastMotionWnd = 0;
-        }
-
-        isNative = (GetWindow_flag(hWnd) & LI_NATIVEWIN);
-        if (isNative) {
-            NDPRINTF(("event %d (0x%x) for nativeWindow\n", message, message));
-        }
+	if (message != WM_MOUSEMOVE) {
+	    lastMotionWnd = 0;
+	}
+
+	isNative = (GetWindow_flag(hWnd) & LI_NATIVEWIN);
+	if (isNative) {
+	    NDPRINTF(("event %d (0x%x) for nativeWindow\n", message, message));
+	}
     }
 
     /*
      * messages which are enqueued to be handled by the view thread
      */
     switch (message) {
-        case WM_THREAD_CREATEWINDOW:
-            EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW\n"));
-
-            {
-                createWindowInfo *cwi = (createWindowInfo *)(lParam);
-
-                if ((cwi->sequenceNr == wParam)
-                 && (cwi->sequenceNr != INVALIDATED_CWI)) {
-                    cwi->sequenceNr = INVALIDATED_CWI;
-                    cwi->infoWasRead = 1;
-                    if (cwi->newWinHandle == NULL) {
-                        HANDLE ev;
-                        HANDLE hwnd;
-
-                        cwi->newWinHandle = hwnd = CreateWindowExW(
-                                            cwi->winStyleBitsEx,
-                                            cwi->className,
-                                            cwi->windowName,
-                                            cwi->winStyleBits,
-                                            cwi->x, cwi->y,
-                                            cwi->dx, cwi->dy,
-                                            cwi->parentHandle,
-                                            NULL,           /* menu */
-                                            (HANDLE) __getHInstance(),
-                                            cwi->localWindowInfo
-                                           );
-
-                        if (hwnd == NULL) {
-                            cwi->errCode = GetLastError();
-                            console_fprintf(stderr, "WinWorkstation [info]: CreateWindow failed: %d (0x%x) [%d]\n",
-                                                cwi->errCode, cwi->errCode, __LINE__);
-                        } else {
-                            SETLOCALWINDOWINFOPTR(hwnd, cwi->localWindowInfo);
+	case WM_THREAD_CREATEWINDOW:
+	    EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW\n"));
+
+	    {
+		createWindowInfo *cwi = (createWindowInfo *)(lParam);
+
+		if ((cwi->sequenceNr == wParam)
+		 && (cwi->sequenceNr != INVALIDATED_CWI)) {
+		    cwi->sequenceNr = INVALIDATED_CWI;
+		    cwi->infoWasRead = 1;
+		    if (cwi->newWinHandle == NULL) {
+			HANDLE ev;
+			HANDLE hwnd;
+
+			cwi->newWinHandle = hwnd = CreateWindowExW(
+					    cwi->winStyleBitsEx,
+					    cwi->className,
+					    cwi->windowName,
+					    cwi->winStyleBits,
+					    cwi->x, cwi->y,
+					    cwi->dx, cwi->dy,
+					    cwi->parentHandle,
+					    NULL,           /* menu */
+					    (HANDLE) __getHInstance(),
+					    cwi->localWindowInfo
+					   );
+
+			if (hwnd == NULL) {
+			    cwi->errCode = GetLastError();
+			    console_fprintf(stderr, "WinWorkstation [info]: CreateWindow failed: %d (0x%x) [%d]\n",
+						cwi->errCode, cwi->errCode, __LINE__);
+			} else {
+			    SETLOCALWINDOWINFOPTR(hwnd, cwi->localWindowInfo);
 #ifdef DEBUG /* PARANOIA */
-                            if (GETLOCALWINDOWINFOPTR(hwnd) != cwi->localWindowInfo) {
-                               console_fprintf(stderr, "lI-Error\n");
-                            }
-#endif
-                            SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
-                                        /* SWP_NOOWNERZORDER |*/
-                                        SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
-                        }
-
-                        ev = cwi->hCreateEvent;
-                        if (ev) {
-                            SetEvent(ev);
-                        }
-                    }
-                } else {
-                    DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
-                }
-            }
-            *pDefault = 0;
-            return 0;
-
-        case WM_THREAD_DESTROYWINDOW:
-            {
-                HBRUSH br;
-
-                br = GetWindow_viewBgBrush(hWnd);
-                if (br) {
-                    SetWindow_viewBgBrush(hWnd, 0);
-                    _DeleteBrushIfNotInCache(br, __LINE__);
-                }
-            }
+			    if (GETLOCALWINDOWINFOPTR(hwnd) != cwi->localWindowInfo) {
+			       console_fprintf(stderr, "lI-Error\n");
+			    }
+#endif
+			    SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0,
+					/* SWP_NOOWNERZORDER |*/
+					SWP_NOSENDCHANGING | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+			}
+
+			ev = cwi->hCreateEvent;
+			if (ev) {
+			    SetEvent(ev);
+			}
+		    }
+		} else {
+		    DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
+
+	case WM_THREAD_DESTROYWINDOW:
+	    {
+		HBRUSH br;
+
+		br = GetWindow_viewBgBrush(hWnd);
+		if (br) {
+		    SetWindow_viewBgBrush(hWnd, 0);
+		    _DeleteBrushIfNotInCache(br, __LINE__);
+		}
+	    }
 
 #ifdef CACHE_LAST_DC
-            if (lastGcData && (lastGcHWIN == hWnd)) {
-                _releaseDC(lastGcData);
-            }
+	    if (lastGcData && (lastGcHWIN == hWnd)) {
+		_releaseDC(lastGcData);
+	    }
 #endif
 #ifdef CACHE_LAST_WM_PAINT_DC
-            if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
-                ReleaseDC(hWnd, last_wm_paint_dc);
-                last_wm_paint_win = last_wm_paint_dc = 0;
-            }
-#endif
-            if (! DestroyWindow(hWnd)) {
-                DPRINTF(("DestroyWindow ERROR\n"));
-            } else {
+	    if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
+		ReleaseDC(hWnd, last_wm_paint_dc);
+		last_wm_paint_win = last_wm_paint_dc = 0;
+	    }
+#endif
+	    if (! DestroyWindow(hWnd)) {
+		DPRINTF(("DestroyWindow ERROR\n"));
+	    } else {
 #ifdef COUNT_RESOURCES
-                __cnt_createWindows--;
-                RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
-#endif
-            }
-            *pDefault = 0;
-            return 0;
-
-        case WM_CREATE:
-            {
+		__cnt_createWindows--;
+		RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
+#endif
+	    }
+	    *pDefault = 0;
+	    return 0;
+
+	case WM_CREATE:
+	    {
 #ifdef SETLOCALINFO_IN_CREATE /* no longer */
-                localWindowInfo *lI;
-
-                CREATESTRUCT *lpcs = (LPCREATESTRUCT) lParam; // structure with creation data
-
-                lI = lpcs->lpCreateParams;
-                EVENT_PRINTF(("WM_CREATE lI=%x\n", lI));
-
-                SETLOCALWINDOWINFOPTR(hWnd, lI);
+		localWindowInfo *lI;
+
+		CREATESTRUCT *lpcs = (LPCREATESTRUCT) lParam; // structure with creation data
+
+		lI = lpcs->lpCreateParams;
+		EVENT_PRINTF(("WM_CREATE lI=%x\n", lI));
+
+		SETLOCALWINDOWINFOPTR(hWnd, lI);
 # ifdef SUPERDEBUG
-                if (GETLOCALWINDOWINFOPTR(hWnd) != lpcs->lpCreateParams) {
-                    PRINTF(("SETLOCALWINDOWINFOPTR ERROR\n"));
-                }
+		if (GETLOCALWINDOWINFOPTR(hWnd) != lpcs->lpCreateParams) {
+		    PRINTF(("SETLOCALWINDOWINFOPTR ERROR\n"));
+		}
 # endif /* SUPERDEBUG */
 #endif
 
-                *pDefault = 0;
+		*pDefault = 0;
 #ifdef COUNT_RESOURCES
-                __cnt_createWindows++;
-                RESPRINTF(("CreateWindows %d\n",__cnt_createWindows));
-#endif
-            }
-            break;
-
-        case WM_CLOSE:
-            EVENT_PRINTF(("WM_CLOSE\n"));
-            if (! destroyWin) {
-                // (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
-                enqEvent(0, hWnd, WM_CLOSE, wParam, 0, 0, 0, 0, EV_NOTIME);
-            } else {
-                destroyWin = 0;
-                {
-                    HBRUSH br;
-
-                    br = GetWindow_viewBgBrush(hWnd);
-                    if (br) {
-                        SetWindow_viewBgBrush(hWnd, 0);
-                        _DeleteBrushIfNotInCache(br, __LINE__);
-                    }
-                }
+		__cnt_createWindows++;
+		RESPRINTF(("CreateWindows %d\n",__cnt_createWindows));
+#endif
+	    }
+	    break;
+
+	case WM_CLOSE:
+	    EVENT_PRINTF(("WM_CLOSE\n"));
+	    if (! destroyWin) {
+		// (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
+		enqEvent(0, hWnd, WM_CLOSE, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    } else {
+		destroyWin = 0;
+		{
+		    HBRUSH br;
+
+		    br = GetWindow_viewBgBrush(hWnd);
+		    if (br) {
+			SetWindow_viewBgBrush(hWnd, 0);
+			_DeleteBrushIfNotInCache(br, __LINE__);
+		    }
+		}
 #ifdef CACHE_LAST_DC
-                if (lastGcData && (lastGcHWIN == hWnd)) {
-                    _releaseDC(lastGcData);
-                }
+		if (lastGcData && (lastGcHWIN == hWnd)) {
+		    _releaseDC(lastGcData);
+		}
 #endif
 #ifdef CACHE_LAST_WM_PAINT_DC
-                if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
-                    ReleaseDC(hWnd, last_wm_paint_dc);
-                    last_wm_paint_win = last_wm_paint_dc = 0;
-                }
-#endif
-                if (! DestroyWindow(hWnd)) {
-                    DPRINTF(("DestroyWindow ERROR\n"));
-                } else {
+		if (last_wm_paint_dc && (last_wm_paint_win == hWnd)) {
+		    ReleaseDC(hWnd, last_wm_paint_dc);
+		    last_wm_paint_win = last_wm_paint_dc = 0;
+		}
+#endif
+		if (! DestroyWindow(hWnd)) {
+		    DPRINTF(("DestroyWindow ERROR\n"));
+		} else {
 #ifdef COUNT_RESOURCES
-                    __cnt_createWindows--;
-                    RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
-#endif
-                }
-            }
-            *pDefault = 0;
-            return 0;
-            break;
-
-        case WM_DESTROY:
-            {
-                char *nm = 0;
-                localWindowInfo *lI;
-
-                lI = GETLOCALWINDOWINFOPTR(hWnd);
-                EVENT_PRINTF(("WM_DESTROY %x li=%x\n", hWnd, lI));
+		    __cnt_createWindows--;
+		    RESPRINTF(("DestroyWindow -> %d\n", __cnt_createWindows));
+#endif
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
+	    break;
+
+	case WM_DESTROY:
+	    {
+		char *nm = 0;
+		localWindowInfo *lI;
+
+		lI = GETLOCALWINDOWINFOPTR(hWnd);
+		EVENT_PRINTF(("WM_DESTROY %x li=%x\n", hWnd, lI));
 
 #ifdef TOPWINDOWCLASS
-                if (lI) {
-                    if (lI->flag & LI_TOPWIN) {
-                        nm = (char*) malloc(300);
-                        GetClassName(hWnd, nm, 300);
-                    }
-                    /* freeing now done in other thread */
-                }
-#endif
-                SETLOCALWINDOWINFOPTR(hWnd, 0);
+		if (lI) {
+		    if (lI->flag & LI_TOPWIN) {
+			nm = (char*) malloc(300);
+			GetClassName(hWnd, nm, 300);
+		    }
+		    /* freeing now done in other thread */
+		}
+#endif
+		SETLOCALWINDOWINFOPTR(hWnd, 0);
 
 #ifdef FREE_LI_IN_STX_PROCESS
-                enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, lI, 0, 0, EV_NOTIME);
-#else
-                if (lI) {
-                    free(lI);
-                }
-                enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, 0, 0, 0, EV_NOTIME);
-#endif
-                *pDefault = 0;
-                return 0;
-            }
-            break;
-
-        case WM_GETMINMAXINFO:
+		enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, lI, 0, 0, EV_NOTIME);
+#else
+		if (lI) {
+		    free(lI);
+		}
+		enqEvent(0, hWnd, WM_DESTROY, wParam, (INT)nm, 0, 0, 0, EV_NOTIME);
+#endif
+		*pDefault = 0;
+		return 0;
+	    }
+	    break;
+
+	case WM_GETMINMAXINFO:
 
 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
-            if (inMove) {
-                *pDefault = 0;
-                return 0;
-            }
-#endif
-
-            {
-                int minW, maxW;
-                localWindowInfo *lI;
-                LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
-
-                EVENT_PRINTF2(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n",
-                            hWnd,
-                            lpmmi->ptMinTrackSize.x,
-                            lpmmi->ptMinTrackSize.y));
-
-                lI = GETLOCALWINDOWINFOPTR(hWnd);
-                if (lI && (lI->minWidth) && (lI->maxWidth)) {
-                  lpmmi->ptMaxPosition.x = 0;
-                  lpmmi->ptMaxPosition.y = 0;
-                  lpmmi->ptMaxSize.x = lI->currentMonitorWidth;
-                  lpmmi->ptMaxSize.y = lI->currentMonitorHeight;
+	    if (inMove) {
+		*pDefault = 0;
+		return 0;
+	    }
+#endif
+
+	    {
+		int minW, maxW;
+		localWindowInfo *lI;
+		LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam;
+
+		EVENT_PRINTF2(("WM_GETMINMAXINFO handle=%x got min: %d/%d\n",
+			    hWnd,
+			    lpmmi->ptMinTrackSize.x,
+			    lpmmi->ptMinTrackSize.y));
+
+		lI = GETLOCALWINDOWINFOPTR(hWnd);
+		if (lI && (lI->minWidth) && (lI->maxWidth)) {
+		  lpmmi->ptMaxPosition.x = 0;
+		  lpmmi->ptMaxPosition.y = 0;
+		  lpmmi->ptMaxSize.x = lI->currentMonitorWidth;
+		  lpmmi->ptMaxSize.y = lI->currentMonitorHeight;
 #define MIN(a, b) (a < b ? a : b)
-                  lpmmi->ptMaxSize.x = MIN(GetSystemMetrics(SM_CXMAXIMIZED), lI->maxWidth);
-                  lpmmi->ptMaxSize.y = MIN(GetSystemMetrics(SM_CYMAXIMIZED), lI->maxHeight);
-
-                  lpmmi->ptMaxTrackSize.x = lI->maxWidth == 0 ? GetSystemMetrics(SM_CXMAXTRACK) : lI->maxWidth;
-                  lpmmi->ptMaxTrackSize.y = lI->maxHeight == 0 ? GetSystemMetrics(SM_CYMAXTRACK) : lI->maxHeight;
-                  lpmmi->ptMinTrackSize.x = lI->minWidth;
-                  lpmmi->ptMinTrackSize.y = lI->minHeight;
-
-                  EVENT_PRINTF3(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n",
-                                  hWnd,
-                                  lI->minWidth, lI->minHeight,
-                                  lI->maxWidth, lI->maxHeight));
-                  *pDefault = 0;
-                }
-            }
-            break;
-
-        case WM_SETCURSOR:
-            {
-                HCURSOR curs;
-                int hitCode;
-
-                hitCode = LOWORD(lParam);
-                if (hitCode != HTCLIENT) {
-                    /*
-                     * not in client area ...
-                     */
-                    return 0;
-                }
-                DPRINTFIF(__debug_WM_SETCURSOR__ , ("WM_SETCURSOR\n"));
-                curs = GetWindow_Cursor(hWnd);
-                if (curs) {
-                    SetCursor(curs);
-                    *pDefault = 0;
-                    return 1;
-                }
-            }
-            return 0;
-
-        case WM_WINDOWPOSCHANGED:
+		  lpmmi->ptMaxSize.x = MIN(GetSystemMetrics(SM_CXMAXIMIZED), lI->maxWidth);
+		  lpmmi->ptMaxSize.y = MIN(GetSystemMetrics(SM_CYMAXIMIZED), lI->maxHeight);
+
+		  lpmmi->ptMaxTrackSize.x = lI->maxWidth == 0 ? GetSystemMetrics(SM_CXMAXTRACK) : lI->maxWidth;
+		  lpmmi->ptMaxTrackSize.y = lI->maxHeight == 0 ? GetSystemMetrics(SM_CYMAXTRACK) : lI->maxHeight;
+		  lpmmi->ptMinTrackSize.x = lI->minWidth;
+		  lpmmi->ptMinTrackSize.y = lI->minHeight;
+
+		  EVENT_PRINTF3(("WM_GETMINMAXINFO handle=%x return min: %d/%d max: %d/%d\n",
+				  hWnd,
+				  lI->minWidth, lI->minHeight,
+				  lI->maxWidth, lI->maxHeight));
+		  *pDefault = 0;
+		}
+	    }
+	    break;
+
+	case WM_SETCURSOR:
+	    {
+		HCURSOR curs;
+		int hitCode;
+
+		hitCode = LOWORD(lParam);
+		if (hitCode != HTCLIENT) {
+		    /*
+		     * not in client area ...
+		     */
+		    return 0;
+		}
+		DPRINTFIF(__debug_WM_SETCURSOR__ , ("WM_SETCURSOR\n"));
+		curs = GetWindow_Cursor(hWnd);
+		if (curs) {
+		    SetCursor(curs);
+		    *pDefault = 0;
+		    return 1;
+		}
+	    }
+	    return 0;
+
+	case WM_WINDOWPOSCHANGED:
 
 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
-            if (inMove) {
-                *pDefault = 0;
-                return 0;
-            }
-#endif
-            if (hWnd == __rootWinSpezial) {
-                /* can this happen ? */
-                *pDefault = 1;
-                return 0;
-            }
-
-            if (! inMove && (__currentCapture == CAPTURE_NONE)) {
-                POINT p;
-                HWND hWndChild,hWndTemp;
-
-                p.x = evRootX;
-                p.y = evRootY;
-                ScreenToClient(hWnd, &p);
-                hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
-                do {
-                    hWndTemp = hWndChild;
-                    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
-                } while ((hWndChild) && (hWndChild != hWndTemp));
-
-                if (hWndChild /*&& (hWndChild != hWnd)*/) {
-                    if (hWndChild != __currentPointerView) {
-                        int modifiers = getModifiers();
-
-                        if (__currentPointerView) {
-                            if (inSizeMove) {
-                                if (needDelayedMouseLeaveWindow == NULL) {
-                                    needDelayedMouseLeaveWindow = __currentPointerView;
-                                }
-                            } else {
-                                if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                                    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
-                                    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-                                }
-                            }
-                            __currentPointerView = 0;
-                        }
-                        if (inSizeMove) {
-                            needDelayedMouseEnterWindow = hWndChild;
-                            delayedMouseEnterX = evRootX;
-                            delayedMouseEnterY = evRootY;
-                        } else {
-                            if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
-                                enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
-                                SetWindow_mouseXY(hWndChild, evRootX, evRootY);
-                            }
-                            // SetFocus(hWndChild);
-                        }
-                        __currentPointerView = hWndChild;
-                    }
-                }
-            }
-
-            /*
-             * ignore child window messages ...
-             */
-            if (GetParent(hWnd) != NULL) {
-                break;
-            }
-
-            {
-                WINDOWPOS *wp = (WINDOWPOS *)lParam;
-                RECT rct, dRect;
-                int x, y, w, h;
-                int dW, dH;
-
-#if 0
-                dRect.left = 0;
-                dRect.top = 0;
-                dRect.right = 100;
-                dRect.bottom = 100;
-                winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
-                winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
-                AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
-                dW = dRect.right - dRect.left;
-                dH = dRect.bottom - dRect.top;
-#endif
-                GetClientRect(hWnd, &rct);
-
-                x = rct.left;
-                y = rct.top;
-                w = rct.right - rct.left;
-                h = rct.bottom - rct.top;
-
-                if (__debug__) {
-                    EVENT_PRINTF(("WM_WINDOWPOSCHANGED ["));
-
-                    if (wp->flags & SWP_NOSIZE) {
-                        EVENT_PRINTF(("NOSIZE "));
-                    }
-                    if (wp->flags & SWP_NOMOVE) {
-                        EVENT_PRINTF(("NOMOVE "));
-                    }
-                    if (wp->flags & SWP_NOZORDER) {
-                        EVENT_PRINTF(("NOZORDER "));
-                    }
-                    if (wp->flags & SWP_NOREDRAW) {
-                        EVENT_PRINTF(("NOREDRAW "));
-                    }
-                    if (wp->flags & SWP_NOACTIVATE) {
-                        EVENT_PRINTF(("NOACTIVATE "));
-                    }
-                    if (wp->flags & SWP_FRAMECHANGED) {
-                        EVENT_PRINTF(("FRAMECHANGED "));
-                    }
-                    if (wp->flags & SWP_NOCOPYBITS) {
-                        EVENT_PRINTF(("NOCOPYBITS "));
-                    }
-                    if (wp->flags & SWP_NOOWNERZORDER) {
-                        EVENT_PRINTF(("NOOWNERZORDER "));
-                    }
-                    if (wp->flags & SWP_NOSENDCHANGING) {
-                        EVENT_PRINTF(("NOSENDCHANGING "));
-                    }
-                    if (wp->flags & SWP_DEFERERASE) {
-                        EVENT_PRINTF(("DEFERERASE "));
-                    }
-                    if (wp->flags & SWP_ASYNCWINDOWPOS) {
-                        EVENT_PRINTF(("ASYNCWINDOWPOS "));
-                    }
-                    if (wp->flags & SWP_HIDEWINDOW) {
-                        EVENT_PRINTF(("HIDEWINDOW "));
-                    }
-                    if (wp->flags & SWP_SHOWWINDOW) {
-                        EVENT_PRINTF(("SHOWWINDOW "));
-                    }
-
-                    EVENT_PRINTF(("] %d/%d %d/%d flags:%d (0x%x) ->",
-                                wp->x, wp->y, wp->cx, wp->cy, wp->flags, wp->flags));
-                    EVENT_PRINTF(("  client rect now: %d/%d %d/%d\n",x, y, w, h));
-
-                } /* __debug__ */
+	    if (inMove) {
+		*pDefault = 0;
+		return 0;
+	    }
+#endif
+	    if (hWnd == __rootWinSpezial) {
+		/* can this happen ? */
+		*pDefault = 1;
+		return 0;
+	    }
+
+	    if (! inMove && (__currentCapture == CAPTURE_NONE)) {
+		POINT p;
+		HWND hWndChild,hWndTemp;
+
+		p.x = evRootX;
+		p.y = evRootY;
+		ScreenToClient(hWnd, &p);
+		hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
+		do {
+		    hWndTemp = hWndChild;
+		    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
+		} while ((hWndChild) && (hWndChild != hWndTemp));
+
+		if (hWndChild /*&& (hWndChild != hWnd)*/) {
+		    if (hWndChild != __currentPointerView) {
+			int modifiers = getModifiers();
+
+			if (__currentPointerView) {
+			    if (inSizeMove) {
+				if (needDelayedMouseLeaveWindow == NULL) {
+				    needDelayedMouseLeaveWindow = __currentPointerView;
+				}
+			    } else {
+				if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+				    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
+				    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+				}
+			    }
+			    __currentPointerView = 0;
+			}
+			if (inSizeMove) {
+			    needDelayedMouseEnterWindow = hWndChild;
+			    delayedMouseEnterX = evRootX;
+			    delayedMouseEnterY = evRootY;
+			} else {
+			    if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
+				enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
+				SetWindow_mouseXY(hWndChild, evRootX, evRootY);
+			    }
+			    // SetFocus(hWndChild);
+			}
+			__currentPointerView = hWndChild;
+		    }
+		}
+	    }
+
+	    /*
+	     * ignore child window messages ...
+	     */
+	    if (GetParent(hWnd) != NULL) {
+		break;
+	    }
+
+	    {
+		WINDOWPOS *wp = (WINDOWPOS *)lParam;
+		RECT rct, dRect;
+		int x, y, w, h;
+		int dW, dH;
+
+#if 0
+		dRect.left = 0;
+		dRect.top = 0;
+		dRect.right = 100;
+		dRect.bottom = 100;
+		winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
+		winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
+		AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
+		dW = dRect.right - dRect.left;
+		dH = dRect.bottom - dRect.top;
+#endif
+		GetClientRect(hWnd, &rct);
+
+		x = rct.left;
+		y = rct.top;
+		w = rct.right - rct.left;
+		h = rct.bottom - rct.top;
+
+		if (__debug__) {
+		    EVENT_PRINTF(("WM_WINDOWPOSCHANGED ["));
+
+		    if (wp->flags & SWP_NOSIZE) {
+			EVENT_PRINTF(("NOSIZE "));
+		    }
+		    if (wp->flags & SWP_NOMOVE) {
+			EVENT_PRINTF(("NOMOVE "));
+		    }
+		    if (wp->flags & SWP_NOZORDER) {
+			EVENT_PRINTF(("NOZORDER "));
+		    }
+		    if (wp->flags & SWP_NOREDRAW) {
+			EVENT_PRINTF(("NOREDRAW "));
+		    }
+		    if (wp->flags & SWP_NOACTIVATE) {
+			EVENT_PRINTF(("NOACTIVATE "));
+		    }
+		    if (wp->flags & SWP_FRAMECHANGED) {
+			EVENT_PRINTF(("FRAMECHANGED "));
+		    }
+		    if (wp->flags & SWP_NOCOPYBITS) {
+			EVENT_PRINTF(("NOCOPYBITS "));
+		    }
+		    if (wp->flags & SWP_NOOWNERZORDER) {
+			EVENT_PRINTF(("NOOWNERZORDER "));
+		    }
+		    if (wp->flags & SWP_NOSENDCHANGING) {
+			EVENT_PRINTF(("NOSENDCHANGING "));
+		    }
+		    if (wp->flags & SWP_DEFERERASE) {
+			EVENT_PRINTF(("DEFERERASE "));
+		    }
+		    if (wp->flags & SWP_ASYNCWINDOWPOS) {
+			EVENT_PRINTF(("ASYNCWINDOWPOS "));
+		    }
+		    if (wp->flags & SWP_HIDEWINDOW) {
+			EVENT_PRINTF(("HIDEWINDOW "));
+		    }
+		    if (wp->flags & SWP_SHOWWINDOW) {
+			EVENT_PRINTF(("SHOWWINDOW "));
+		    }
+
+		    EVENT_PRINTF(("] %d/%d %d/%d flags:%d (0x%x) ->",
+				wp->x, wp->y, wp->cx, wp->cy, wp->flags, wp->flags));
+		    EVENT_PRINTF(("  client rect now: %d/%d %d/%d\n",x, y, w, h));
+
+		} /* __debug__ */
 #ifdef THIS_IS_WRONG
-                if (!(wp->flags & SWP_NOSIZE)) {
-                    EVENT_PRINTF(("w,h: %d/%d vs. %d/%d\n", wp->cx, wp->cy, w, h));
-                    w = wp->cx;
-                    h = wp->cy;
-                }
-                if (!(wp->flags & SWP_NOMOVE)) {
-                    EVENT_PRINTF(("x,y: %d/%d vs. %d/%d\n", wp->x, wp->y, x, y));
-                    x = wp->x;
-                    y = wp->y;
-                }
-#endif
-                lastPos_win = 0;
-
-                if ((w == 0) && (h == 0)) {
-                    EVENT_PRINTF(("w,h = 0.\n"));
-                    if (! GetWindow_iconified(hWnd)) {
-                        EVENT_PRINTF(("iconified.\n"));
-                        SetWindow_iconified(hWnd, 1);
-                        DPRINTF(("WM_WINDOWPOSCHANGED to iconified (flags:0x%x)\n", wp->flags));
-                        enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
-                    }
-                } else {
-                    if (GetWindow_iconified(hWnd)) {
-                        EVENT_PRINTF(("deiconified.\n"));
-                        SetWindow_iconified(hWnd, 0);
-                        DPRINTF(("WM_WINDOWPOSCHANGED to deiconified (flags:0x%x)\n", wp->flags));
-                        enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
-                    }
-                    if (!(wp->flags & SWP_NOSIZE)
-                     || !(wp->flags & SWP_NOMOVE)) {
-                        EVENT_PRINTF(("enq event %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
+		if (!(wp->flags & SWP_NOSIZE)) {
+		    EVENT_PRINTF(("w,h: %d/%d vs. %d/%d\n", wp->cx, wp->cy, w, h));
+		    w = wp->cx;
+		    h = wp->cy;
+		}
+		if (!(wp->flags & SWP_NOMOVE)) {
+		    EVENT_PRINTF(("x,y: %d/%d vs. %d/%d\n", wp->x, wp->y, x, y));
+		    x = wp->x;
+		    y = wp->y;
+		}
+#endif
+		lastPos_win = 0;
+
+		if ((w == 0) && (h == 0)) {
+		    EVENT_PRINTF(("w,h = 0.\n"));
+		    if (! GetWindow_iconified(hWnd)) {
+			EVENT_PRINTF(("iconified.\n"));
+			SetWindow_iconified(hWnd, 1);
+			DPRINTF(("WM_WINDOWPOSCHANGED to iconified (flags:0x%x)\n", wp->flags));
+			enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
+		    }
+		} else {
+		    if (GetWindow_iconified(hWnd)) {
+			EVENT_PRINTF(("deiconified.\n"));
+			SetWindow_iconified(hWnd, 0);
+			DPRINTF(("WM_WINDOWPOSCHANGED to deiconified (flags:0x%x)\n", wp->flags));
+			enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
+		    }
+		    if (!(wp->flags & SWP_NOSIZE)
+		     || !(wp->flags & SWP_NOMOVE)) {
+			EVENT_PRINTF(("enq event %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
 #ifdef COMPRESS_WINDOWPOSCHANGED
-                        /*
-                         * remember the current
-                         * window and size;
-                         * This allows the backend to ignore
-                         * intermediate events.
-                         */
-                        lastPos_w = w;
-                        lastPos_h = h;
-                        lastPos_x = x;
-                        lastPos_y = y;
-                        lastPos_win = hWnd;
-#endif
-                        enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
-                    } else {
-                        EVENT_PRINTF(("no event due to SWP_NOSIZE/SWP_NOMOVE.\n"));
-                    }
-                }
-            }
-            *pDefault = 0;
-            return 0;
-
-        case WM_ERASEBKGND:
-            DPRINTFIF(__debug_WM_ERASEBKGND__ , ("WM_ERASEBKGND\n"));
-            if (isNative) {
-                NDPRINTF(("WM_ERASEBKGND for native - default handling\n"));
-                return 0;
-            }
+			/*
+			 * remember the current
+			 * window and size;
+			 * This allows the backend to ignore
+			 * intermediate events.
+			 */
+			lastPos_w = w;
+			lastPos_h = h;
+			lastPos_x = x;
+			lastPos_y = y;
+			lastPos_win = hWnd;
+#endif
+			enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
+		    } else {
+			EVENT_PRINTF(("no event due to SWP_NOSIZE/SWP_NOMOVE.\n"));
+		    }
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
+
+	case WM_ERASEBKGND:
+	    DPRINTFIF(__debug_WM_ERASEBKGND__ , ("WM_ERASEBKGND\n"));
+	    if (isNative) {
+		NDPRINTF(("WM_ERASEBKGND for native - default handling\n"));
+		return 0;
+	    }
 
 #ifndef PRE_21_NOV
-            *pDefault = 0;
-            return 0;
-#else
-
-            if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
-                *pDefault = 0;
-                return 0;
-            }
-            if (hWnd == __rootWinSpezial) {
-                *pDefault = 0;
-                return 0;
-            }
-
-            /* THIS_WORKS */
-            *pDefault = 0;
-            return 0;
+	    *pDefault = 0;
+	    return 0;
+#else
+
+	    if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
+		*pDefault = 0;
+		return 0;
+	    }
+	    if (hWnd == __rootWinSpezial) {
+		*pDefault = 0;
+		return 0;
+	    }
+
+	    /* THIS_WORKS */
+	    *pDefault = 0;
+	    return 0;
 
 #endif  /* ! PRE_21_NOV */
 
-        case WM_PAINT:
-            DPRINTFIF(__debug_WM_PAINT__ , ("WM_PAINT ********************* "));
-
-            if (isNative) {
-                NDPRINTF(("WM_PAINT for native - default handling\n"));
-                return 0;
-            }
+	case WM_PAINT:
+	    DPRINTFIF(__debug_WM_PAINT__ , ("WM_PAINT ********************* "));
+
+	    if (isNative) {
+		NDPRINTF(("WM_PAINT for native - default handling\n"));
+		return 0;
+	    }
 
 #ifndef PRE_21_NOV
-            {   int n;
-
-                n = __generateExposes( hWnd, NULL, WM_PAINT, 0 );
-
-                if( n <= 0 ) {
-                    * pDefault = 1;
-                    return 0;
-                }
-                * pDefault = 0;
-                return n;
-            }
-#else
-
-
-
-            if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
-                *pDefault = 0;
-                return 0;
-            }
-
-            if (hWnd == __rootWinSpezial) {
+	    {   int n;
+
+		n = __generateExposes( hWnd, NULL, WM_PAINT, 0 );
+
+		if( n <= 0 ) {
+		    * pDefault = 1;
+		    return 0;
+		}
+		* pDefault = 0;
+		return n;
+	    }
+#else
+
+
+
+	    if (GetWindow_flag(hWnd) & LI_INPUTWIN) {
+		*pDefault = 0;
+		return 0;
+	    }
+
+	    if (hWnd == __rootWinSpezial) {
 # ifdef THIS_MAKES_GUI_PAINTER_START_SLOW
-                *pDefault = 0;
-# endif
-                return 0;
-            }
-
-            {
-                int retVal;
+		*pDefault = 0;
+# endif
+		return 0;
+	    }
+
+	    {
+		int retVal;
 
 # ifdef LATE_GENERATE_EXPOSE
-                enqEvent(0, hWnd, __WM_PAINT, 0, 0, 0, 0, 0, EV_NOTIME);
+		enqEvent(0, hWnd, __WM_PAINT, 0, 0, 0, 0, 0, EV_NOTIME);
 # else
-                AQUIRE_DRAW_MUTEX
-                retVal = __generateExposes(hWnd, NULL, WM_PAINT, WM_PAINT_CLEAR_EARLY);
-                RELEASE_DRAW_MUTEX
-# endif
-                switch (retVal) {
-                    case -1:  /* error */
-                        *pDefault = 0;
-                        break;
-                    case 0:   /* nothing generated */
-                    default:  /* generated events */
-                        break;
-                }
+		AQUIRE_DRAW_MUTEX
+		retVal = __generateExposes(hWnd, NULL, WM_PAINT, WM_PAINT_CLEAR_EARLY);
+		RELEASE_DRAW_MUTEX
+# endif
+		switch (retVal) {
+		    case -1:  /* error */
+			*pDefault = 0;
+			break;
+		    case 0:   /* nothing generated */
+		    default:  /* generated events */
+			break;
+		}
 # ifdef THIS_IS_BAD
-                *pDefault = 0;
-                return 1;
-# endif
-            }
-            return 0;
+		*pDefault = 0;
+		return 1;
+# endif
+	    }
+	    return 0;
 
 #endif  /* ! PRE_21_NOV */
 
-        case WM_SIZE:
-            DPRINTFIF(__debug_WM_SIZE__ , ("WM_SIZE\n"));
-
-            lastPos_win = 0;
-            /*
-             * ignore child window messages ...
-             */
-            if (GetParent(hWnd) != NULL) {
-                *pDefault = 0;
-                return 0;
-            }
-
-            switch (wParam) {
-                case SIZE_MAXIMIZED:     /* default handling */
-                case SIZE_MINIMIZED:     /* default handling */
-                case SIZE_RESTORED:      /* default handling */
-                    {
-                        RECT rct;
-                        int x, y, w, h;
-
-                        GetClientRect(hWnd, &rct);
-
-                        x = rct.left;
-                        y = rct.top;
-                        w = rct.right - rct.left;
-                        h = rct.bottom - rct.top;
-
-                        EVENT_PRINTF(("WM_MIN/MAX/RESTORED\n"));
-
-                        if ((w == 0) && (h == 0)) {
-                            /*
-                             * iconified ...
-                             */
-                            if (! GetWindow_iconified(hWnd)) {
-                                SetWindow_iconified(hWnd, 1);
-                                enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
-                            }
-                        } else {
-                            if (GetWindow_iconified(hWnd)) {
-                                SetWindow_iconified(hWnd, 0);
-                                enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
-                            }
-                            EVENT_PRINTF(("enq event2 %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
+	case WM_SIZE:
+	    DPRINTFIF(__debug_WM_SIZE__ , ("WM_SIZE\n"));
+
+	    lastPos_win = 0;
+	    /*
+	     * ignore child window messages ...
+	     */
+	    if (GetParent(hWnd) != NULL) {
+		*pDefault = 0;
+		return 0;
+	    }
+
+	    switch (wParam) {
+		case SIZE_MAXIMIZED:     /* default handling */
+		case SIZE_MINIMIZED:     /* default handling */
+		case SIZE_RESTORED:      /* default handling */
+		    {
+			RECT rct;
+			int x, y, w, h;
+
+			GetClientRect(hWnd, &rct);
+
+			x = rct.left;
+			y = rct.top;
+			w = rct.right - rct.left;
+			h = rct.bottom - rct.top;
+
+			EVENT_PRINTF(("WM_MIN/MAX/RESTORED\n"));
+
+			if ((w == 0) && (h == 0)) {
+			    /*
+			     * iconified ...
+			     */
+			    if (! GetWindow_iconified(hWnd)) {
+				SetWindow_iconified(hWnd, 1);
+				enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
+			    }
+			} else {
+			    if (GetWindow_iconified(hWnd)) {
+				SetWindow_iconified(hWnd, 0);
+				enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
+			    }
+			    EVENT_PRINTF(("enq event2 %x: %d, %d, %d, %d\n", hWnd, x, y, w, h));
 #ifdef COMPRESS_WINDOWPOSCHANGED
-                            /*
-                             * remember the current
-                             * window and size;
-                             * This allows the backend to ignore
-                             * intermediate events.
-                             */
-                            lastPos_w = w;
-                            lastPos_h = h;
-                            lastPos_x = x;
-                            lastPos_y = y;
-                            lastPos_win = hWnd;
-#endif
-                            enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
-                        }
-                   }
-                   break;
-
-                default:                 /* ignore */
-                    *pDefault = 0;
-                    return 0;
-            }
-            break;
-
-        case WM_DROPFILES:
-            DPRINTFIF(__debug_WM_DROPFILES__ , ("WM_DROPFILES\n"));
-            enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_SHOWWINDOW:
-            DPRINTFIF(__debug_WM_SHOWWINDOW__ , ("WM_SHOWWINDOW h=%x\n", hWnd));
-            enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
-            if (isNative) {
-                NDPRINTF(("WM_SHOWWINDOW for native - default handling\n"));
-                return 0;
-            }
-            *pDefault = 0;
-            break;
-
-        case WM_MOUSEACTIVATE :
-            DPRINTFIF(__debug_WM_MOUSEACTIVATE__ , ("WM_MOUSEACTIVATE h=%x parent=%x\n", hWnd, GetParent(hWnd)));
-
-            /*
-             * ignore child window messages ...
-             */
-            if (GetParent(hWnd)) {
-                return 0;
-            }
-
-            *pDefault = 0;
-            if ((hWnd == __rootWinSpezial) || (hWnd == GetActiveWindow())) {
-                DDPRINTF(("NOACTIVATE (root or already)\n"));
-                return MA_NOACTIVATE;
-            }
-            if (LOWORD(lParam) != HTCLIENT) {
-                DDPRINTF(("ACTIVATE (not client)\n"));
-                return MA_ACTIVATE;
-            }
-            if (__activateOnClick) {
-                if (__ignoreButtonPressOnActivate) {
-                    DDPRINTF(("ACTIVATE_EAT\n"));
-                    /*
-                     * windows is sooo stupid:
-                     * it will send me a MOTION soon after, with the
-                     * to the click location, with the buttonState down.
-                     * The app will interpret that as a pressed motion and
-                     * do a selection (if in a textview).
-                     * To prevent this, we set a flag here, that the following
-                     * motion is to be suppressed.
-                     * Until the mouse is released.
-                     */
-                    __eatingMouseEvents = 1;
-                    return MA_ACTIVATEANDEAT;
-                }
-                DDPRINTF(("ACTIVATE\n"));
-                return MA_ACTIVATE;
-            }
-            DDPRINTF(("NO_ACTIVATE\n"));
-            return MA_NOACTIVATE;
-
-        case WM_NCHITTEST:
-            EVENT_PRINTF2(("WM_NCHITTEST\n"));
-            if (hWnd == __rootWinSpezial) {
-                *pDefault = 0;
-                return HTCLIENT;
-            }
-            break;
-
-        case WM_NCACTIVATE:
-            EVENT_PRINTF(("WM_NCACTIVATE\n"));
-            break;
-
-        case WM_ACTIVATE:
-            CPRINTF(("WM_ACTIVATE %s h=%x\n", LOWORD(wParam) ? "active" : "inactive", hWnd));
-
-            switch (LOWORD(wParam)) {
-                case WA_INACTIVE:
-                    EVENT_PRINTF2(("WM_ACTIVATE inactive h=%x\n", hWnd));
-                    break;
-
-                case WA_ACTIVE:
-                    EVENT_PRINTF2(("WM_ACTIVATE active h=%x\n", hWnd));
+			    /*
+			     * remember the current
+			     * window and size;
+			     * This allows the backend to ignore
+			     * intermediate events.
+			     */
+			    lastPos_w = w;
+			    lastPos_h = h;
+			    lastPos_x = x;
+			    lastPos_y = y;
+			    lastPos_win = hWnd;
+#endif
+			    enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
+			}
+		   }
+		   break;
+
+		default:                 /* ignore */
+		    *pDefault = 0;
+		    return 0;
+	    }
+	    break;
+
+	case WM_DROPFILES:
+	    DPRINTFIF(__debug_WM_DROPFILES__ , ("WM_DROPFILES\n"));
+	    enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_SHOWWINDOW:
+	    DPRINTFIF(__debug_WM_SHOWWINDOW__ , ("WM_SHOWWINDOW h=%x\n", hWnd));
+	    enqEvent(0, hWnd, message, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    if (isNative) {
+		NDPRINTF(("WM_SHOWWINDOW for native - default handling\n"));
+		return 0;
+	    }
+	    *pDefault = 0;
+	    break;
+
+	case WM_MOUSEACTIVATE :
+	    DPRINTFIF(__debug_WM_MOUSEACTIVATE__ , ("WM_MOUSEACTIVATE h=%x parent=%x\n", hWnd, GetParent(hWnd)));
+
+	    /*
+	     * ignore child window messages ...
+	     */
+	    if (GetParent(hWnd)) {
+		return 0;
+	    }
+
+	    *pDefault = 0;
+	    if ((hWnd == __rootWinSpezial) || (hWnd == GetActiveWindow())) {
+		DDPRINTF(("NOACTIVATE (root or already)\n"));
+		return MA_NOACTIVATE;
+	    }
+	    if (LOWORD(lParam) != HTCLIENT) {
+		DDPRINTF(("ACTIVATE (not client)\n"));
+		return MA_ACTIVATE;
+	    }
+	    if (__activateOnClick) {
+		if (__ignoreButtonPressOnActivate) {
+		    DDPRINTF(("ACTIVATE_EAT\n"));
+		    /*
+		     * windows is sooo stupid:
+		     * it will send me a MOTION soon after, with the
+		     * to the click location, with the buttonState down.
+		     * The app will interpret that as a pressed motion and
+		     * do a selection (if in a textview).
+		     * To prevent this, we set a flag here, that the following
+		     * motion is to be suppressed.
+		     * Until the mouse is released.
+		     */
+		    __eatingMouseEvents = 1;
+		    return MA_ACTIVATEANDEAT;
+		}
+		DDPRINTF(("ACTIVATE\n"));
+		return MA_ACTIVATE;
+	    }
+	    DDPRINTF(("NO_ACTIVATE\n"));
+	    return MA_NOACTIVATE;
+
+	case WM_NCHITTEST:
+	    EVENT_PRINTF2(("WM_NCHITTEST\n"));
+	    if (hWnd == __rootWinSpezial) {
+		*pDefault = 0;
+		return HTCLIENT;
+	    }
+	    break;
+
+	case WM_NCACTIVATE:
+	    EVENT_PRINTF(("WM_NCACTIVATE\n"));
+	    break;
+
+	case WM_ACTIVATE:
+	    CPRINTF(("WM_ACTIVATE %s h=%x\n", LOWORD(wParam) ? "active" : "inactive", hWnd));
+
+	    switch (LOWORD(wParam)) {
+		case WA_INACTIVE:
+		    EVENT_PRINTF2(("WM_ACTIVATE inactive h=%x\n", hWnd));
+		    break;
+
+		case WA_ACTIVE:
+		    EVENT_PRINTF2(("WM_ACTIVATE active h=%x\n", hWnd));
 
 #ifdef THIS_DOES_NOT_AVOID_DOUBLE_REPAINTS
-                    __generateRecursiveExposes(hWnd, WM_PAINT);
+		    __generateRecursiveExposes(hWnd, WM_PAINT);
 #endif /* sigh */
-                    break;
-
-                case WA_CLICKACTIVE:
-                    EVENT_PRINTF2(("++ WM_ACTIVATE clkactive h=%x\n", hWnd));
-                    break;
-
-                default:
-                    EVENT_PRINTF2(("WM_ACTIVATE ? h=%x\n", hWnd));
-                    break;
-            }
+		    break;
+
+		case WA_CLICKACTIVE:
+		    EVENT_PRINTF2(("++ WM_ACTIVATE clkactive h=%x\n", hWnd));
+		    break;
+
+		default:
+		    EVENT_PRINTF2(("WM_ACTIVATE ? h=%x\n", hWnd));
+		    break;
+	    }
 
 #ifndef PRE_25_NOV_03
-            if (__currentCapture == CAPTURE_NONE) {
-                HWND  newHWnd = 0;
-                POINT newPoint;
-
-                if (LOWORD(wParam) != WA_INACTIVE) {
-                    if (MustHandleButtonEvent()) {
-                        newPoint.x = evRootX;
-                        newPoint.y = evRootY;
-
-                        newHWnd = WindowFromPoint (newPoint);
-
-                        if (newHWnd) {
-                            if ( (newHWnd == hWnd) || IsChild(hWnd, newHWnd) ) {
-                                ScreenToClient (newHWnd, & newPoint);
-
-                                if ((newPoint.x < 0) || (newPoint.y < 0)) {
-                                    newHWnd = 0;
-                                }
-                            } else {
-                                newHWnd = 0;
-                            }
-                        }
-                    }
-                }
-                CPRINTF(( "Old Handle: %x New Handle: %x  x:%d y:%d\n", __currentPointerView, newHWnd, newPoint.x, newPoint.y));
-
-                if (newHWnd != __currentPointerView) {
-                    int modifiers = getModifiers();
-
-                    if (__currentPointerView) {
-                        if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                            enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
-                            SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-                        }
-                    }
-                    __currentPointerView = newHWnd;
-
-                    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                        enqEvent(EnterWindowMask, __currentPointerView, __WM_MOUSEENTER, 0, newPoint.x, newPoint.y, 0, modifiers, EV_NOTIME);
-                        SetWindow_mouseXY(__currentPointerView, newPoint.x, newPoint.y);
-                    }
-                }
-            }
-#endif
-            enqEvent(0, hWnd, WM_ACTIVATE, wParam, 0, 0, 0, 0, EV_NOTIME);
-
-            if (isNative) {
-                return 0;
-            }
-            break;
-
-        case WM_HOTKEY:
-            // console_fprintf(stderr, "winEventProcessing [info]: receive hotkey %x\n",wParam);
-            DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", wParam));
-            {
-                enqEvent(0, hWnd, WM_HOTKEY, wParam, lParam, 0, 0, 0, evTime);
-            }
-            break;
-
-        case WM_SYSCHAR:
-            EVENT_PRINTF2(("WM_SYSCHAR h=%x %x\n", hWnd, wParam));
-            goto commonChar;
+	    if (__currentCapture == CAPTURE_NONE) {
+		HWND  newHWnd = 0;
+		POINT newPoint;
+
+		if (LOWORD(wParam) != WA_INACTIVE) {
+		    if (MustHandleButtonEvent()) {
+			newPoint.x = evRootX;
+			newPoint.y = evRootY;
+
+			newHWnd = WindowFromPoint (newPoint);
+
+			if (newHWnd) {
+			    if ( (newHWnd == hWnd) || IsChild(hWnd, newHWnd) ) {
+				ScreenToClient (newHWnd, & newPoint);
+
+				if ((newPoint.x < 0) || (newPoint.y < 0)) {
+				    newHWnd = 0;
+				}
+			    } else {
+				newHWnd = 0;
+			    }
+			}
+		    }
+		}
+		CPRINTF(( "Old Handle: %x New Handle: %x  x:%d y:%d\n", __currentPointerView, newHWnd, newPoint.x, newPoint.y));
+
+		if (newHWnd != __currentPointerView) {
+		    int modifiers = getModifiers();
+
+		    if (__currentPointerView) {
+			if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+			    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
+			    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+			}
+		    }
+		    __currentPointerView = newHWnd;
+
+		    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+			enqEvent(EnterWindowMask, __currentPointerView, __WM_MOUSEENTER, 0, newPoint.x, newPoint.y, 0, modifiers, EV_NOTIME);
+			SetWindow_mouseXY(__currentPointerView, newPoint.x, newPoint.y);
+		    }
+		}
+	    }
+#endif
+	    enqEvent(0, hWnd, WM_ACTIVATE, wParam, 0, 0, 0, 0, EV_NOTIME);
+
+	    if (isNative) {
+		return 0;
+	    }
+	    break;
+
+	case WM_HOTKEY:
+	    // console_fprintf(stderr, "winEventProcessing [info]: receive hotkey %x\n",wParam);
+	    DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", wParam));
+	    {
+		enqEvent(0, hWnd, WM_HOTKEY, wParam, lParam, 0, 0, 0, evTime);
+	    }
+	    break;
+
+	case WM_SYSCHAR:
+	    EVENT_PRINTF2(("WM_SYSCHAR h=%x %x\n", hWnd, wParam));
+	    goto commonChar;
 
 #ifdef WM_UNICHAR
-        /* does not work, anyway */
-        case WM_UNICHAR:
-            DPRINTFIF(__debug_WM_CHAR__ , ("WM_UNICHAR h=%x %x\n", hWnd, wParam));
-            if (wParam == UNICODE_NOCHAR) {
-                /* this is a query from windows to see if I am able to receive unicode... */
-                *pDefault = 0;
-                return 1;
-            }
-            goto commonChar;
-#endif
-
-        case WM_CHAR:
-            DPRINTFIF(__debug_WM_CHAR__ , ("WM_CHAR h=%x %x\n", hWnd, wParam));
-#if 0
-            EVENT_PRINTF2(("WM_CHAR h=%x %x\n", hWnd, wParam));
-#endif
-        commonChar:
-            if (isNative) {
-                NDPRINTF(("WM_CHAR for native - default handling\n"));
-                return 0;
-            }
-
-            {
-                HWND destWindow;
-                int evMask;
-
-                if (__focusFollowsMouse) {
-                    destWindow = __currentPointerView;
-                    if (destWindow == 0) {
-                        destWindow = hWnd;
-                    }
-                } else {
-                    destWindow = hWnd;
-                }
-
-                evMask = GetWindow_eventMask(destWindow);
-                if (evMask & (KeyPressMask | KeyReleaseMask)) {
-                    POINT p;
-                    int modifiers = getModifiers();
-
-                    p.x = evRootX;
-                    p.y = evRootY;
-                    ScreenToClient(destWindow, &p);
-                    x = p.x;
-                    y = p.y;
-
-                    DPRINTFIF(__debug_WM_CHAR__ , ("key:%x modifiers: %x\n", wParam, modifiers));
-                    if (evMask & KeyPressMask)
-                        enqEvent(KeyPressMask, destWindow, WM_KEYDOWN, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
-                    if (evMask & KeyReleaseMask)
-                        enqEvent(KeyReleaseMask, destWindow, WM_KEYUP, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
-                }
-            }
-            *pDefault = 0;
-            return 0;
-
-
-        case WM_KEYUP:
-            DPRINTFIF(__debug_WM_KEYUP__ , ("WM_KEYUP h=%x %x\n", hWnd, wParam));
-            goto commonKeyUp;
-
-        case WM_SYSKEYUP:
-            DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n, wParam"));
-        commonKeyUp:
-            if (isNative) {
-                NDPRINTF(("WM_KEYUP/WM_SYSKEYUP for native - default handling\n"));
-                return 0;
-            }
-            {
-                HWND destWindow;
-
-                if (__focusFollowsMouse) {
-                    destWindow = __currentPointerView;
-                    if (destWindow == 0) {
-                        destWindow = hWnd;
-                    }
-                } else {
-                    destWindow = hWnd;
-                }
-
-                if (GetWindow_eventMask(destWindow) & KeyReleaseMask) {
-                    POINT p;
-
-                    p.x = evRootX;
-                    p.y = evRootY;
-                    ScreenToClient(destWindow, &p);
-                    x = p.x;
-                    y = p.y;
-
-                    enqEvent(KeyReleaseMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
-                }
-            }
-            *pDefault = 0;
-            return 0;
-
-        case WM_SYSKEYDOWN:
-            DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n, wParam"));
-            goto commonKey;
-
-        case WM_KEYDOWN:
-            DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN h=%x %x\n", hWnd, wParam));
-        commonKey:
-            if (isNative) {
-                NDPRINTF(("WM_KEYDOWN/WM_SYSKEYDOWN for native - default handling\n"));
-                return 0;
-            }
+	/* does not work, anyway */
+	case WM_UNICHAR:
+	    DPRINTFIF(__debug_WM_CHAR__ , ("WM_UNICHAR h=%x %x\n", hWnd, wParam));
+	    if (wParam == UNICODE_NOCHAR) {
+		/* this is a query from windows to see if I am able to receive unicode... */
+		*pDefault = 0;
+		return 1;
+	    }
+	    goto commonChar;
+#endif
+
+	case WM_CHAR:
+	    DPRINTFIF(__debug_WM_CHAR__ , ("WM_CHAR h=%x %x\n", hWnd, wParam));
+#if 0
+	    EVENT_PRINTF2(("WM_CHAR h=%x %x\n", hWnd, wParam));
+#endif
+	commonChar:
+	    if (isNative) {
+		NDPRINTF(("WM_CHAR for native - default handling\n"));
+		return 0;
+	    }
+
+	    {
+		HWND destWindow;
+		int evMask;
+
+		if (__focusFollowsMouse) {
+		    destWindow = __currentPointerView;
+		    if (destWindow == 0) {
+			destWindow = hWnd;
+		    }
+		} else {
+		    destWindow = hWnd;
+		}
+
+		evMask = GetWindow_eventMask(destWindow);
+		if (evMask & (KeyPressMask | KeyReleaseMask)) {
+		    POINT p;
+		    int modifiers = getModifiers();
+
+		    p.x = evRootX;
+		    p.y = evRootY;
+		    ScreenToClient(destWindow, &p);
+		    x = p.x;
+		    y = p.y;
+
+		    DPRINTFIF(__debug_WM_CHAR__ , ("key:%x modifiers: %x\n", wParam, modifiers));
+		    if (evMask & KeyPressMask)
+			enqEvent(KeyPressMask, destWindow, WM_KEYDOWN, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
+		    if (evMask & KeyReleaseMask)
+			enqEvent(KeyReleaseMask, destWindow, WM_KEYUP, wParam, x, y, lParam, (modifiers | TRANSLATED_KEY), evTime);
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
+
+
+	case WM_KEYUP:
+	    DPRINTFIF(__debug_WM_KEYUP__ , ("WM_KEYUP h=%x %x\n", hWnd, wParam));
+	    goto commonKeyUp;
+
+	case WM_SYSKEYUP:
+	    DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n, wParam"));
+	commonKeyUp:
+	    if (isNative) {
+		NDPRINTF(("WM_KEYUP/WM_SYSKEYUP for native - default handling\n"));
+		return 0;
+	    }
+	    {
+		HWND destWindow;
+
+		if (__focusFollowsMouse) {
+		    destWindow = __currentPointerView;
+		    if (destWindow == 0) {
+			destWindow = hWnd;
+		    }
+		} else {
+		    destWindow = hWnd;
+		}
+
+		if (GetWindow_eventMask(destWindow) & KeyReleaseMask) {
+		    POINT p;
+
+		    p.x = evRootX;
+		    p.y = evRootY;
+		    ScreenToClient(destWindow, &p);
+		    x = p.x;
+		    y = p.y;
+
+		    enqEvent(KeyReleaseMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
+
+	case WM_SYSKEYDOWN:
+	    DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n, wParam"));
+	    goto commonKey;
+
+	case WM_KEYDOWN:
+	    DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN h=%x %x\n", hWnd, wParam));
+	commonKey:
+	    if (isNative) {
+		NDPRINTF(("WM_KEYDOWN/WM_SYSKEYDOWN for native - default handling\n"));
+		return 0;
+	    }
 
 #ifdef EXIT_WITH_3_CTRL_Cs
-            if ((msg.wParam == 'c')
-             && (GetKeyState(VK_CONTROL) & 0x8000)) {
-                /* CTRL-C */
-                if (ctrl_c_count++ > 3)  /* for debugging */
-                    exit(1);
-            } else {
-                if (msg.wParam != VK_CONTROL)
-                    ctrl_c_count = 0;
-            }
+	    if ((msg.wParam == 'c')
+	     && (GetKeyState(VK_CONTROL) & 0x8000)) {
+		/* CTRL-C */
+		if (ctrl_c_count++ > 3)  /* for debugging */
+		    exit(1);
+	    } else {
+		if (msg.wParam != VK_CONTROL)
+		    ctrl_c_count = 0;
+	    }
 #endif
 #ifdef RELEASE_CAPTURE_WITH_3_ESCAPEs
-            if (msg.wParam == VK_ESCAPE)) {
-                /* ESCAPE */
-                if (escape_count++ > 3) {
-                    __currentCapture = CAPTURE_NONE;
-                    ReleaseCapture();
-                    CPRINTF(("ReleaseCapture <ESC>\n"));
-                }
-            } else {
-                escape_count = 0;
-            }
-#endif
-            /* FALL INTO */
-
-            {
-                HWND destWindow;
-
-                if (__focusFollowsMouse) {
-                    destWindow = __currentPointerView;
-                    if (destWindow == 0) {
-                        destWindow = hWnd;
-                    }
-                } else {
-                    destWindow = hWnd;
-                }
-
-                if (GetWindow_eventMask(destWindow) & KeyPressMask) {
-                    POINT p;
-
-                    p.x = evRootX;
-                    p.y = evRootY;
-                    ScreenToClient(destWindow, &p);
-                    x = p.x;
-                    y = p.y;
-
-                    enqEvent(KeyPressMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
-                }
-            }
-            *pDefault = 0;
-            return 0;
+	    if (msg.wParam == VK_ESCAPE)) {
+		/* ESCAPE */
+		if (escape_count++ > 3) {
+		    __currentCapture = CAPTURE_NONE;
+		    ReleaseCapture();
+		    CPRINTF(("ReleaseCapture <ESC>\n"));
+		}
+	    } else {
+		escape_count = 0;
+	    }
+#endif
+	    /* FALL INTO */
+
+	    {
+		HWND destWindow;
+
+		if (__focusFollowsMouse) {
+		    destWindow = __currentPointerView;
+		    if (destWindow == 0) {
+			destWindow = hWnd;
+		    }
+		} else {
+		    destWindow = hWnd;
+		}
+
+		if (GetWindow_eventMask(destWindow) & KeyPressMask) {
+		    POINT p;
+
+		    p.x = evRootX;
+		    p.y = evRootY;
+		    ScreenToClient(destWindow, &p);
+		    x = p.x;
+		    y = p.y;
+
+		    enqEvent(KeyPressMask, destWindow, message, wParam, x, y, lParam, getModifiers(), evTime);
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
 
 #ifdef WM_MOUSEWHEEL
-        case WM_MOUSEWHEEL:
-            {
-                HWND destWindow;
-
-                if (__focusFollowsMouse) {
-                    destWindow = __currentPointerView;
-                    if (destWindow == 0) {
-                        destWindow = hWnd;
-                    }
-                } else {
-                    destWindow = hWnd;
-                }
-
-
-                EVENT_PRINTF(("WM_MOUSEWHEEL h=%x wP=%x lP=%x\n", hWnd, wParam, lParam));
-                if (GetWindow_eventMask(destWindow) & KeyPressMask) {
-                    POINT p;
-                    int delta;
-
-                    p.x = evRootX;
-                    p.y = evRootY;
-                    ScreenToClient(destWindow, &p);
-                    x = p.x;
-                    y = p.y;
-                    delta = evTime - lastMouseWheelTime;
-                    if (evTime < lastMouseWheelTime) {
-                        delta = (0xFFFFFFFF - lastMouseWheelTime) + evTime;
-                    }
-                    enqEvent(0, destWindow, message, wParam, x, y, lParam, getModifiers(), delta);
-                }
-                lastMouseWheelTime = evTime;
-            }
-            *pDefault = 0;
-            return 0;
-#endif
-
-        case WM_MOUSEMOVE:
-            DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("WM_MOUSEMOVE h=%x\n", hWnd));
-            if (isNative) {
-                NDPRINTF(("WM_MOUSEMOVE for native - default handling\n"));
-                return 0;
-            }
-
-            if (hWnd != __currentPointerView) {
-                if (! MustHandleButtonEvent()) {
-                    *pDefault = 0;
-                    return 0;
-                }
-            }
-
-            {
-                short x, y;
-                int modifiers = getModifiers();
-
-                x = (int)(short)LOWORD(lParam);
-                y = (int)(short)HIWORD(lParam);
-
-                if (__currentCapture == CAPTURE_NONE) {
-                    if (hWnd != __currentPointerView) {
-                        HWND prevPointerView;
-
-                        prevPointerView = __currentPointerView;
-                        if (prevPointerView) {
-                            if (inSizeMove) {
-                                if (needDelayedMouseLeaveWindow == NULL) {
-                                    needDelayedMouseLeaveWindow = __currentPointerView;
-                                }
-                            } else {
-                                if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                                    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, evTime);
-                                    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-                                }
-                            }
-                            __currentPointerView = 0;
-                        }
-
-#if 0
-                        if (__activateOnClick) {
-                            /*
-                             * only send mouseEnter if the window belongs to the current
-                             * active window
-                             */
-                            if (GetTopParent(prevPointerView) == GetTopParent(hWnd)) {
-                            }
-                        }
-#endif
-                        if (inSizeMove) {
-                            needDelayedMouseEnterWindow = hWnd;
-                            delayedMouseEnterX = x;
-                            delayedMouseEnterY = y;
-                        } else {
-                            if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
-                                enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, x, y, 0, modifiers, evTime);
-                                SetWindow_mouseXY(hWnd, x, y);
-                            }
-                        }
-                        __currentPointerView = hWnd;
-                    }
-                    DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("MouseMove %x\n", __currentPointerView));
-                } else {
-                    CPRINTF(("MouseMove Capture %x\n", __currentPointerView));
-                }
-
-                if ((GetWindow_eventMask(__currentPointerView) & PointerMotionMask)
-                 || (modifiers & AnyButtonMask)) {
-                    if (! __eatingMouseEvents) {
-                        if ((x == lastMotionX)
-                         && (y == lastMotionY)
-                         && (__currentPointerView == lastMotionWnd)) {
-                            /* ignore */
-                        } else {
-                            lastMotionX = x;
-                            lastMotionY = y;
-                            lastMotionWnd = __currentPointerView;
-
-                            if ((GetWindow_mouseX(__currentPointerView) == x)
-                             && (GetWindow_mouseY(__currentPointerView) == y)) {
-                            } else {
-                                enqEvent(PointerMotionMask, __currentPointerView, WM_MOUSEMOVE, wParam, x, y, 0, modifiers, evTime);
-                                SetWindow_mouseXY(__currentPointerView, x, y);
-                            }
-                        }
-                    }
-                }
-            }
-            *pDefault = 0;
-            return 0;
-
-        case WM_LBUTTONUP:
-            DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_LBUTTONUP h=%x\n", hWnd));
-            curButton = Button1;
-            goto commonButtonUp;
-        case WM_MBUTTONUP:
-            DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_MBUTTONUP h=%x\n", hWnd));
-            curButton = Button2;
-            goto commonButtonUp;
-        case WM_RBUTTONUP:
-            DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_RBUTTONUP h=%x\n", hWnd));
-            curButton = Button3;
+	case WM_MOUSEWHEEL:
+	    {
+		HWND destWindow;
+
+		if (__focusFollowsMouse) {
+		    destWindow = __currentPointerView;
+		    if (destWindow == 0) {
+			destWindow = hWnd;
+		    }
+		} else {
+		    destWindow = hWnd;
+		}
+
+
+		EVENT_PRINTF(("WM_MOUSEWHEEL h=%x wP=%x lP=%x\n", hWnd, wParam, lParam));
+		if (GetWindow_eventMask(destWindow) & KeyPressMask) {
+		    POINT p;
+		    int delta;
+
+		    p.x = evRootX;
+		    p.y = evRootY;
+		    ScreenToClient(destWindow, &p);
+		    x = p.x;
+		    y = p.y;
+		    delta = evTime - lastMouseWheelTime;
+		    if (evTime < lastMouseWheelTime) {
+			delta = (0xFFFFFFFF - lastMouseWheelTime) + evTime;
+		    }
+		    enqEvent(0, destWindow, message, wParam, x, y, lParam, getModifiers(), delta);
+		}
+		lastMouseWheelTime = evTime;
+	    }
+	    *pDefault = 0;
+	    return 0;
+#endif
+
+	case WM_MOUSEMOVE:
+	    DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("WM_MOUSEMOVE h=%x\n", hWnd));
+	    if (isNative) {
+		NDPRINTF(("WM_MOUSEMOVE for native - default handling\n"));
+		return 0;
+	    }
+
+	    if (hWnd != __currentPointerView) {
+		if (! MustHandleButtonEvent()) {
+		    *pDefault = 0;
+		    return 0;
+		}
+	    }
+
+	    {
+		short x, y;
+		int modifiers = getModifiers();
+
+		x = (int)(short)LOWORD(lParam);
+		y = (int)(short)HIWORD(lParam);
+
+		if (__currentCapture == CAPTURE_NONE) {
+		    if (hWnd != __currentPointerView) {
+			HWND prevPointerView;
+
+			prevPointerView = __currentPointerView;
+			if (prevPointerView) {
+			    if (inSizeMove) {
+				if (needDelayedMouseLeaveWindow == NULL) {
+				    needDelayedMouseLeaveWindow = __currentPointerView;
+				}
+			    } else {
+				if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+				    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, evTime);
+				    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+				}
+			    }
+			    __currentPointerView = 0;
+			}
+
+#if 0
+			if (__activateOnClick) {
+			    /*
+			     * only send mouseEnter if the window belongs to the current
+			     * active window
+			     */
+			    if (GetTopParent(prevPointerView) == GetTopParent(hWnd)) {
+			    }
+			}
+#endif
+			if (inSizeMove) {
+			    needDelayedMouseEnterWindow = hWnd;
+			    delayedMouseEnterX = x;
+			    delayedMouseEnterY = y;
+			} else {
+			    if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
+				enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, x, y, 0, modifiers, evTime);
+				SetWindow_mouseXY(hWnd, x, y);
+			    }
+			}
+			__currentPointerView = hWnd;
+		    }
+		    DPRINTFIF(__debug_WM_MOUSEMOVE__ , ("MouseMove %x\n", __currentPointerView));
+		} else {
+		    CPRINTF(("MouseMove Capture %x\n", __currentPointerView));
+		}
+
+		if ((GetWindow_eventMask(__currentPointerView) & PointerMotionMask)
+		 || (modifiers & AnyButtonMask)) {
+		    if (! __eatingMouseEvents) {
+			if ((x == lastMotionX)
+			 && (y == lastMotionY)
+			 && (__currentPointerView == lastMotionWnd)) {
+			    /* ignore */
+			} else {
+			    lastMotionX = x;
+			    lastMotionY = y;
+			    lastMotionWnd = __currentPointerView;
+
+			    if ((GetWindow_mouseX(__currentPointerView) == x)
+			     && (GetWindow_mouseY(__currentPointerView) == y)) {
+			    } else {
+				enqEvent(PointerMotionMask, __currentPointerView, WM_MOUSEMOVE, wParam, x, y, 0, modifiers, evTime);
+				SetWindow_mouseXY(__currentPointerView, x, y);
+			    }
+			}
+		    }
+		}
+	    }
+	    *pDefault = 0;
+	    return 0;
+
+	case WM_LBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_LBUTTONUP h=%x\n", hWnd));
+	    curButton = Button1;
+	    goto commonButtonUp;
+	case WM_MBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_MBUTTONUP h=%x\n", hWnd));
+	    curButton = Button2;
+	    goto commonButtonUp;
+	case WM_RBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_RBUTTONUP h=%x\n", hWnd));
+	    curButton = Button3;
 commonButtonUp:
-            if (isNative) {
-                NDPRINTF(("WM_*BUTTONUP for native - default handling\n"));
-                return 0;
-            }
+	    if (isNative) {
+		NDPRINTF(("WM_*BUTTONUP for native - default handling\n"));
+		return 0;
+	    }
 
 #ifndef PRE_01_APR_04
-            if ((__currentPointerView != hWnd) && (__currentPointerView == (HANDLE)0)) {
-                __currentPointerView = hWnd;
-
-                if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
-                    POINT p;
-
-                    p.x = evRootX;
-                    p.y = evRootY;
-
-                    ScreenToClient (hWnd, & p);
-
-                    if ((p.x >= 0) && (p.y >= 0)) {
-                        enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, p.x, p.y, 0, getModifiers(), EV_NOTIME);
-                        SetWindow_mouseXY(hWnd, p.x, p.y);
-                    } else {
-                        __currentPointerView = (HANDLE) 0;
-                    }
-                }
-            }
-#endif
-
-            if (__currentCapture == curButton /* CAPTURE_IMPLICIT*/) {
-                __currentCapture = CAPTURE_NONE;
-                ReleaseCapture();
-                CPRINTF(("ReleaseCapture <BUTTONUP>\n"));
-            }
-            EVENT_PRINTF3(("WM_BUTTONUP h=%x pos=%d/%d\n",
-                           hWnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)));
-
-
-            if (GetWindow_eventMask(hWnd) & ButtonReleaseMask) {
-                if (__eatingMouseEvents) {
-                    __eatingMouseEvents = 0;
-                } else {
-                    enqEvent(ButtonReleaseMask, hWnd,
-                             message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
-                             wParam, getModifiers(), evTime);
-                }
-            }
-            *pDefault = 0;
-            break;
-
-        case WM_LBUTTONDBLCLK:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDBLCLK h=%x\n", hWnd));
-            curButton = Button1;
-            goto commonButtonDown;
-        case WM_MBUTTONDBLCLK:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDBLCLK h=%x\n", hWnd));
-            curButton = Button2;
-            goto commonButtonDown;
-        case WM_RBUTTONDBLCLK:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDBLCLK h=%x\n", hWnd));
-            curButton = Button3;
+	    if ((__currentPointerView != hWnd) && (__currentPointerView == (HANDLE)0)) {
+		__currentPointerView = hWnd;
+
+		if (GetWindow_eventMask(hWnd) & EnterWindowMask) {
+		    POINT p;
+
+		    p.x = evRootX;
+		    p.y = evRootY;
+
+		    ScreenToClient (hWnd, & p);
+
+		    if ((p.x >= 0) && (p.y >= 0)) {
+			enqEvent(EnterWindowMask, hWnd, __WM_MOUSEENTER, 0, p.x, p.y, 0, getModifiers(), EV_NOTIME);
+			SetWindow_mouseXY(hWnd, p.x, p.y);
+		    } else {
+			__currentPointerView = (HANDLE) 0;
+		    }
+		}
+	    }
+#endif
+
+	    if (__currentCapture == curButton /* CAPTURE_IMPLICIT*/) {
+		__currentCapture = CAPTURE_NONE;
+		ReleaseCapture();
+		CPRINTF(("ReleaseCapture <BUTTONUP>\n"));
+	    }
+	    EVENT_PRINTF3(("WM_BUTTONUP h=%x pos=%d/%d\n",
+			   hWnd, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)));
+
+
+	    if (GetWindow_eventMask(hWnd) & ButtonReleaseMask) {
+		if (__eatingMouseEvents) {
+		    __eatingMouseEvents = 0;
+		} else {
+		    enqEvent(ButtonReleaseMask, hWnd,
+			     message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
+			     wParam, getModifiers(), evTime);
+		}
+	    }
+	    *pDefault = 0;
+	    break;
+
+	case WM_LBUTTONDBLCLK:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDBLCLK h=%x\n", hWnd));
+	    curButton = Button1;
+	    goto commonButtonDown;
+	case WM_MBUTTONDBLCLK:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDBLCLK h=%x\n", hWnd));
+	    curButton = Button2;
+	    goto commonButtonDown;
+	case WM_RBUTTONDBLCLK:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDBLCLK h=%x\n", hWnd));
+	    curButton = Button3;
 #ifdef PRE_25_AUG_2010
-            if (isNative) {
-                 NDPRINTF(("WM_*BUTTONDBLCLK for native - default handling\n"));
-                 return 0;
-            }
-            goto commonButton;
-#else
-            goto commonButtonDown;
+	    if (isNative) {
+		 NDPRINTF(("WM_*BUTTONDBLCLK for native - default handling\n"));
+		 return 0;
+	    }
+	    goto commonButton;
+#else
+	    goto commonButtonDown;
 #endif /* PRE_25_AUG_2010 */
 
-        case WM_LBUTTONDOWN:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDOWN h=%x\n", hWnd));
-            curButton = Button1;
-            goto commonButtonDown;
-        case WM_MBUTTONDOWN:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDOWN h=%x\n", hWnd));
-            curButton = Button2;
-            goto commonButtonDown;
-        case WM_RBUTTONDOWN:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDOWN h=%x\n", hWnd));
-            curButton = Button3;
-
-        commonButtonDown:
-            if (isNative) {
-                NDPRINTF(("WM_*BUTTONDOWN for native - default handling\n"));
-                return 0;
-            }
-
-        commonButtonWithCapture:
-            if (__currentCapture == CAPTURE_NONE) {
-                __currentCapture = curButton /*CAPTURE_IMPLICIT*/;
-                //SetFocus(hWnd);
-                SetCapture(hWnd);
-                CPRINTF(("SetCapture <BUTTONDOWN>%x\n",hWnd));
-            }
-            goto commonButton;
-
-        commonButton:
-            EVENT_PRINTF3(("WM_BUTTONDOWN h=%x pos=%d/%d\n",
-                           hWnd, LOWORD(lParam), HIWORD(lParam)));
-
-            if (GetWindow_eventMask(hWnd) & ButtonPressMask) {
-                if (__eatingMouseEvents) {
-                    __eatingMouseEvents = 0;
-                } else {
-                    enqEvent(ButtonPressMask, hWnd,
-                             message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
-                             wParam, getModifiers(), evTime);
-                }
-            }
-            *pDefault = 0;
-            break;
-
-        case WM_CAPTURECHANGED:
-            DPRINTFIF(__debug_WM_FOCUS__ , ("WM_CAPTURECHANGED h=%x to %x\n", hWnd, lParam));
-#if 0
-            if ((__currentCapture != CAPTURE_NONE) && (__currentCapture != CAPTURE_EXPLICIT))
-            {
-            }
-#endif
-            break;
-
-        case WM_KILLFOCUS:
-            DPRINTFIF(__debug_WM_FOCUS__ , ("WM_KILLFOCUS h=%x\n", hWnd));
-            // enqEvent(0, hWnd, WM_KILLFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
-            if (isNative) {
-                NDPRINTF(("WM_KILLFOCUS for native - default handling\n"));
-                return 0;
-            }
-            *pDefault = 0;
-            break;
-
-        case WM_SETFOCUS:
-            DPRINTFIF(__debug_WM_FOCUS__ , ("WM_SETFOCUS h=%x\n", hWnd));
-#if 0
-            // enqEvent(0,hWnd, WM_SETFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
-            {
-                POINT p;
-                HWND hWndChild,hWndTemp;
-
-                p.x = evRootX;
-                p.y = evRootY;
-                ScreenToClient(hWnd, &p);
-                hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
-                do {
-                    hWndTemp = hWndChild;
-                    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
-                } while ((hWndChild) && (hWndChild != hWndTemp));
-
-                /*console_printf("WM_ACTIVATE active h=%x p=%d.%d in %x\n", hWnd,p.x,p.y,hWndChild);*/
-                if (hWndChild /*&& (hWndChild != hWnd)*/) {
-                    if (hWndChild != __currentPointerView) {
-                        int modifiers = getModifiers();
-
-                        if (__currentPointerView) {
-                            if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask)
-                                enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
-                                SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-
-                            __currentPointerView = 0;
-                        }
-                        if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
-                            enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
-                            SetWindow_mouseXY(hWndChild, evRootX, evRootY);
-                        }
-                        //SetFocus(hWndChild);
-                        __currentPointerView = hWndChild;
-                    }
-                }
-            }
-
-            if (isNative) {
-                NDPRINTF(("WM_SETFOCUS for native - default handling\n"));
-                return 0;
-            }
-            *pDefault = 0;
-#endif
-            break;
-
-        case WM_GETTEXT:
-            /*EVENT_PRINTF(("WM_GETTEXT %x\n", message));*/
-            break;
-
-        case WM_GETTEXTLENGTH:
-            EVENT_PRINTF(("WM_GETTEXTLENGTH %x\n", message));
-            break;
-
-        case WM_NCCREATE:
-            EVENT_PRINTF(("WM_NCCREATE %x\n", message));
-            break;
-
-        case WM_NCMOUSEMOVE:
-            if (__currentCapture == CAPTURE_NONE) {
-                if (__currentPointerView && (hWnd != __currentPointerView)) {
-                    if (inSizeMove) {
-                        if (needDelayedMouseLeaveWindow == NULL) {
-                            needDelayedMouseLeaveWindow = __currentPointerView;
-                        }
-                    } else {
-                        if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                            enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), evTime);
-                            SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-                        }
-                    }
-                    __currentPointerView = 0;
-                }
-            }
-            *pDefault = 0;
-            break;
-
-        case WM_PARENTNOTIFY:
-            EVENT_PRINTF2(("WM_PARENTNOTIFY h=%x hChild=%x %d\n",
-                                hWnd, lParam, LOWORD(wParam)));
-            break;
-
-        case WM_NCLBUTTONDOWN:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCLBUTTONDOWN\n"));
-            if (__shiftedLeftButtonIsLowerWindow) {
-                /*
-                 * with shift, this is a lower-operation
-                 */
-                if (GetKeyState(VK_SHIFT) & 0x8000) {
-                    SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
-                                 SWP_NOSENDCHANGING |
-                                 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
-                    *pDefault = 0;
-                }
-            }
-            break;
-
-        case WM_NCLBUTTONUP:
-            DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCLBUTTONUP\n"));
-            break;
-
-        case WM_NCRBUTTONDOWN:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCRBUTTONDOWN\n"));
-            if (__rightButtonIsLowerWindow) {
-                /*
-                 * this is a lower-operation
-                 */
-                SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
-                             SWP_NOSENDCHANGING |
-                             SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
-                *pDefault = 0;
-            }
-            break;
-
-        case WM_NCRBUTTONUP:
-            DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCRBUTTONUP\n"));
-            break;
-
-        case WM_NCMBUTTONDOWN:
-            DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCMBUTTONDOWN\n"));
-            break;
-
-        case WM_NCMBUTTONUP:
-            DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCMBUTTONUP\n"));
-            break;
-
-        case WM_NCLBUTTONDBLCLK:
-            EVENT_PRINTF(("WM_NCLBUTTONDBLCLK\n"));
-            break;
-
-        case WM_NCRBUTTONDBLCLK:
-            EVENT_PRINTF(("WM_NCRBUTTONDBLCLK\n"));
-            break;
-
-        case WM_NCMBUTTONDBLCLK:
-            EVENT_PRINTF(("WM_NCMBUTTONDBLCLK\n"));
-            break;
-
-        case WM_SETTEXT:
-            DPRINTFIF(__debug_WM_SETTEXT__ , ("WM_SETTEXT\n"));
-            break;
+	case WM_LBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_LBUTTONDOWN h=%x\n", hWnd));
+	    curButton = Button1;
+	    goto commonButtonDown;
+	case WM_MBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_MBUTTONDOWN h=%x\n", hWnd));
+	    curButton = Button2;
+	    goto commonButtonDown;
+	case WM_RBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_RBUTTONDOWN h=%x\n", hWnd));
+	    curButton = Button3;
+
+	commonButtonDown:
+	    if (isNative) {
+		NDPRINTF(("WM_*BUTTONDOWN for native - default handling\n"));
+		return 0;
+	    }
+
+	commonButtonWithCapture:
+	    if (__currentCapture == CAPTURE_NONE) {
+		__currentCapture = curButton /*CAPTURE_IMPLICIT*/;
+		//SetFocus(hWnd);
+		SetCapture(hWnd);
+		CPRINTF(("SetCapture <BUTTONDOWN>%x\n",hWnd));
+	    }
+	    goto commonButton;
+
+	commonButton:
+	    EVENT_PRINTF3(("WM_BUTTONDOWN h=%x pos=%d/%d\n",
+			   hWnd, LOWORD(lParam), HIWORD(lParam)));
+
+	    if (GetWindow_eventMask(hWnd) & ButtonPressMask) {
+		if (__eatingMouseEvents) {
+		    __eatingMouseEvents = 0;
+		} else {
+		    enqEvent(ButtonPressMask, hWnd,
+			     message, wParam, (UINT)(short)LOWORD(lParam), (INT)(short)HIWORD(lParam),
+			     wParam, getModifiers(), evTime);
+		}
+	    }
+	    *pDefault = 0;
+	    break;
+
+	case WM_CAPTURECHANGED:
+	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_CAPTURECHANGED h=%x to %x\n", hWnd, lParam));
+#if 0
+	    if ((__currentCapture != CAPTURE_NONE) && (__currentCapture != CAPTURE_EXPLICIT))
+	    {
+	    }
+#endif
+	    break;
+
+	case WM_KILLFOCUS:
+	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_KILLFOCUS h=%x\n", hWnd));
+	    // enqEvent(0, hWnd, WM_KILLFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    if (isNative) {
+		NDPRINTF(("WM_KILLFOCUS for native - default handling\n"));
+		return 0;
+	    }
+	    *pDefault = 0;
+	    break;
+
+	case WM_SETFOCUS:
+	    DPRINTFIF(__debug_WM_FOCUS__ , ("WM_SETFOCUS h=%x\n", hWnd));
+#if 0
+	    // enqEvent(0,hWnd, WM_SETFOCUS, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    {
+		POINT p;
+		HWND hWndChild,hWndTemp;
+
+		p.x = evRootX;
+		p.y = evRootY;
+		ScreenToClient(hWnd, &p);
+		hWndChild = hWnd; //hWndChild = ChildWindowFromPoint(hWnd,p);
+		do {
+		    hWndTemp = hWndChild;
+		    hWndChild = ChildWindowFromPointEx(hWndTemp,p,CWP_SKIPINVISIBLE|CWP_SKIPDISABLED|CWP_SKIPTRANSPARENT);
+		} while ((hWndChild) && (hWndChild != hWndTemp));
+
+		/*console_printf("WM_ACTIVATE active h=%x p=%d.%d in %x\n", hWnd,p.x,p.y,hWndChild);*/
+		if (hWndChild /*&& (hWndChild != hWnd)*/) {
+		    if (hWndChild != __currentPointerView) {
+			int modifiers = getModifiers();
+
+			if (__currentPointerView) {
+			    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask)
+				enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
+				SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+
+			    __currentPointerView = 0;
+			}
+			if (GetWindow_eventMask(hWndChild) & EnterWindowMask) {
+			    enqEvent(EnterWindowMask, hWndChild, __WM_MOUSEENTER, 0, evRootX, evRootY, 0, modifiers, EV_NOTIME);
+			    SetWindow_mouseXY(hWndChild, evRootX, evRootY);
+			}
+			//SetFocus(hWndChild);
+			__currentPointerView = hWndChild;
+		    }
+		}
+	    }
+
+	    if (isNative) {
+		NDPRINTF(("WM_SETFOCUS for native - default handling\n"));
+		return 0;
+	    }
+	    *pDefault = 0;
+#endif
+	    break;
+
+	case WM_GETTEXT:
+	    /*EVENT_PRINTF(("WM_GETTEXT %x\n", message));*/
+	    break;
+
+	case WM_GETTEXTLENGTH:
+	    EVENT_PRINTF(("WM_GETTEXTLENGTH %x\n", message));
+	    break;
+
+	case WM_NCCREATE:
+	    EVENT_PRINTF(("WM_NCCREATE %x\n", message));
+	    break;
+
+	case WM_NCMOUSEMOVE:
+	    if (__currentCapture == CAPTURE_NONE) {
+		if (__currentPointerView && (hWnd != __currentPointerView)) {
+		    if (inSizeMove) {
+			if (needDelayedMouseLeaveWindow == NULL) {
+			    needDelayedMouseLeaveWindow = __currentPointerView;
+			}
+		    } else {
+			if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+			    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), evTime);
+			    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+			}
+		    }
+		    __currentPointerView = 0;
+		}
+	    }
+	    *pDefault = 0;
+	    break;
+
+	case WM_PARENTNOTIFY:
+	    EVENT_PRINTF2(("WM_PARENTNOTIFY h=%x hChild=%x %d\n",
+				hWnd, lParam, LOWORD(wParam)));
+	    break;
+
+	case WM_NCLBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCLBUTTONDOWN\n"));
+	    if (__shiftedLeftButtonIsLowerWindow) {
+		/*
+		 * with shift, this is a lower-operation
+		 */
+		if (GetKeyState(VK_SHIFT) & 0x8000) {
+		    SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
+				 SWP_NOSENDCHANGING |
+				 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+		    *pDefault = 0;
+		}
+	    }
+	    break;
+
+	case WM_NCLBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCLBUTTONUP\n"));
+	    break;
+
+	case WM_NCRBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCRBUTTONDOWN\n"));
+	    if (__rightButtonIsLowerWindow) {
+		/*
+		 * this is a lower-operation
+		 */
+		SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0,
+			     SWP_NOSENDCHANGING |
+			     SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+		*pDefault = 0;
+	    }
+	    break;
+
+	case WM_NCRBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCRBUTTONUP\n"));
+	    break;
+
+	case WM_NCMBUTTONDOWN:
+	    DPRINTFIF(__debug_WM_BUTTONDOWN__ , ("WM_NCMBUTTONDOWN\n"));
+	    break;
+
+	case WM_NCMBUTTONUP:
+	    DPRINTFIF(__debug_WM_BUTTONUP__ , ("WM_NCMBUTTONUP\n"));
+	    break;
+
+	case WM_NCLBUTTONDBLCLK:
+	    EVENT_PRINTF(("WM_NCLBUTTONDBLCLK\n"));
+	    break;
+
+	case WM_NCRBUTTONDBLCLK:
+	    EVENT_PRINTF(("WM_NCRBUTTONDBLCLK\n"));
+	    break;
+
+	case WM_NCMBUTTONDBLCLK:
+	    EVENT_PRINTF(("WM_NCMBUTTONDBLCLK\n"));
+	    break;
+
+	case WM_SETTEXT:
+	    DPRINTFIF(__debug_WM_SETTEXT__ , ("WM_SETTEXT\n"));
+	    break;
 
 #ifdef WM_SYNCPAINT
-        case WM_SYNCPAINT:
-            EVENT_PRINTF(("WM_SYNCPAINT\n"));
-            break;
-#else
-        case 0x88:
-            EVENT_PRINTF(("0x88 (undoc)\n"));
-            break;
-#endif
-
-        case WM_NCCALCSIZE:
-            EVENT_PRINTF(("WM_NCCALCSIZE\n"));
-            break;
-
-        case WM_NCPAINT:
-            EVENT_PRINTF3(("WM_NCPAINT\n"));
+	case WM_SYNCPAINT:
+	    EVENT_PRINTF(("WM_SYNCPAINT\n"));
+	    break;
+#else
+	case 0x88:
+	    EVENT_PRINTF(("0x88 (undoc)\n"));
+	    break;
+#endif
+
+	case WM_NCCALCSIZE:
+	    EVENT_PRINTF(("WM_NCCALCSIZE\n"));
+	    break;
+
+	case WM_NCPAINT:
+	    EVENT_PRINTF3(("WM_NCPAINT\n"));
 
 #ifdef THIS_DOES_NOT_WORK
-            /* mhmh - something is drawn, but clipped wrong
-             * and with wrong colors ....
-             */
-
-            /*
-             * child windows only ...
-             */
-            if (GetParent(hWnd)) {
-                int clr;
-
-                clr = GetWindow_bdColor(hWnd);
-                if (clr != BlackPixel) {
-                    /*
-                     * draw it here
-                     */
-                    HBRUSH br;
-                    RECT rect, lineRect;
-                    HDC hDC;
-
-                    if (clr == WhitePixel) {
-                        br = __whiteBrush;
-                    } else {
-                        br = CreateSolidBrush(clr);
-                    }
-
-                    GetWindowRect(hWnd, &rect);
-                    hDC = GetWindowDC(hWnd);
-                    SelectClipRgn(hDC, NULL);
-
-                    lineRect.left = rect.left;
-                    lineRect.right = rect.right;
-                    lineRect.top = rect.top;
-                    lineRect.bottom = rect.top + 1;
-                    FillRect(hDC, &lineRect, br);
-
-                    lineRect.bottom = rect.bottom - 1;
-                    lineRect.bottom = rect.bottom;
-                    FillRect(hDC, &lineRect, br);
-
-                    lineRect.top = rect.top;
-                    lineRect.bottom = rect.bottom;
-                    lineRect.left = rect.left;
-                    lineRect.right = rect.left + 1;
-                    FillRect(hDC, &lineRect, br);
-
-                    lineRect.left = rect.right - 1;
-                    lineRect.right = rect.right;
-                    FillRect(hDC, &lineRect, br);
-
-                    _DeleteBrush(br, __LINE__);
-                    ReleaseDC(hWnd, hDC);
-                    *pDefault = 0;
-                    return 0;
-                }
-            }
+	    /* mhmh - something is drawn, but clipped wrong
+	     * and with wrong colors ....
+	     */
+
+	    /*
+	     * child windows only ...
+	     */
+	    if (GetParent(hWnd)) {
+		int clr;
+
+		clr = GetWindow_bdColor(hWnd);
+		if (clr != BlackPixel) {
+		    /*
+		     * draw it here
+		     */
+		    HBRUSH br;
+		    RECT rect, lineRect;
+		    HDC hDC;
+
+		    if (clr == WhitePixel) {
+			br = __whiteBrush;
+		    } else {
+			br = CreateSolidBrush(clr);
+		    }
+
+		    GetWindowRect(hWnd, &rect);
+		    hDC = GetWindowDC(hWnd);
+		    SelectClipRgn(hDC, NULL);
+
+		    lineRect.left = rect.left;
+		    lineRect.right = rect.right;
+		    lineRect.top = rect.top;
+		    lineRect.bottom = rect.top + 1;
+		    FillRect(hDC, &lineRect, br);
+
+		    lineRect.bottom = rect.bottom - 1;
+		    lineRect.bottom = rect.bottom;
+		    FillRect(hDC, &lineRect, br);
+
+		    lineRect.top = rect.top;
+		    lineRect.bottom = rect.bottom;
+		    lineRect.left = rect.left;
+		    lineRect.right = rect.left + 1;
+		    FillRect(hDC, &lineRect, br);
+
+		    lineRect.left = rect.right - 1;
+		    lineRect.right = rect.right;
+		    FillRect(hDC, &lineRect, br);
+
+		    _DeleteBrush(br, __LINE__);
+		    ReleaseDC(hWnd, hDC);
+		    *pDefault = 0;
+		    return 0;
+		}
+	    }
 #endif /* THIS_DOES_NOT_WORK */
-            break;
-
-        case WM_SYSCOMMAND:
-            switch (wParam & ~0x000F) {
-                case SC_CLOSE:
-                    EVENT_PRINTF2(("WM_SYSCOMMAND SC_CLOSE\n"));
-                    break;
-
-                case SC_MOVE:
-                    EVENT_PRINTF2(("WM_SYSCOMMAND SC_MOVE\n"));
-                    break;
-
-                case SC_RESTORE:
-                    EVENT_PRINTF2(("WM_SYSCOMMAND SC_RESTORE\n"));
-                    break;
-
-                case SC_SIZE:
-                    EVENT_PRINTF2(("WM_SYSCOMMAND SC_SIZE\n"));
-                    break;
-
-                default:
-                    EVENT_PRINTF2(("WM_SYSCOMMAND %x\n", wParam));
-                    break;
-            }
-            break;
-
-        case WM_INITMENU:
-            EVENT_PRINTF(("WM_INITMENU\n"));
-            break;
-
-        case WM_INITMENUPOPUP:
-            EVENT_PRINTF(("WM_INITMENUPOPUP\n"));
-            break;
-
-        case WM_ENTERIDLE:
-            EVENT_PRINTF(("WM_ENTERIDLE\n"));
-            break;
-
-        case WM_ENTERMENULOOP:
-            EVENT_PRINTF(("WM_ENTERMENULOOP\n"));
-            break;
-
-        case WM_EXITMENULOOP:
-            EVENT_PRINTF(("WM_EXITMENULOOP\n"));
-            break;
-
-        case WM_MENUSELECT:
-            EVENT_PRINTF(("WM_MENUSELECT\n"));
-            break;
-
-        case WM_QUIT:
-            DPRINTF(("quit message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
-            enqEvent(0, 0, WM_QUIT, wParam, lParam, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_NCDESTROY:
-            EVENT_PRINTF(("WM_NCDESTROY\n"));
-            break;
-
-        case WM_QUERYNEWPALETTE:
-            EVENT_PRINTF(("WM_QUERYNEWPALETTE\n"));
-            break;
-
-        case WM_PALETTECHANGED:
-            EVENT_PRINTF(("WM_PALETTECHANGED\n"));
-            break;
-
-        case WM_ACTIVATEAPP:
-            EVENT_PRINTF2(("WM_ACTIVATEAPP %s\n", wParam ? "active" : "inactive"));
-            break;
-
-        case WM_SYSDEADCHAR:
-            EVENT_PRINTF2(("WM_SYSDEADCHAR %x\n, wParam"));
-            break;
-
-        case WM_DEADCHAR:
-            EVENT_PRINTF2(("WM_DEADCHAR %x\n, wParam"));
-            break;
-
-        case WM_PAINTICON:
-            EVENT_PRINTF(("WM_PAINTICON\n"));
-            break;
-
-        case WM_ICONERASEBKGND:
-            EVENT_PRINTF(("WM_ICONERASEBKGND\n"));
-            break;
-
-        case WM_WINDOWPOSCHANGING:
-            DPRINTFIF(__debug_WM_WINDOWPOSCHANGING__ , ("WM_WINDOWPOSCHANGING\n"));
+	    break;
+
+	case WM_SYSCOMMAND:
+	    switch (wParam & ~0x000F) {
+		case SC_CLOSE:
+		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_CLOSE\n"));
+		    break;
+
+		case SC_MOVE:
+		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_MOVE\n"));
+		    break;
+
+		case SC_RESTORE:
+		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_RESTORE\n"));
+		    break;
+
+		case SC_SIZE:
+		    EVENT_PRINTF2(("WM_SYSCOMMAND SC_SIZE\n"));
+		    break;
+
+		default:
+		    EVENT_PRINTF2(("WM_SYSCOMMAND %x\n", wParam));
+		    break;
+	    }
+	    break;
+
+	case WM_INITMENU:
+	    EVENT_PRINTF(("WM_INITMENU\n"));
+	    break;
+
+	case WM_INITMENUPOPUP:
+	    EVENT_PRINTF(("WM_INITMENUPOPUP\n"));
+	    break;
+
+	case WM_ENTERIDLE:
+	    EVENT_PRINTF(("WM_ENTERIDLE\n"));
+	    break;
+
+	case WM_ENTERMENULOOP:
+	    EVENT_PRINTF(("WM_ENTERMENULOOP\n"));
+	    break;
+
+	case WM_EXITMENULOOP:
+	    EVENT_PRINTF(("WM_EXITMENULOOP\n"));
+	    break;
+
+	case WM_MENUSELECT:
+	    EVENT_PRINTF(("WM_MENUSELECT\n"));
+	    break;
+
+	case WM_QUIT:
+	    DPRINTF(("quit message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
+	    enqEvent(0, 0, WM_QUIT, wParam, lParam, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_NCDESTROY:
+	    EVENT_PRINTF(("WM_NCDESTROY\n"));
+	    break;
+
+	case WM_QUERYNEWPALETTE:
+	    EVENT_PRINTF(("WM_QUERYNEWPALETTE\n"));
+	    break;
+
+	case WM_PALETTECHANGED:
+	    EVENT_PRINTF(("WM_PALETTECHANGED\n"));
+	    break;
+
+	case WM_ACTIVATEAPP:
+	    EVENT_PRINTF2(("WM_ACTIVATEAPP %s\n", wParam ? "active" : "inactive"));
+	    break;
+
+	case WM_SYSDEADCHAR:
+	    EVENT_PRINTF2(("WM_SYSDEADCHAR %x\n, wParam"));
+	    break;
+
+	case WM_DEADCHAR:
+	    EVENT_PRINTF2(("WM_DEADCHAR %x\n, wParam"));
+	    break;
+
+	case WM_PAINTICON:
+	    EVENT_PRINTF(("WM_PAINTICON\n"));
+	    break;
+
+	case WM_ICONERASEBKGND:
+	    EVENT_PRINTF(("WM_ICONERASEBKGND\n"));
+	    break;
+
+	case WM_WINDOWPOSCHANGING:
+	    DPRINTFIF(__debug_WM_WINDOWPOSCHANGING__ , ("WM_WINDOWPOSCHANGING\n"));
 
 #ifdef HANDLE_VIEWGRAVITY
-            /*
-             * any child with a viewGravity ?
-             * (only care for topViews here;
-             *  child views do it on the smalltalk level ...)
-             */
-            if (GetParent(hWnd) == 0) {
-                if (GetParent(hWnd) == 0) {
-                    struct gravityCallBackInfo i;
-                    RECT rct, dRect;
-                    int dW, dH;
-                    WINDOWPOS *wp = (WINDOWPOS *)lParam;
-                    int winStyleBits, winExStyleBits;
-
-                    if (! (wp->flags & SWP_NOSIZE)) {
-                        dRect.left = 0;
-                        dRect.top = 0;
-                        dRect.right = 100;
-                        dRect.bottom = 100;
-                        winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
-                        winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
-                        AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
-                        dW = dRect.right - dRect.left;
-                        dH = dRect.bottom - dRect.top;
-
-                        GetClientRect(hWnd, &rct);
-
-                        i.parent = hWnd;
-
-                        i.currW = rct.right - rct.left;
-                        i.currH = rct.bottom - rct.top;
-
-                        /* wp gives us the new outer (frame) bounds */
-                        i.newW = wp->cx - (dW - 100);
-                        i.newH = wp->cy - (dH - 100);
-
-                        if ((i.currW != i.newW)
-                         || (i.currH != i.newH)) {
-                            DPRINTF((stderr, "about to sizeChange old: %d/%d new: %d/%d\n",
-                                    i.currW, i.currH, i.newW, i.newH));
-
-                            GetWindowRect(hWnd, &rct);
-                            i.parentWinX = rct.left - dRect.left;
-                            i.parentWinY = rct.top - dRect.top;
-                            EnumChildWindows(hWnd, gravityEnumeratorCallBack, (int)(&i));
-                        }
-                    }
-                }
-            }
+	    /*
+	     * any child with a viewGravity ?
+	     * (only care for topViews here;
+	     *  child views do it on the smalltalk level ...)
+	     */
+	    if (GetParent(hWnd) == 0) {
+		if (GetParent(hWnd) == 0) {
+		    struct gravityCallBackInfo i;
+		    RECT rct, dRect;
+		    int dW, dH;
+		    WINDOWPOS *wp = (WINDOWPOS *)lParam;
+		    int winStyleBits, winExStyleBits;
+
+		    if (! (wp->flags & SWP_NOSIZE)) {
+			dRect.left = 0;
+			dRect.top = 0;
+			dRect.right = 100;
+			dRect.bottom = 100;
+			winStyleBits = GetWindowLong(hWnd, GWL_STYLE);
+			winExStyleBits = GetWindowLong(hWnd, GWL_EXSTYLE);
+			AdjustWindowRectEx(&dRect, winStyleBits, 0, winExStyleBits);
+			dW = dRect.right - dRect.left;
+			dH = dRect.bottom - dRect.top;
+
+			GetClientRect(hWnd, &rct);
+
+			i.parent = hWnd;
+
+			i.currW = rct.right - rct.left;
+			i.currH = rct.bottom - rct.top;
+
+			/* wp gives us the new outer (frame) bounds */
+			i.newW = wp->cx - (dW - 100);
+			i.newH = wp->cy - (dH - 100);
+
+			if ((i.currW != i.newW)
+			 || (i.currH != i.newH)) {
+			    DPRINTF((stderr, "about to sizeChange old: %d/%d new: %d/%d\n",
+				    i.currW, i.currH, i.newW, i.newH));
+
+			    GetWindowRect(hWnd, &rct);
+			    i.parentWinX = rct.left - dRect.left;
+			    i.parentWinY = rct.top - dRect.top;
+			    EnumChildWindows(hWnd, gravityEnumeratorCallBack, (int)(&i));
+			}
+		    }
+		}
+	    }
 #endif /* HANDLE_VIEWGRAVITY */
 
-            break;
-
-        case WM_QUERYOPEN:
-            EVENT_PRINTF(("WM_QUERYOPEN\n"));
-            break;
-
-        case WM_QUERYENDSESSION:
-            EVENT_PRINTF(("WM_QUERYENDSESSION\n"));
-            *pDefault = 0;
-            if (@global(CanEndSession) == false) {
-                enqEvent(0, hWnd, WM_QUERYENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
-
-                // TODO: enter new event loop
-                // which is left when an endSessionConfirmation
-                // arrives from smalltalk
-                // (either positive or negative).
-                // for now, do not allow leaving
-                // windows as long as ST/X is open.
-
-                return(0);
-            }
-            return(TRUE);  // allow leaving windows
-            break;
-
-        case WM_ENDSESSION:
-            EVENT_PRINTF(("WM_ENDSESSION\n"));
-            enqEvent(0, hWnd, WM_ENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_DISPLAYCHANGE:
-            EVENT_PRINTF(("WM_DISPLAYCHANGE\n"));
-            enqEvent(0, hWnd, WM_DISPLAYCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_FONTCHANGE:
-            EVENT_PRINTF(("WM_FONTCHANGE\n"));
-            enqEvent(0, hWnd, WM_FONTCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_WININICHANGE:
-            EVENT_PRINTF(("WM_WININICHANGE\n"));
-            enqEvent(0, hWnd, WM_WININICHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_SYSCOLORCHANGE:
-            EVENT_PRINTF(("WM_SYSCOLORCHANGE\n"));
-            enqEvent(0, hWnd, WM_SYSCOLORCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_MOVING:
-            DPRINTFIF(__debug_WM_MOVING__ , ("WM_MOVING\n"));
+	    break;
+
+	case WM_QUERYOPEN:
+	    EVENT_PRINTF(("WM_QUERYOPEN\n"));
+	    break;
+
+	case WM_QUERYENDSESSION:
+	    EVENT_PRINTF(("WM_QUERYENDSESSION\n"));
+	    *pDefault = 0;
+	    if (@global(CanEndSession) == false) {
+		enqEvent(0, hWnd, WM_QUERYENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
+
+		// TODO: enter new event loop
+		// which is left when an endSessionConfirmation
+		// arrives from smalltalk
+		// (either positive or negative).
+		// for now, do not allow leaving
+		// windows as long as ST/X is open.
+
+		return(0);
+	    }
+	    return(TRUE);  // allow leaving windows
+	    break;
+
+	case WM_ENDSESSION:
+	    EVENT_PRINTF(("WM_ENDSESSION\n"));
+	    enqEvent(0, hWnd, WM_ENDSESSION, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_DISPLAYCHANGE:
+	    EVENT_PRINTF(("WM_DISPLAYCHANGE\n"));
+	    enqEvent(0, hWnd, WM_DISPLAYCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_FONTCHANGE:
+	    EVENT_PRINTF(("WM_FONTCHANGE\n"));
+	    enqEvent(0, hWnd, WM_FONTCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_WININICHANGE:
+	    EVENT_PRINTF(("WM_WININICHANGE\n"));
+	    enqEvent(0, hWnd, WM_WININICHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_SYSCOLORCHANGE:
+	    EVENT_PRINTF(("WM_SYSCOLORCHANGE\n"));
+	    enqEvent(0, hWnd, WM_SYSCOLORCHANGE, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_MOVING:
+	    DPRINTFIF(__debug_WM_MOVING__ , ("WM_MOVING\n"));
 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
-            inMove = 1;
-#endif
-            break;
-
-        case WM_SIZING:
-            EVENT_PRINTF(("WM_SIZING\n"));
+	    inMove = 1;
+#endif
+	    break;
+
+	case WM_SIZING:
+	    EVENT_PRINTF(("WM_SIZING\n"));
 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
-            inSize = 1;
-#endif
-            break;
-
-        case WM_ENTERSIZEMOVE:
-            EVENT_PRINTF(("WM_ENTERSIZEMOVE\n"));
+	    inSize = 1;
+#endif
+	    break;
+
+	case WM_ENTERSIZEMOVE:
+	    EVENT_PRINTF(("WM_ENTERSIZEMOVE\n"));
 #ifdef DELAY_ENTER_LEAVE_WHILE_IN_SIZE_MOVE
-            inSizeMove = 1;
-#endif
-            break;
-
-        case WM_EXITSIZEMOVE:
-            EVENT_PRINTF(("WM_EXITSIZEMOVE\n"));
+	    inSizeMove = 1;
+#endif
+	    break;
+
+	case WM_EXITSIZEMOVE:
+	    EVENT_PRINTF(("WM_EXITSIZEMOVE\n"));
 
 #ifndef PRE_13_APR_04_POSCHANGED_IN_EXITSIZEMOVE
-            if (inMove) {
-                /* generate WM_WINDOWPOSCHANGED
-                */
-                RECT rct;
-                int x, y, w, h;
-
-                GetClientRect(hWnd, &rct);
-
-                x = rct.left;
-                y = rct.top;
-                w = rct.right - rct.left;
-                h = rct.bottom - rct.top;
-
-                if ((w == 0) && (h == 0)) {
-                    if (! GetWindow_iconified(hWnd)) {
-                        SetWindow_iconified(hWnd, 1);
-                    }
-                    enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
-                } else {
-                    if (GetWindow_iconified(hWnd)) {
-                        SetWindow_iconified(hWnd, 0);
-                        enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
-                    } else {
-                        enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
-                    }
-                }
-            }
-#endif
-
-            inSizeMove = inMove = inSize = 0;
-
-            if (needDelayedMouseLeaveWindow || needDelayedMouseEnterWindow) {
-                int modifiers = getModifiers();
-
-                if (needDelayedMouseLeaveWindow) {
-                    if (GetWindow_eventMask(needDelayedMouseLeaveWindow) & LeaveWindowMask) {
-                        enqEvent(LeaveWindowMask, needDelayedMouseLeaveWindow, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
-                        SetWindow_mouseXY(needDelayedMouseLeaveWindow, -9999, -9999);
-                    }
-                    needDelayedMouseLeaveWindow = NULL;
-                }
-                if (needDelayedMouseEnterWindow) {
-                    if (GetWindow_eventMask(needDelayedMouseEnterWindow) & EnterWindowMask) {
-                        enqEvent(EnterWindowMask, needDelayedMouseEnterWindow, __WM_MOUSEENTER, 0, delayedMouseEnterX, delayedMouseEnterY, 0, modifiers, EV_NOTIME);
-                        SetWindow_mouseXY(needDelayedMouseEnterWindow, delayedMouseEnterX, delayedMouseEnterY);
-                    }
-                    needDelayedMouseEnterWindow = NULL;
-                }
-            }
-
-            break;
-
-        case WM_MOVE:
-            EVENT_PRINTF(("WM_MOVE\n"));
-            break;
-
-        case WM_POWER:
-            EVENT_PRINTF(("WM_POWER\n"));
-            enqEvent(0, hWnd, WM_POWER, wParam, 0, 0, 0, 0, EV_NOTIME);
-            break;
-
-        /* native widget actions */
-        case WM_COMMAND:
-            if (lParam) {
-                NDPRINTF(("COMMAND for widget\n"));
-                enqEvent(0, (HWND)(lParam), WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
-            } else {
-                NDPRINTF(("COMMAND for owner\n"));
-                enqEvent(0, hWnd, WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
-            }
-            break;
-
-        /* tray action */
-        case WM_TRAY_MESSAGE:
-            DPRINTF(("tray message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
-            enqEvent(0, hWnd, WM_TRAY_MESSAGE, wParam, lParam, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_COPYDATA:
-            DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA\n"));
-            {
-                PCOPYDATASTRUCT pCDs = (PCOPYDATASTRUCT) lParam;
-                int dwData = pCDs->dwData;
-                int nBytes = pCDs->cbData;
-                void *pData = pCDs->lpData;
-                void *pCopiedData;
-
-                DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA %d %lx\n", nBytes, pData));
-
-                /*
-                 * because pData is only valid here, copy it out to a malloc'd
-                 * area. This MUST be free'd by someone else !
-                 */
-                if (nBytes) {
-                    pCopiedData = malloc(nBytes);
-                    memcpy(pCopiedData, pData, nBytes);
-                } else {
-                    pCopiedData = NULL;
-                }
-                //     (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
-                enqEvent(0, hWnd, WM_COPYDATA, wParam, (INT)pCopiedData, nBytes, dwData, 0, EV_NOTIME);
-            }
-            *pDefault = 0;
-            break;
-
-        case WM_HSCROLL:
-        case WM_VSCROLL:
-            NDPRINTF(("VM_*SCROLL\n"));
-            enqEvent(0, hWnd, message, wParam, lParam, 0, 0, 0, EV_NOTIME);
-            break;
-
-        case WM_DRAWITEM:
-            EVENT_PRINTF(("WM_DRAWITEM\n"));
-#if 0
-            {
-                DRAWITEMSTRUCT *pItemStruct;
-
-                pItemStruct = (DRAWITEMSTRUCT *)lParam;
-                enqEvent(0, pItemStruct->hwndItem, WM_DRAWITEM, wParam, 0, 0, 0, 0, EV_NOTIME);
-            }
-#endif
-            break;
+	    if (inMove) {
+		/* generate WM_WINDOWPOSCHANGED
+		*/
+		RECT rct;
+		int x, y, w, h;
+
+		GetClientRect(hWnd, &rct);
+
+		x = rct.left;
+		y = rct.top;
+		w = rct.right - rct.left;
+		h = rct.bottom - rct.top;
+
+		if ((w == 0) && (h == 0)) {
+		    if (! GetWindow_iconified(hWnd)) {
+			SetWindow_iconified(hWnd, 1);
+		    }
+		    enqEvent(0, hWnd, __WM_ICONIFIED, 1, 0, 0, 0, 0, EV_NOTIME);
+		} else {
+		    if (GetWindow_iconified(hWnd)) {
+			SetWindow_iconified(hWnd, 0);
+			enqEvent(0, hWnd, __WM_ICONIFIED, 0, 0, 0, 0, 0, EV_NOTIME);
+		    } else {
+			enqEvent(0, hWnd, WM_WINDOWPOSCHANGED, 0, x, y, w, h, EV_NOTIME);
+		    }
+		}
+	    }
+#endif
+
+	    inSizeMove = inMove = inSize = 0;
+
+	    if (needDelayedMouseLeaveWindow || needDelayedMouseEnterWindow) {
+		int modifiers = getModifiers();
+
+		if (needDelayedMouseLeaveWindow) {
+		    if (GetWindow_eventMask(needDelayedMouseLeaveWindow) & LeaveWindowMask) {
+			enqEvent(LeaveWindowMask, needDelayedMouseLeaveWindow, __WM_MOUSELEAVE, 0, -1, -1, 0, modifiers, EV_NOTIME);
+			SetWindow_mouseXY(needDelayedMouseLeaveWindow, -9999, -9999);
+		    }
+		    needDelayedMouseLeaveWindow = NULL;
+		}
+		if (needDelayedMouseEnterWindow) {
+		    if (GetWindow_eventMask(needDelayedMouseEnterWindow) & EnterWindowMask) {
+			enqEvent(EnterWindowMask, needDelayedMouseEnterWindow, __WM_MOUSEENTER, 0, delayedMouseEnterX, delayedMouseEnterY, 0, modifiers, EV_NOTIME);
+			SetWindow_mouseXY(needDelayedMouseEnterWindow, delayedMouseEnterX, delayedMouseEnterY);
+		    }
+		    needDelayedMouseEnterWindow = NULL;
+		}
+	    }
+
+	    break;
+
+	case WM_MOVE:
+	    EVENT_PRINTF(("WM_MOVE\n"));
+	    break;
+
+	case WM_POWER:
+	    EVENT_PRINTF(("WM_POWER\n"));
+	    enqEvent(0, hWnd, WM_POWER, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	/* native widget actions */
+	case WM_COMMAND:
+	    if (lParam) {
+		NDPRINTF(("COMMAND for widget\n"));
+		enqEvent(0, (HWND)(lParam), WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
+	    } else {
+		NDPRINTF(("COMMAND for owner\n"));
+		enqEvent(0, hWnd, WM_COMMAND, wParam, lParam, 0, 0, 0, EV_NOTIME);
+	    }
+	    break;
+
+	/* tray action */
+	case WM_TRAY_MESSAGE:
+	    DPRINTF(("tray message hWnd=0x%x lP=0x%x wP=0x%x\n", hWnd, lParam, wParam));
+	    enqEvent(0, hWnd, WM_TRAY_MESSAGE, wParam, lParam, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_COPYDATA:
+	    DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA\n"));
+	    {
+		PCOPYDATASTRUCT pCDs = (PCOPYDATASTRUCT) lParam;
+		int dwData = pCDs->dwData;
+		int nBytes = pCDs->cbData;
+		void *pData = pCDs->lpData;
+		void *pCopiedData;
+
+		DPRINTFIF(__debug_WM_COPYDATA__ , ("WM_COPYDATA %d %lx\n", nBytes, pData));
+
+		/*
+		 * because pData is only valid here, copy it out to a malloc'd
+		 * area. This MUST be free'd by someone else !
+		 */
+		if (nBytes) {
+		    pCopiedData = malloc(nBytes);
+		    memcpy(pCopiedData, pData, nBytes);
+		} else {
+		    pCopiedData = NULL;
+		}
+		//     (flag, hWnd, message, wParam, arg1, arg2, arg3, arg4, evTime)
+		enqEvent(0, hWnd, WM_COPYDATA, wParam, (INT)pCopiedData, nBytes, dwData, 0, EV_NOTIME);
+	    }
+	    *pDefault = 0;
+	    break;
+
+	case WM_HSCROLL:
+	case WM_VSCROLL:
+	    NDPRINTF(("VM_*SCROLL\n"));
+	    enqEvent(0, hWnd, message, wParam, lParam, 0, 0, 0, EV_NOTIME);
+	    break;
+
+	case WM_DRAWITEM:
+	    EVENT_PRINTF(("WM_DRAWITEM\n"));
+#if 0
+	    {
+		DRAWITEMSTRUCT *pItemStruct;
+
+		pItemStruct = (DRAWITEMSTRUCT *)lParam;
+		enqEvent(0, pItemStruct->hwndItem, WM_DRAWITEM, wParam, 0, 0, 0, 0, EV_NOTIME);
+	    }
+#endif
+	    break;
 
 #ifdef TRACE_ALL_EVENTS
-        case WM_CTLCOLORMSGBOX:
-            UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORMSGBOX\n"));
-            break;
-        case WM_CTLCOLOREDIT:
-            UNHANDLED_EVENT_PRINTF(("WM_CTLCOLOREDIT\n"));
-            break;
-        case WM_CTLCOLORLISTBOX:
-            UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORLISTBOX\n"));
-            break;
-        case WM_CTLCOLORBTN:
-            UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORBTN\n"));
-            break;
-        case WM_CTLCOLORDLG:
-            UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORDLG\n"));
-            break;
-        case WM_CTLCOLORSTATIC:
-            UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORSTATIC\n"));
-            break;
-        case WM_CTLCOLORSCROLLBAR:
-            UNHANDLED_EVENT_PRINTFIF(__debug_WM_CTLCOLORSCROLLBAR__, ("WM_CTLCOLORSCROLLBAR\n"));
-            break;
-
-        case WM_STYLECHANGING:
-            UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGING\n"));
-            break;
-        case WM_STYLECHANGED:
-            UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGED\n"));
-            break;
-
-        case WM_GETICON:
-            UNHANDLED_EVENT_PRINTFIF(__debug_WM_GETICON__, ("WM_GETICON\n"));
-            break;
-        case WM_SETICON:
-            UNHANDLED_EVENT_PRINTF(("WM_SETICON\n"));
-            break;
-
-        case WM_PRINT:
-            UNHANDLED_EVENT_PRINTF(("WM_PRINT(lParam=%d)\n", lParam));
-            break;
-        case WM_PRINTCLIENT:
-            UNHANDLED_EVENT_PRINTF(("WM_PRINTCLIENT(lParam=%d)\n", lParam));
-            break;
-
-        case WM_NULL:
-            UNHANDLED_EVENT_PRINTF(("WM_NULL\n"));
-            break;
-
-        case WM_ENABLE:
-            UNHANDLED_EVENT_PRINTF(("WM_ENABLE\n"));
-            break;
-
-        case WM_SETREDRAW:
-            UNHANDLED_EVENT_PRINTF(("WM_SETREDRAW\n"));
-            break;
-
-        case WM_DEVMODECHANGE:
-            UNHANDLED_EVENT_PRINTF(("WM_DEVMODECHANGE\n"));
-            break;
-
-        case WM_TIMECHANGE:
-            UNHANDLED_EVENT_PRINTF(("WM_TIMECHANGE\n"));
-            break;
-
-        case WM_CANCELMODE:
-            UNHANDLED_EVENT_PRINTF(("WM_CANCELMODE\n"));
-            break;
-
-        case WM_CHILDACTIVATE:
-            UNHANDLED_EVENT_PRINTF(("WM_CHILDACTIVATE\n"));
-            break;
-
-        case WM_QUEUESYNC:
-            UNHANDLED_EVENT_PRINTF(("WM_QUEUESYNC\n"));
-            break;
-
-        case WM_NEXTDLGCTL:
-            UNHANDLED_EVENT_PRINTF(("WM_NEXTDLGCTL\n"));
-            break;
-
-        case WM_SPOOLERSTATUS:
-            UNHANDLED_EVENT_PRINTF(("WM_SPOOLERSTATUS\n"));
-            break;
-
-        case WM_MEASUREITEM:
-            UNHANDLED_EVENT_PRINTF(("WM_MEASUREITEM\n"));
-            break;
-
-        case WM_DELETEITEM:
-            UNHANDLED_EVENT_PRINTF(("WM_DELETEITEM\n"));
-            break;
-
-        case WM_VKEYTOITEM:
-            UNHANDLED_EVENT_PRINTF(("WM_VKEYTOITEM\n"));
-            break;
-
-        case WM_CHARTOITEM:
-            UNHANDLED_EVENT_PRINTF(("WM_CHARTOITEM\n"));
-            break;
-
-        case WM_SETFONT:
-            UNHANDLED_EVENT_PRINTF(("WM_SETFONT\n"));
-            break;
-
-        case WM_GETFONT:
-            UNHANDLED_EVENT_PRINTF(("WM_GETFONT\n"));
-            break;
-
-        case WM_SETHOTKEY:
-            UNHANDLED_EVENT_PRINTF(("WM_SETHOTKEY\n"));
-            break;
-
-        case WM_GETHOTKEY:
-            UNHANDLED_EVENT_PRINTF(("WM_GETHOTKEY\n"));
-            break;
-
-        case WM_QUERYDRAGICON:
-            UNHANDLED_EVENT_PRINTF(("WM_QUERYDRAGICON\n"));
-            break;
-
-        case WM_COMPAREITEM:
-            UNHANDLED_EVENT_PRINTF(("WM_COMPAREITEM\n"));
-            break;
-
-        case WM_GETOBJECT:
-            UNHANDLED_EVENT_PRINTF(("WM_GETOBJECT\n"));
-            break;
-
-        case WM_COMPACTING:
-            UNHANDLED_EVENT_PRINTF(("WM_COMPACTING\n"));
-            break;
-
-        case WM_COMMNOTIFY:
-            UNHANDLED_EVENT_PRINTF(("WM_COMMNOTIFY\n"));
-            break;
-
-        case WM_CANCELJOURNAL:
-            UNHANDLED_EVENT_PRINTF(("WM_CANCELJOURNAL\n"));
-            break;
-
-        case WM_INPUTLANGCHANGEREQUEST:
-            UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGEREQUEST\n"));
-            break;
-
-        case WM_INPUTLANGCHANGE:
-            UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGE\n"));
-            break;
-
-        case WM_TCARD:
-            UNHANDLED_EVENT_PRINTF(("WM_TCARD\n"));
-            break;
-
-        case WM_HELP:
-            UNHANDLED_EVENT_PRINTF(("WM_HELP\n"));
-            break;
-
-        case WM_USERCHANGED:
-            UNHANDLED_EVENT_PRINTF(("WM_USERCHANGED\n"));
-            break;
-
-        case WM_NOTIFY:
-            UNHANDLED_EVENT_PRINTF(("WM_NOTIFY\n"));
-            break;
-
-        case WM_NOTIFYFORMAT:
-            UNHANDLED_EVENT_PRINTF(("WM_NOTIFYFORMAT\n"));
-            break;
-
-        case WM_CONTEXTMENU:
-            UNHANDLED_EVENT_PRINTF(("WM_CONTEXTMENU\n"));
-            break;
-
-        case WM_NCXBUTTONDOWN:
-            UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDOWN\n"));
-            break;
-
-        case WM_NCXBUTTONUP:
-            UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONUP\n"));
-            break;
-
-        case WM_NCXBUTTONDBLCLK:
-            UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDBLCLK\n"));
-            break;
-
-        case WM_DEVICECHANGE:
-            UNHANDLED_EVENT_PRINTF(("WM_DEVICECHANGE\n"));
-            break;
-
-        case DBT_DEVICEARRIVAL:
-            UNHANDLED_EVENT_PRINTF(("DBT_DEVICEARRIVAL\n"));
-            break;
-
-        case DBT_DEVICEREMOVECOMPLETE:
-            UNHANDLED_EVENT_PRINTF(("DBT_DEVICEREMOVECOMPLETE\n"));
-            break;
-#endif
-
-        default:
-            EVENT_PRINTF(( "WinWorkstat [info] unhandled msg = %d 0x%x [%d]\n", message, message, __LINE__));
-            break;
+	case WM_CTLCOLORMSGBOX:
+	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORMSGBOX\n"));
+	    break;
+	case WM_CTLCOLOREDIT:
+	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLOREDIT\n"));
+	    break;
+	case WM_CTLCOLORLISTBOX:
+	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORLISTBOX\n"));
+	    break;
+	case WM_CTLCOLORBTN:
+	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORBTN\n"));
+	    break;
+	case WM_CTLCOLORDLG:
+	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORDLG\n"));
+	    break;
+	case WM_CTLCOLORSTATIC:
+	    UNHANDLED_EVENT_PRINTF(("WM_CTLCOLORSTATIC\n"));
+	    break;
+	case WM_CTLCOLORSCROLLBAR:
+	    UNHANDLED_EVENT_PRINTFIF(__debug_WM_CTLCOLORSCROLLBAR__, ("WM_CTLCOLORSCROLLBAR\n"));
+	    break;
+
+	case WM_STYLECHANGING:
+	    UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGING\n"));
+	    break;
+	case WM_STYLECHANGED:
+	    UNHANDLED_EVENT_PRINTF(("WM_STYLECHANGED\n"));
+	    break;
+
+	case WM_GETICON:
+	    UNHANDLED_EVENT_PRINTFIF(__debug_WM_GETICON__, ("WM_GETICON\n"));
+	    break;
+	case WM_SETICON:
+	    UNHANDLED_EVENT_PRINTF(("WM_SETICON\n"));
+	    break;
+
+	case WM_PRINT:
+	    UNHANDLED_EVENT_PRINTF(("WM_PRINT(lParam=%d)\n", lParam));
+	    break;
+	case WM_PRINTCLIENT:
+	    UNHANDLED_EVENT_PRINTF(("WM_PRINTCLIENT(lParam=%d)\n", lParam));
+	    break;
+
+	case WM_NULL:
+	    UNHANDLED_EVENT_PRINTF(("WM_NULL\n"));
+	    break;
+
+	case WM_ENABLE:
+	    UNHANDLED_EVENT_PRINTF(("WM_ENABLE\n"));
+	    break;
+
+	case WM_SETREDRAW:
+	    UNHANDLED_EVENT_PRINTF(("WM_SETREDRAW\n"));
+	    break;
+
+	case WM_DEVMODECHANGE:
+	    UNHANDLED_EVENT_PRINTF(("WM_DEVMODECHANGE\n"));
+	    break;
+
+	case WM_TIMECHANGE:
+	    UNHANDLED_EVENT_PRINTF(("WM_TIMECHANGE\n"));
+	    break;
+
+	case WM_CANCELMODE:
+	    UNHANDLED_EVENT_PRINTF(("WM_CANCELMODE\n"));
+	    break;
+
+	case WM_CHILDACTIVATE:
+	    UNHANDLED_EVENT_PRINTF(("WM_CHILDACTIVATE\n"));
+	    break;
+
+	case WM_QUEUESYNC:
+	    UNHANDLED_EVENT_PRINTF(("WM_QUEUESYNC\n"));
+	    break;
+
+	case WM_NEXTDLGCTL:
+	    UNHANDLED_EVENT_PRINTF(("WM_NEXTDLGCTL\n"));
+	    break;
+
+	case WM_SPOOLERSTATUS:
+	    UNHANDLED_EVENT_PRINTF(("WM_SPOOLERSTATUS\n"));
+	    break;
+
+	case WM_MEASUREITEM:
+	    UNHANDLED_EVENT_PRINTF(("WM_MEASUREITEM\n"));
+	    break;
+
+	case WM_DELETEITEM:
+	    UNHANDLED_EVENT_PRINTF(("WM_DELETEITEM\n"));
+	    break;
+
+	case WM_VKEYTOITEM:
+	    UNHANDLED_EVENT_PRINTF(("WM_VKEYTOITEM\n"));
+	    break;
+
+	case WM_CHARTOITEM:
+	    UNHANDLED_EVENT_PRINTF(("WM_CHARTOITEM\n"));
+	    break;
+
+	case WM_SETFONT:
+	    UNHANDLED_EVENT_PRINTF(("WM_SETFONT\n"));
+	    break;
+
+	case WM_GETFONT:
+	    UNHANDLED_EVENT_PRINTF(("WM_GETFONT\n"));
+	    break;
+
+	case WM_SETHOTKEY:
+	    UNHANDLED_EVENT_PRINTF(("WM_SETHOTKEY\n"));
+	    break;
+
+	case WM_GETHOTKEY:
+	    UNHANDLED_EVENT_PRINTF(("WM_GETHOTKEY\n"));
+	    break;
+
+	case WM_QUERYDRAGICON:
+	    UNHANDLED_EVENT_PRINTF(("WM_QUERYDRAGICON\n"));
+	    break;
+
+	case WM_COMPAREITEM:
+	    UNHANDLED_EVENT_PRINTF(("WM_COMPAREITEM\n"));
+	    break;
+
+	case WM_GETOBJECT:
+	    UNHANDLED_EVENT_PRINTF(("WM_GETOBJECT\n"));
+	    break;
+
+	case WM_COMPACTING:
+	    UNHANDLED_EVENT_PRINTF(("WM_COMPACTING\n"));
+	    break;
+
+	case WM_COMMNOTIFY:
+	    UNHANDLED_EVENT_PRINTF(("WM_COMMNOTIFY\n"));
+	    break;
+
+	case WM_CANCELJOURNAL:
+	    UNHANDLED_EVENT_PRINTF(("WM_CANCELJOURNAL\n"));
+	    break;
+
+	case WM_INPUTLANGCHANGEREQUEST:
+	    UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGEREQUEST\n"));
+	    break;
+
+	case WM_INPUTLANGCHANGE:
+	    UNHANDLED_EVENT_PRINTF(("WM_INPUTLANGCHANGE\n"));
+	    break;
+
+	case WM_TCARD:
+	    UNHANDLED_EVENT_PRINTF(("WM_TCARD\n"));
+	    break;
+
+	case WM_HELP:
+	    UNHANDLED_EVENT_PRINTF(("WM_HELP\n"));
+	    break;
+
+	case WM_USERCHANGED:
+	    UNHANDLED_EVENT_PRINTF(("WM_USERCHANGED\n"));
+	    break;
+
+	case WM_NOTIFY:
+	    UNHANDLED_EVENT_PRINTF(("WM_NOTIFY\n"));
+	    break;
+
+	case WM_NOTIFYFORMAT:
+	    UNHANDLED_EVENT_PRINTF(("WM_NOTIFYFORMAT\n"));
+	    break;
+
+	case WM_CONTEXTMENU:
+	    UNHANDLED_EVENT_PRINTF(("WM_CONTEXTMENU\n"));
+	    break;
+
+	case WM_NCXBUTTONDOWN:
+	    UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDOWN\n"));
+	    break;
+
+	case WM_NCXBUTTONUP:
+	    UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONUP\n"));
+	    break;
+
+	case WM_NCXBUTTONDBLCLK:
+	    UNHANDLED_EVENT_PRINTF(("WM_NCXBUTTONDBLCLK\n"));
+	    break;
+
+	case WM_DEVICECHANGE:
+	    UNHANDLED_EVENT_PRINTF(("WM_DEVICECHANGE\n"));
+	    break;
+
+	case DBT_DEVICEARRIVAL:
+	    UNHANDLED_EVENT_PRINTF(("DBT_DEVICEARRIVAL\n"));
+	    break;
+
+	case DBT_DEVICEREMOVECOMPLETE:
+	    UNHANDLED_EVENT_PRINTF(("DBT_DEVICEREMOVECOMPLETE\n"));
+	    break;
+#endif
+
+	default:
+	    EVENT_PRINTF(( "WinWorkstat [info] unhandled msg = %d 0x%x [%d]\n", message, message, __LINE__));
+	    break;
     }
     return 0;
 }
@@ -4548,7 +4601,7 @@
 
 #if 0
     if (AttachThreadInput(_masterThreadId, _dispatchThreadId2, TRUE) != TRUE) {
-        console_fprintf(stderr, "WinWorkstation [warning]: AttachThreadInput failed\n");
+	console_fprintf(stderr, "WinWorkstation [warning]: AttachThreadInput failed\n");
     };
 #endif
 #ifndef WIN32THREADS
@@ -4562,20 +4615,20 @@
     /* allocate localMemory for Window */
     lI = (localWindowInfo *)malloc(sizeof(localWindowInfo));
     if (lI) {
-        memset(lI, 0, sizeof(*lI));
+	memset(lI, 0, sizeof(*lI));
     }
 
     __rootWinSpezial = CreateWindowExW(WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT,
-                                      wapp_nameRoot, wapp_nameRoot,
-                                      WS_POPUP | WS_DISABLED,
-                                      0, 0,
-                                      rect.right - rect.left, rect.bottom - rect.top,
-                                      0, 0, (HANDLE) __getHInstance(), lI);
+				      wapp_nameRoot, wapp_nameRoot,
+				      WS_POPUP | WS_DISABLED,
+				      0, 0,
+				      rect.right - rect.left, rect.bottom - rect.top,
+				      0, 0, (HANDLE) __getHInstance(), lI);
 
     //ShowWindow(__rootWinSpezial,SW_SHOWNOACTIVATE);
     SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
-                 SWP_NOSENDCHANGING |
-                 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+		 SWP_NOSENDCHANGING |
+		 SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 
 #ifdef STARTUP_DISPATCHTHREAD_DEBUG
     console_fprintf(stderr, "WinWorkstation [info]: setting ThreadRunningEvent\n");
@@ -4583,305 +4636,305 @@
     SetEvent(hDispatchThreadRunningEvent);
 
     for (;;) {
-        HANDLE dummy;
-
-        TH_DPRINTF(("TG %d\n", th_calls++));
-
-        /*
-         * if there is no current capture (pointer-grab),
-         * make certain that we do not get stuck in the GetMessage
-         * but instead poll the mouse in 200ms intervals.
-         * This is required to synthesize the MOUSELEAVE message,
-         */
+	HANDLE dummy;
+
+	TH_DPRINTF(("TG %d\n", th_calls++));
+
+	/*
+	 * if there is no current capture (pointer-grab),
+	 * make certain that we do not get stuck in the GetMessage
+	 * but instead poll the mouse in 200ms intervals.
+	 * This is required to synthesize the MOUSELEAVE message,
+	 */
 // DPRINTF(("X1\n"));
-        if (__currentPointerView && (__currentCapture == CAPTURE_NONE)) {
+	if (__currentPointerView && (__currentCapture == CAPTURE_NONE)) {
 // DPRINTF(("X2\n"));
-            while (PeekMessageW(&msg, 0, 0, 0, PM_NOREMOVE) == 0) {
+	    while (PeekMessageW(&msg, 0, 0, 0, PM_NOREMOVE) == 0) {
 // DPRINTF(("PeekMessage -> 0\n"));
-                /*
-                 * wait for an event; timeout after 200 millis
-                 */
-                if (MsgWaitForMultipleObjects(0,&dummy,FALSE,200,QS_ALLINPUT) == WAIT_TIMEOUT) {
-                    if (! inSizeMove) {
-                        /*
-                         * timeout - see where mouse pointer is
-                         * for synthetic leave events.
-                         */
-                        POINT point;
-
-                        if (GetCursorPos(&point)) {
-                            HWND hWnd = WindowFromPoint(point);
-
-                            if (hWnd) {
-                                if (GetWindowThreadProcessId(hWnd,0) != GetCurrentThreadId()) {
-                                    if (inSizeMove) {
-                                        if (needDelayedMouseLeaveWindow == NULL) {
-                                            needDelayedMouseLeaveWindow = __currentPointerView;
-                                        }
-                                    } else {
-                                        if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                                            enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
-                                            SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-                                        }
-                                    }
-                                    __currentPointerView = 0;
-                                    break;
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-        }
-
-        GetMessageW(&msg, NULL, 0, 0);
+		/*
+		 * wait for an event; timeout after 200 millis
+		 */
+		if (MsgWaitForMultipleObjects(0,&dummy,FALSE,200,QS_ALLINPUT) == WAIT_TIMEOUT) {
+		    if (! inSizeMove) {
+			/*
+			 * timeout - see where mouse pointer is
+			 * for synthetic leave events.
+			 */
+			POINT point;
+
+			if (GetCursorPos(&point)) {
+			    HWND hWnd = WindowFromPoint(point);
+
+			    if (hWnd) {
+				if (GetWindowThreadProcessId(hWnd,0) != GetCurrentThreadId()) {
+				    if (inSizeMove) {
+					if (needDelayedMouseLeaveWindow == NULL) {
+					    needDelayedMouseLeaveWindow = __currentPointerView;
+					}
+				    } else {
+					if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+					    enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
+					    SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+					}
+				    }
+				    __currentPointerView = 0;
+				    break;
+				}
+			    }
+			}
+		    }
+		}
+	    }
+	}
+
+	GetMessageW(&msg, NULL, 0, 0);
 // DPRINTF(("GetMessage -> %d\n", msg.message));
-        TH_DPRINTF(("TD %d\n", th_calls++));
-        destroyWin = 0;
-
-        switch (msg.message) {
-#if 0
-            case WM_THREAD_DESTROYWINDOW:
-                destroyWin = TRUE;
-                msg.message = WM_CLOSE;
-                EVENT_PRINTF(("thread WM_THREAD_DESTROYWINDOW %x\n",msg.hwnd));
-                break;
+	TH_DPRINTF(("TD %d\n", th_calls++));
+	destroyWin = 0;
+
+	switch (msg.message) {
+#if 0
+	    case WM_THREAD_DESTROYWINDOW:
+		destroyWin = TRUE;
+		msg.message = WM_CLOSE;
+		EVENT_PRINTF(("thread WM_THREAD_DESTROYWINDOW %x\n",msg.hwnd));
+		break;
 #endif
 
 #ifdef SET_FOCUS_IN_WINTHREAD
-            case WM_THREAD_SETFOCUS:
-                DPRINTFIF(__debug_WM_FOCUS__ , ("WM_THREAD_SETFOCUS h=%x\n", msg.wParam));
+	    case WM_THREAD_SETFOCUS:
+		DPRINTFIF(__debug_WM_FOCUS__ , ("WM_THREAD_SETFOCUS h=%x\n", msg.wParam));
 # ifdef xxWIN32THREADS
-                if (msg.lParam) {
-                    if (AttachThreadInput(_dispatchThreadId2,msg.lParam,TRUE) == FALSE)
-                        PRINTF(("SetFocus AttachThreadInput error %d\n", GetLastError()));
-                }
-# endif
-                EVENT_PRINTF(("threadSetfocus %x\n",msg.wParam));
-                if (SetFocus((HWND)msg.wParam) == 0) {
-                    DDPRINTF(("SetFocus to %x failed.\n",msg.wParam));
-                }
-                continue;
+		if (msg.lParam) {
+		    if (AttachThreadInput(_dispatchThreadId2,msg.lParam,TRUE) == FALSE)
+			PRINTF(("SetFocus AttachThreadInput error %d\n", GetLastError()));
+		}
+# endif
+		EVENT_PRINTF(("threadSetfocus %x\n",msg.wParam));
+		if (SetFocus((HWND)msg.wParam) == 0) {
+		    DDPRINTF(("SetFocus to %x failed.\n",msg.wParam));
+		}
+		continue;
 #endif
 
 #ifdef SET_CURSOR_IN_WINTHREAD
-            case WM_THREAD_SETCURSOR:
-                if (msg.lParam) {
+	    case WM_THREAD_SETCURSOR:
+		if (msg.lParam) {
 #if 1
-                    SetCursor((HCURSOR)msg.lParam);
-#else
-                    /* this check is done by our sender */
-                    {
-                        POINT p;
-                        GetCursorPos(&p);
-                        if (WindowFromPoint(p) == msg.hwnd) {
-                            EVENT_PRINTF(("threadSetCursor %x\n",msg.lParam));
-                            SetCursor((HCURSOR)msg.lParam);
-                        }
-                    }
-#endif
-                }
-                continue;
+		    SetCursor((HCURSOR)msg.lParam);
+#else
+		    /* this check is done by our sender */
+		    {
+			POINT p;
+			GetCursorPos(&p);
+			if (WindowFromPoint(p) == msg.hwnd) {
+			    EVENT_PRINTF(("threadSetCursor %x\n",msg.lParam));
+			    SetCursor((HCURSOR)msg.lParam);
+			}
+		    }
+#endif
+		}
+		continue;
 #endif
 
 #ifdef BEEP_IN_WINTHREAD
-            case WM_THREAD_BEEP:
-                MessageBeep( MB_ICONEXCLAMATION);
-                continue;
-#endif
-
-            case WM_THREAD_SETCAPTURE:
-                if (msg.wParam) {
-                    if (__currentPointerView) {
-                        if (inSizeMove) {
-                            if (needDelayedMouseLeaveWindow == NULL) {
-                                needDelayedMouseLeaveWindow = __currentPointerView;
-                            }
-                        } else {
-                            if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
-                                enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
-                                SetWindow_mouseXY(__currentPointerView, -9999, -9999);
-                            }
-                        }
-                    }
-
-                    __currentPointerView = (HWND)msg.wParam;
-                    __currentCapture = CAPTURE_EXPLICIT;
-                    EVENT_PRINTF(("threadSetCapture %x\n",msg.wParam));
-                    SetCapture(__currentPointerView);
-                } else {
-                    if (__currentPointerView  == __rootWinSpezial) {
-                        //ShowWindow(__rootWinSpezial, SW_HIDE);
-                        SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
-                                     SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS
-                                     | SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
-                                   /*| SWP_NOZORDER | SWP_NOOWNERZORDER */);
-                    }
-                    __currentPointerView = 0;
-                    __currentCapture = CAPTURE_NONE;
-                    EVENT_PRINTF(("threadReleaseCapture\n"));
-                    ReleaseCapture();
-                }
-                if (msg.lParam) {
-                    DDDDPRINTF(("threadSetCursor %x\n",msg.lParam));
-                    SetCursor((HCURSOR)msg.lParam);
-                }
-                continue;
-
-            case WM_THREAD_CREATEWINDOW:
-                EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW %d\n", th_calls));
-
-                {
-                    createWindowInfo *cwi = (createWindowInfo *)(msg.lParam);
-
-                    if ((cwi->sequenceNr == msg.wParam)
-                     && (cwi->sequenceNr != INVALIDATED_CWI)) {
-                        cwi->sequenceNr = INVALIDATED_CWI;
-                        cwi->infoWasRead = 1;
-                        if (cwi->newWinHandle == NULL) {
-                            HANDLE ev;
-
-                            cwi->newWinHandle = CreateWindowExW(
-                                                cwi->winStyleBitsEx,
-                                                cwi->className,
-                                                cwi->windowName,
-                                                cwi->winStyleBits,
-                                                cwi->x, cwi->y,
-                                                cwi->dx, cwi->dy,
-                                                cwi->parentHandle,
-                                                NULL,           /* menu */
-                                                (HANDLE) __getHInstance(),
-                                                cwi->localWindowInfo
-                                               );
-
-                            if (cwi->newWinHandle == NULL) {
-                                cwi->errCode = GetLastError();
-                                console_fprintf(stderr, "WinWorkstation [info]: CreateWindow %s failed: %d (0x%x) [%d]\n",
-                                                cwi->className, cwi->errCode, cwi->errCode, __LINE__);
-                            } else {
-                                SETLOCALWINDOWINFOPTR(cwi->newWinHandle, cwi->localWindowInfo);
+	    case WM_THREAD_BEEP:
+		MessageBeep( MB_ICONEXCLAMATION);
+		continue;
+#endif
+
+	    case WM_THREAD_SETCAPTURE:
+		if (msg.wParam) {
+		    if (__currentPointerView) {
+			if (inSizeMove) {
+			    if (needDelayedMouseLeaveWindow == NULL) {
+				needDelayedMouseLeaveWindow = __currentPointerView;
+			    }
+			} else {
+			    if (GetWindow_eventMask(__currentPointerView) & LeaveWindowMask) {
+				enqEvent(LeaveWindowMask, __currentPointerView, __WM_MOUSELEAVE, 0, -1, -1, 0, getModifiers(), EV_NOTIME);
+				SetWindow_mouseXY(__currentPointerView, -9999, -9999);
+			    }
+			}
+		    }
+
+		    __currentPointerView = (HWND)msg.wParam;
+		    __currentCapture = CAPTURE_EXPLICIT;
+		    EVENT_PRINTF(("threadSetCapture %x\n",msg.wParam));
+		    SetCapture(__currentPointerView);
+		} else {
+		    if (__currentPointerView  == __rootWinSpezial) {
+			//ShowWindow(__rootWinSpezial, SW_HIDE);
+			SetWindowPos(__rootWinSpezial, HWND_BOTTOM, 0, 0, 0, 0,
+				     SWP_NOREDRAW | SWP_NOSENDCHANGING | SWP_NOCOPYBITS
+				     | SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE
+				   /*| SWP_NOZORDER | SWP_NOOWNERZORDER */);
+		    }
+		    __currentPointerView = 0;
+		    __currentCapture = CAPTURE_NONE;
+		    EVENT_PRINTF(("threadReleaseCapture\n"));
+		    ReleaseCapture();
+		}
+		if (msg.lParam) {
+		    DDDDPRINTF(("threadSetCursor %x\n",msg.lParam));
+		    SetCursor((HCURSOR)msg.lParam);
+		}
+		continue;
+
+	    case WM_THREAD_CREATEWINDOW:
+		EVENT_PRINTF(("*WM_THREAD_CREATEWINDOW %d\n", th_calls));
+
+		{
+		    createWindowInfo *cwi = (createWindowInfo *)(msg.lParam);
+
+		    if ((cwi->sequenceNr == msg.wParam)
+		     && (cwi->sequenceNr != INVALIDATED_CWI)) {
+			cwi->sequenceNr = INVALIDATED_CWI;
+			cwi->infoWasRead = 1;
+			if (cwi->newWinHandle == NULL) {
+			    HANDLE ev;
+
+			    cwi->newWinHandle = CreateWindowExW(
+						cwi->winStyleBitsEx,
+						cwi->className,
+						cwi->windowName,
+						cwi->winStyleBits,
+						cwi->x, cwi->y,
+						cwi->dx, cwi->dy,
+						cwi->parentHandle,
+						NULL,           /* menu */
+						(HANDLE) __getHInstance(),
+						cwi->localWindowInfo
+					       );
+
+			    if (cwi->newWinHandle == NULL) {
+				cwi->errCode = GetLastError();
+				console_fprintf(stderr, "WinWorkstation [info]: CreateWindow %s failed: %d (0x%x) [%d]\n",
+						cwi->className, cwi->errCode, cwi->errCode, __LINE__);
+			    } else {
+				SETLOCALWINDOWINFOPTR(cwi->newWinHandle, cwi->localWindowInfo);
 #ifdef DEBUG /* PARANOIA */
-                                if (GETLOCALWINDOWINFOPTR(cwi->newWinHandle) != cwi->localWindowInfo) {
-                                   console_fprintf(stderr, "lI-Error\n");
-                                }
-#endif
-                            }
-
-                            ev = cwi->hCreateEvent;
-                            if (ev) {
-                                SetEvent(ev);
-                            }
-                        }
-                    } else {
-                        DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
-                    }
-                }
-                continue;
-
-            case WM_THREAD_REGISTERHOTKEY:
-                EVENT_PRINTF(("*WM_THREAD_REGISTERHOTKEY\n"));
-                {
-                    registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
-                    rhki->errorCode = 0;
-                    if (!RegisterHotKey(rhki->hwnd,rhki->hotKeyId,rhki->modifier,rhki->virtualKey)){
-                        rhki->errorCode = GetLastError();
-                        console_fprintf(stderr, "WinWorkstation [error]: RegisterHotKey failed: err=%d\n", rhki->errorCode);
-                    }
-                    rhki->finished = 1;
-                }
-                continue;
-
-            case WM_THREAD_UNREGISTERHOTKEY:
-                EVENT_PRINTF(("*WM_THREAD_UNREGISTERHOTKEY\n"));
-                {
-                    registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
-                    rhki->errorCode = 0;
-                    if (!UnregisterHotKey(rhki->hwnd,rhki->hotKeyId)){
-                        rhki->errorCode = GetLastError();
-                        console_fprintf(stderr, "WinWorkstation [error]: UnegisterHotKey failed: err=%d\n", rhki->errorCode);
-                    }
-                    rhki->finished = 1;
-                }
-                continue;
-
-            case WM_KEYDOWN:
-                DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN %x\n", msg.wParam));
-                goto commonKey;
-
-            case WM_KEYUP:
-                DPRINTFIF(__debug_WM_KEYUP__  , ("WM_KEYUP %x\n", msg.wParam));
-                goto commonKey;
-
-            case WM_SYSKEYDOWN:
-                DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n", msg.wParam));
-                goto commonKey;
-
-            case WM_SYSKEYUP:
-                DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n", msg.wParam));
-                goto commonKey;
-
-            case WM_HOTKEY:
-                // console_fprintf(stderr, "dispatchThread [info]: receive hotkey %x %x\n", msg.hwnd, msg.wParam);
-                DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", msg.wParam));
-                break;
-
-            commonKey:
+				if (GETLOCALWINDOWINFOPTR(cwi->newWinHandle) != cwi->localWindowInfo) {
+				   console_fprintf(stderr, "lI-Error\n");
+				}
+#endif
+			    }
+
+			    ev = cwi->hCreateEvent;
+			    if (ev) {
+				SetEvent(ev);
+			    }
+			}
+		    } else {
+			DPRINTF(("obsolete createWindow message %x ignored\n", cwi->sequenceNr));
+		    }
+		}
+		continue;
+
+	    case WM_THREAD_REGISTERHOTKEY:
+		EVENT_PRINTF(("*WM_THREAD_REGISTERHOTKEY\n"));
+		{
+		    registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
+		    rhki->errorCode = 0;
+		    if (!RegisterHotKey(rhki->hwnd,rhki->hotKeyId,rhki->modifier,rhki->virtualKey)){
+			rhki->errorCode = GetLastError();
+			console_fprintf(stderr, "WinWorkstation [error]: RegisterHotKey failed: err=%d\n", rhki->errorCode);
+		    }
+		    rhki->finished = 1;
+		}
+		continue;
+
+	    case WM_THREAD_UNREGISTERHOTKEY:
+		EVENT_PRINTF(("*WM_THREAD_UNREGISTERHOTKEY\n"));
+		{
+		    registerHotKeyInfo *rhki = (registerHotKeyInfo *)(msg.lParam);
+		    rhki->errorCode = 0;
+		    if (!UnregisterHotKey(rhki->hwnd,rhki->hotKeyId)){
+			rhki->errorCode = GetLastError();
+			console_fprintf(stderr, "WinWorkstation [error]: UnegisterHotKey failed: err=%d\n", rhki->errorCode);
+		    }
+		    rhki->finished = 1;
+		}
+		continue;
+
+	    case WM_KEYDOWN:
+		DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_KEYDOWN %x\n", msg.wParam));
+		goto commonKey;
+
+	    case WM_KEYUP:
+		DPRINTFIF(__debug_WM_KEYUP__  , ("WM_KEYUP %x\n", msg.wParam));
+		goto commonKey;
+
+	    case WM_SYSKEYDOWN:
+		DPRINTFIF(__debug_WM_KEYDOWN__ , ("WM_SYSKEYDOWN %x\n", msg.wParam));
+		goto commonKey;
+
+	    case WM_SYSKEYUP:
+		DPRINTFIF(__debug_WM_KEYUP__ , ("WM_SYSKEYUP %x\n", msg.wParam));
+		goto commonKey;
+
+	    case WM_HOTKEY:
+		// console_fprintf(stderr, "dispatchThread [info]: receive hotkey %x %x\n", msg.hwnd, msg.wParam);
+		DPRINTFIF(__debug_WM_KEYUP__ , ("WM_HOTKEY %x\n", msg.wParam));
+		break;
+
+	    commonKey:
 #if 1
-                if (((msg.wParam >= '0') && (msg.wParam <= 'Z'))
-                 || ((msg.wParam >= VK_MULTIPLY) && (msg.wParam <= VK_DIVIDE))
-                 || (msg.wParam == VK_SPACE)
-                 || (msg.wParam == VK_CAPITAL)
-                 /* || (msg.wParam == VK_SHIFT) */
-                 || (msg.wParam >= 0xB0))
-#endif
-                {
-                    /*
-                     * translate to a WM_CHAR message
-                     */
-                    if (TranslateMessage(&msg))
-                        continue;
-                }
-                break;
-
-            /* short cirquit some messages */
+		if (((msg.wParam >= '0') && (msg.wParam <= 'Z'))
+		 || ((msg.wParam >= VK_MULTIPLY) && (msg.wParam <= VK_DIVIDE))
+		 || (msg.wParam == VK_SPACE)
+		 || (msg.wParam == VK_CAPITAL)
+		 /* || (msg.wParam == VK_SHIFT) */
+		 || (msg.wParam >= 0xB0))
+#endif
+		{
+		    /*
+		     * translate to a WM_CHAR message
+		     */
+		    if (TranslateMessage(&msg))
+			continue;
+		}
+		break;
+
+	    /* short cirquit some messages */
 #if 0
 # ifndef SUPPORT_NATIVE_WINDOWS
-            /*
-             * some can simply be ignored ...
-             */
-            case WM_ERASEBKGND:
-                EVENT_PRINTF(("*WM_ERASEBKGND\n"));
-                continue;
-            case WM_KILLFOCUS:
-                EVENT_PRINTF(("*WM_KILLFOCUS\n"));
-                continue;
-# endif
-#endif
-
-#if 0
-            case WM_SIZE:
-                EVENT_PRINTF(("*WM_SIZE\n"));
-                continue;
-#endif
-        }
-
-        /*
-         * common ...
-         */
-        evRootX = msg.pt.x;
-        evRootY = msg.pt.y;
+	    /*
+	     * some can simply be ignored ...
+	     */
+	    case WM_ERASEBKGND:
+		EVENT_PRINTF(("*WM_ERASEBKGND\n"));
+		continue;
+	    case WM_KILLFOCUS:
+		EVENT_PRINTF(("*WM_KILLFOCUS\n"));
+		continue;
+# endif
+#endif
+
+#if 0
+	    case WM_SIZE:
+		EVENT_PRINTF(("*WM_SIZE\n"));
+		continue;
+#endif
+	}
+
+	/*
+	 * common ...
+	 */
+	evRootX = msg.pt.x;
+	evRootY = msg.pt.y;
 #if 1
-        {
-            POINT p;
-
-            if (GetCursorPos(&p)) {
-                evRootX = p.x;
-                evRootY = p.y;
-            }
-        }
-#endif
-        lastMSGTime = msg.time;
-        DispatchMessageW(&msg);   /* Dispatches message to window */
+	{
+	    POINT p;
+
+	    if (GetCursorPos(&p)) {
+		evRootX = p.x;
+		evRootY = p.y;
+	    }
+	}
+#endif
+	lastMSGTime = msg.time;
+	DispatchMessageW(&msg);   /* Dispatches message to window */
     }
 }
 
@@ -4902,20 +4955,20 @@
      */
     cwi = pendingCREATEWINDOWInfo;
     if (cwi) {
-        int dummyWantDefault;
-        int seqNr = pendingSequenceNr;
-
-        pendingCREATEWINDOWInfo = 0;
-        pendingSequenceNr = INVALIDATED_CWI;
-        DPRINTF(("### THREAD_CREATEWINDOW\n"));
-        winEventProcessing(0, WM_THREAD_CREATEWINDOW, seqNr, (INT)cwi, &dummyWantDefault);
+	int dummyWantDefault;
+	int seqNr = pendingSequenceNr;
+
+	pendingCREATEWINDOWInfo = 0;
+	pendingSequenceNr = INVALIDATED_CWI;
+	DPRINTF(("### THREAD_CREATEWINDOW\n"));
+	winEventProcessing(0, WM_THREAD_CREATEWINDOW, seqNr, (INT)cwi, &dummyWantDefault);
     }
 
     retVal = winEventProcessing(hWnd, message, wParam, lParam, &wantDefault);
     if (wantDefault) {
-        DDDPRINTF((">>DefWindowProc\n"));
-        retVal = DefWindowProcW(hWnd, message, wParam, lParam);
-        DDDPRINTF(("<<DefWindowProc\n"));
+	DDDPRINTF((">>DefWindowProc\n"));
+	retVal = DefWindowProcW(hWnd, message, wParam, lParam);
+	DDDPRINTF(("<<DefWindowProc\n"));
     }
     return retVal;
 }
@@ -4923,19 +4976,19 @@
 static int CALLBACK
 EnumWindowsProc(HWND hwnd, LPARAM lParam)
 {
-        volatile OBJ *refToCollection;
-        OBJ collection;
-        OBJ wHandle;
-
-        if (hwnd) {
-            refToCollection = (OBJ*) lParam;
-            __PROTECT__(*refToCollection);
-            wHandle = __MKEXTERNALADDRESS(hwnd);
-            __UNPROTECT__(*refToCollection);
-            collection = *refToCollection;
-            __SSEND1( collection, @symbol(add:), 0, wHandle );
-        }
-        return TRUE;
+	volatile OBJ *refToCollection;
+	OBJ collection;
+	OBJ wHandle;
+
+	if (hwnd) {
+	    refToCollection = (OBJ*) lParam;
+	    __PROTECT__(*refToCollection);
+	    wHandle = __MKEXTERNALADDRESS(hwnd);
+	    __UNPROTECT__(*refToCollection);
+	    collection = *refToCollection;
+	    __SSEND1( collection, @symbol(add:), 0, wHandle );
+	}
+	return TRUE;
 }
 
 #ifdef USE_EnumFontFamiliesEx
@@ -4951,26 +5004,26 @@
     DWORD dwType,              /* font type */
     LPARAM lpData              /* application supplied data */
 ) {
-        OBJ t;
-        volatile OBJ *refToList;
-        OBJ  typeFaceList;
-        char *faceNameString;
-
-        if (lplf) {
-            refToList = (OBJ *) lpData;
-            __PROTECT__(*refToList);
+	OBJ t;
+	volatile OBJ *refToList;
+	OBJ  typeFaceList;
+	char *faceNameString;
+
+	if (lplf) {
+	    refToList = (OBJ *) lpData;
+	    __PROTECT__(*refToList);
 
 #ifdef USE_EnumFontFamiliesEx
-            faceNameString = lplf->elfLogFont.lfFaceName;
-#else
-            faceNameString = lplf->lfFaceName;
-#endif
-            t = __MKSTRING( faceNameString );
-            __UNPROTECT__(*refToList);
-            typeFaceList = *refToList;
-            __SSEND1( typeFaceList, @symbol(add:), 0, t );
-        }
-        return 1;
+	    faceNameString = lplf->elfLogFont.lfFaceName;
+#else
+	    faceNameString = lplf->lfFaceName;
+#endif
+	    t = __MKSTRING( faceNameString );
+	    __UNPROTECT__(*refToList);
+	    typeFaceList = *refToList;
+	    __SSEND1( typeFaceList, @symbol(add:), 0, t );
+	}
+	return 1;
 }
 
 /*
@@ -5007,98 +5060,98 @@
     OBJ s;
 
     switch (charSet) {
-        case ANSI_CHARSET:
-            s = @symbol('ms-ansi');
-            break;
-        case DEFAULT_CHARSET:
-            s = @symbol('ms-default');
-            break;
-        case SYMBOL_CHARSET:
-            s = @symbol('ms-symbol');
-            break;
-        case SHIFTJIS_CHARSET:
-            s = @symbol('ms-shiftjis');
-            break;
-        case GB2312_CHARSET:
-            s = @symbol('ms-gb2312');
-            break;
-        case HANGEUL_CHARSET:
-            s = @symbol('ms-hangeul');
-            break;
+	case ANSI_CHARSET:
+	    s = @symbol('ms-ansi');
+	    break;
+	case DEFAULT_CHARSET:
+	    s = @symbol('ms-default');
+	    break;
+	case SYMBOL_CHARSET:
+	    s = @symbol('ms-symbol');
+	    break;
+	case SHIFTJIS_CHARSET:
+	    s = @symbol('ms-shiftjis');
+	    break;
+	case GB2312_CHARSET:
+	    s = @symbol('ms-gb2312');
+	    break;
+	case HANGEUL_CHARSET:
+	    s = @symbol('ms-hangeul');
+	    break;
 # if defined(HANGUL_CHARSET) && (HANGUL_CHARSET != HANGEUL_CHARSET)
-        case HANGUL_CHARSET:
-            s = @symbol('ms-hangul');
-            break;
-# endif
-        case CHINESEBIG5_CHARSET:
-            s = @symbol('ms-chinesebig5');
-            break;
-        case OEM_CHARSET:
-            s = @symbol('ms-oem');
-            break;
+	case HANGUL_CHARSET:
+	    s = @symbol('ms-hangul');
+	    break;
+# endif
+	case CHINESEBIG5_CHARSET:
+	    s = @symbol('ms-chinesebig5');
+	    break;
+	case OEM_CHARSET:
+	    s = @symbol('ms-oem');
+	    break;
 # ifdef JOHAB_CHARSET
-        case JOHAB_CHARSET:
-            s = @symbol('ms-johab');
-            break;
+	case JOHAB_CHARSET:
+	    s = @symbol('ms-johab');
+	    break;
 # endif
 # ifdef HEBREW_CHARSET
-        case HEBREW_CHARSET:
-            s = @symbol('ms-hebrew');
-            break;
+	case HEBREW_CHARSET:
+	    s = @symbol('ms-hebrew');
+	    break;
 # endif
 # ifdef ARABIC_CHARSET
-        case ARABIC_CHARSET:
-            s = @symbol('ms-arabic');
-            break;
+	case ARABIC_CHARSET:
+	    s = @symbol('ms-arabic');
+	    break;
 # endif
 # ifdef GREEK_CHARSET
-        case GREEK_CHARSET:
-            s = @symbol('ms-greek');
-            break;
+	case GREEK_CHARSET:
+	    s = @symbol('ms-greek');
+	    break;
 # endif
 # ifdef TURKISH_CHARSET
-        case TURKISH_CHARSET:
-            s = @symbol('ms-turkish');
-            break;
+	case TURKISH_CHARSET:
+	    s = @symbol('ms-turkish');
+	    break;
 # endif
 # ifdef RUSSIAN_CHARSET
-        case RUSSIAN_CHARSET:
-            s = @symbol('ms-russian');
-            break;
+	case RUSSIAN_CHARSET:
+	    s = @symbol('ms-russian');
+	    break;
 # endif
 # ifdef EASTEUROPE_CHARSET
-        case EASTEUROPE_CHARSET:
-            s = @symbol('ms-easteurope');
-            break;
+	case EASTEUROPE_CHARSET:
+	    s = @symbol('ms-easteurope');
+	    break;
 # endif
 # ifdef BALTIC_CHARSET
-        case BALTIC_CHARSET:
-            s = @symbol('ms-baltic');
-            break;
+	case BALTIC_CHARSET:
+	    s = @symbol('ms-baltic');
+	    break;
 # endif
 # ifdef VIETNAMESE_CHARSET
-        case VIETNAMESE_CHARSET:
-            s = @symbol('ms-vietnamese');
-            break;
+	case VIETNAMESE_CHARSET:
+	    s = @symbol('ms-vietnamese');
+	    break;
 # endif
 # ifdef THAI_CHARSET
-        case THAI_CHARSET:
-            s = @symbol('ms-thai');
-            break;
+	case THAI_CHARSET:
+	    s = @symbol('ms-thai');
+	    break;
 # endif
 # ifdef MAC_CHARSET
-        case MAC_CHARSET:
-            s = @symbol('ms-mac');
-            break;
+	case MAC_CHARSET:
+	    s = @symbol('ms-mac');
+	    break;
 # endif
 # ifdef UNICODE_CHARSET
-        case UNICODE_CHARSET:
-            s = @symbol('ms-unicode');
-            break;
-# endif
-        default:
-            s = @symbol(unknown);
-            break;
+	case UNICODE_CHARSET:
+	    s = @symbol('ms-unicode');
+	    break;
+# endif
+	default:
+	    s = @symbol(unknown);
+	    break;
     }
     return s;
 }
@@ -5106,106 +5159,106 @@
 OBJ
 __extractLogicalFontParameters(LOGFONT *lplf)
 {
-        OBJ newArray, t;
-        OBJ s;
-
-        DPRINTF((" lfHeight          %d\n", lplf->lfHeight ));
-        DPRINTF((" lfWidth           %d\n", lplf->lfWidth  ));
-        DPRINTF((" lfEscapement      %d\n", lplf->lfEscapement  ));
-        DPRINTF((" lfOrientation     %d\n", lplf->lfOrientation  ));
-        DPRINTF((" lfWeight          %d\n", lplf->lfWeight  ));
-        DPRINTF((" lfItalic          %d\n", lplf->lfItalic  ));
-        DPRINTF((" lfUnderline       %d\n", lplf->lfUnderline  ));
-        DPRINTF((" lfStrikeOut       %d\n", lplf->lfStrikeOut  ));
-        DPRINTF((" lfCharSet         %d\n", lplf->lfCharSet  ));
-        DPRINTF((" lfOutPrecision    %d\n", lplf->lfOutPrecision  ));
-        DPRINTF((" lfClipPrecision   %d\n", lplf->lfClipPrecision  ));
-        DPRINTF((" lfQuality         %d\n", lplf->lfQuality  ));
-        DPRINTF((" lfPitchAndFamily  %d\n", lplf->lfPitchAndFamily  ));
-        DPRINTF((" lfFaceName        %s\n\n", lplf->lfFaceName  ));
-
-        newArray = __ARRAY_NEW_INT(20);
-
-        __ArrayInstPtr(newArray)->a_element[0] = __MKSMALLINT(lplf->lfHeight);
-        __ArrayInstPtr(newArray)->a_element[1] = __MKSMALLINT(lplf->lfWidth);
-        __ArrayInstPtr(newArray)->a_element[2] = __MKSMALLINT(lplf->lfEscapement);
-        __ArrayInstPtr(newArray)->a_element[3] = __MKSMALLINT(lplf->lfOrientation);
-        __ArrayInstPtr(newArray)->a_element[4] = __MKSMALLINT(lplf->lfWeight);
-        switch (lplf->lfWeight) {
-            case FW_HEAVY:
-            case FW_EXTRABOLD:
-            case FW_SEMIBOLD:
-            case FW_BOLD:
-                s = @symbol(bold);
-                break;
-            case FW_NORMAL:
-#if 0
-                s = @symbol(normal);
-                break;
-#endif
-            case FW_MEDIUM:
-                s = @symbol(medium);
-                break;
-            case FW_THIN:
-            case FW_EXTRALIGHT:
-            case FW_LIGHT:
-                s = @symbol(demi);
-                break;
-            default:
-                s = @symbol(other);
-                break;
-        }
-        __ArrayInstPtr(newArray)->a_element[5] = s; __STORE(newArray, s);
-        __ArrayInstPtr(newArray)->a_element[6] = __MKSMALLINT(lplf->lfItalic);
-        __ArrayInstPtr(newArray)->a_element[7] = __MKSMALLINT(lplf->lfUnderline);
-        __ArrayInstPtr(newArray)->a_element[8] = __MKSMALLINT(lplf->lfStrikeOut);
-        __ArrayInstPtr(newArray)->a_element[9] = __MKSMALLINT(lplf->lfCharSet);
-        __ArrayInstPtr(newArray)->a_element[10] = __MKSMALLINT(lplf->lfOutPrecision);
-        __ArrayInstPtr(newArray)->a_element[11] = __MKSMALLINT(lplf->lfClipPrecision);
-        __ArrayInstPtr(newArray)->a_element[12] = __MKSMALLINT(lplf->lfQuality);
-        __ArrayInstPtr(newArray)->a_element[13] = __MKSMALLINT(lplf->lfPitchAndFamily);
-        /* ... */
-
-        if( lplf->lfItalic == TRUE ) {
-            if( lplf->lfUnderline == TRUE ) {
-                if( lplf->lfStrikeOut == TRUE ) {
-                    s = @symbol('italic-underline-strikeOut');
-                } else {
-                    s = @symbol('italic-underline');
-                }
-            } else {
-                if( lplf->lfStrikeOut == TRUE ) {
-                    s = @symbol('italic-strikeOut');
-                } else {
-                    s = @symbol('italic');
-                }
-            }
-        } else {
-            if( lplf->lfUnderline == TRUE ) {
-                if( lplf->lfStrikeOut == TRUE ) {
-                    s = @symbol('roman-underline-strikeOut');
-                } else {
-                    s = @symbol('roman-underline');
-                }
-            } else {
-                if( lplf->lfStrikeOut == TRUE ) {
-                    s = @symbol('roman-strikeOut');
-                } else {
-                    s = @symbol('roman');
-                }
-            }
-        }
-        __ArrayInstPtr(newArray)->a_element[14] = s; __STORE(newArray, s);
-
-        __PROTECT__(newArray);
-        t = __MKSTRING(lplf->lfFaceName);
-        __UNPROTECT__(newArray);
-        __ArrayInstPtr(newArray)->a_element[15] = t; __STORE(newArray, t);
-
-        t = __charSetSymbolFor(lplf->lfCharSet);
-        __ArrayInstPtr(newArray)->a_element[16] = t; __STORE(newArray, t);
-
-        return newArray;
+	OBJ newArray, t;
+	OBJ s;
+
+	DPRINTF((" lfHeight          %d\n", lplf->lfHeight ));
+	DPRINTF((" lfWidth           %d\n", lplf->lfWidth  ));
+	DPRINTF((" lfEscapement      %d\n", lplf->lfEscapement  ));
+	DPRINTF((" lfOrientation     %d\n", lplf->lfOrientation  ));
+	DPRINTF((" lfWeight          %d\n", lplf->lfWeight  ));
+	DPRINTF((" lfItalic          %d\n", lplf->lfItalic  ));
+	DPRINTF((" lfUnderline       %d\n", lplf->lfUnderline  ));
+	DPRINTF((" lfStrikeOut       %d\n", lplf->lfStrikeOut  ));
+	DPRINTF((" lfCharSet         %d\n", lplf->lfCharSet  ));
+	DPRINTF((" lfOutPrecision    %d\n", lplf->lfOutPrecision  ));
+	DPRINTF((" lfClipPrecision   %d\n", lplf->lfClipPrecision  ));
+	DPRINTF((" lfQuality         %d\n", lplf->lfQuality  ));
+	DPRINTF((" lfPitchAndFamily  %d\n", lplf->lfPitchAndFamily  ));
+	DPRINTF((" lfFaceName        %s\n\n", lplf->lfFaceName  ));
+
+	newArray = __ARRAY_NEW_INT(20);
+
+	__ArrayInstPtr(newArray)->a_element[0] = __MKSMALLINT(lplf->lfHeight);
+	__ArrayInstPtr(newArray)->a_element[1] = __MKSMALLINT(lplf->lfWidth);
+	__ArrayInstPtr(newArray)->a_element[2] = __MKSMALLINT(lplf->lfEscapement);
+	__ArrayInstPtr(newArray)->a_element[3] = __MKSMALLINT(lplf->lfOrientation);
+	__ArrayInstPtr(newArray)->a_element[4] = __MKSMALLINT(lplf->lfWeight);
+	switch (lplf->lfWeight) {
+	    case FW_HEAVY:
+	    case FW_EXTRABOLD:
+	    case FW_SEMIBOLD:
+	    case FW_BOLD:
+		s = @symbol(bold);
+		break;
+	    case FW_NORMAL:
+#if 0
+		s = @symbol(normal);
+		break;
+#endif
+	    case FW_MEDIUM:
+		s = @symbol(medium);
+		break;
+	    case FW_THIN:
+	    case FW_EXTRALIGHT:
+	    case FW_LIGHT:
+		s = @symbol(demi);
+		break;
+	    default:
+		s = @symbol(other);
+		break;
+	}
+	__ArrayInstPtr(newArray)->a_element[5] = s; __STORE(newArray, s);
+	__ArrayInstPtr(newArray)->a_element[6] = __MKSMALLINT(lplf->lfItalic);
+	__ArrayInstPtr(newArray)->a_element[7] = __MKSMALLINT(lplf->lfUnderline);
+	__ArrayInstPtr(newArray)->a_element[8] = __MKSMALLINT(lplf->lfStrikeOut);
+	__ArrayInstPtr(newArray)->a_element[9] = __MKSMALLINT(lplf->lfCharSet);
+	__ArrayInstPtr(newArray)->a_element[10] = __MKSMALLINT(lplf->lfOutPrecision);
+	__ArrayInstPtr(newArray)->a_element[11] = __MKSMALLINT(lplf->lfClipPrecision);
+	__ArrayInstPtr(newArray)->a_element[12] = __MKSMALLINT(lplf->lfQuality);
+	__ArrayInstPtr(newArray)->a_element[13] = __MKSMALLINT(lplf->lfPitchAndFamily);
+	/* ... */
+
+	if( lplf->lfItalic == TRUE ) {
+	    if( lplf->lfUnderline == TRUE ) {
+		if( lplf->lfStrikeOut == TRUE ) {
+		    s = @symbol('italic-underline-strikeOut');
+		} else {
+		    s = @symbol('italic-underline');
+		}
+	    } else {
+		if( lplf->lfStrikeOut == TRUE ) {
+		    s = @symbol('italic-strikeOut');
+		} else {
+		    s = @symbol('italic');
+		}
+	    }
+	} else {
+	    if( lplf->lfUnderline == TRUE ) {
+		if( lplf->lfStrikeOut == TRUE ) {
+		    s = @symbol('roman-underline-strikeOut');
+		} else {
+		    s = @symbol('roman-underline');
+		}
+	    } else {
+		if( lplf->lfStrikeOut == TRUE ) {
+		    s = @symbol('roman-strikeOut');
+		} else {
+		    s = @symbol('roman');
+		}
+	    }
+	}
+	__ArrayInstPtr(newArray)->a_element[14] = s; __STORE(newArray, s);
+
+	__PROTECT__(newArray);
+	t = __MKSTRING(lplf->lfFaceName);
+	__UNPROTECT__(newArray);
+	__ArrayInstPtr(newArray)->a_element[15] = t; __STORE(newArray, t);
+
+	t = __charSetSymbolFor(lplf->lfCharSet);
+	__ArrayInstPtr(newArray)->a_element[16] = t; __STORE(newArray, t);
+
+	return newArray;
 }
 
 
@@ -5216,37 +5269,37 @@
     DWORD dwType,              // font type
     LPARAM lpData              // application supplied data
 ) {
-        volatile OBJ *refToList;
-        OBJ list;
-        OBJ infoArray;
-        OBJ *fullName;
-
-        DPRINTF(("EnumFontsProc\n"));
-
-        if ( lplf ) {
-            refToList = (OBJ *) lpData;
-
-            __PROTECT__(*refToList);
+	volatile OBJ *refToList;
+	OBJ list;
+	OBJ infoArray;
+	OBJ *fullName;
+
+	DPRINTF(("EnumFontsProc\n"));
+
+	if ( lplf ) {
+	    refToList = (OBJ *) lpData;
+
+	    __PROTECT__(*refToList);
 #ifdef USE_EnumFontFamiliesEx
-            infoArray = __extractLogicalFontParameters(lplf->elfLogFont);
-            __PROTECT__(infoArray);
-            fullName = __MKSTRING(lplf->elfFullName);
-            __UNPROTECT__(infoArray);
-            __ArrayInstPtr(infoArray)->a_element[17] = fullName; __STORE(infoArray, fullName);
-#else
-            infoArray = __extractLogicalFontParameters(lplf);
-#endif
-
-            __UNPROTECT__(*refToList);
-
-            if ( dwType & TRUETYPE_FONTTYPE ) {
-                /* change height to 0 to mark variable fonts */
-                __ArrayInstPtr(infoArray)->a_element[0] = __MKSMALLINT(0);
-            }
-            list = *refToList;
-            __SSEND1(list, @symbol(add:), 0, infoArray);
-        }
-        return 1;
+	    infoArray = __extractLogicalFontParameters(lplf->elfLogFont);
+	    __PROTECT__(infoArray);
+	    fullName = __MKSTRING(lplf->elfFullName);
+	    __UNPROTECT__(infoArray);
+	    __ArrayInstPtr(infoArray)->a_element[17] = fullName; __STORE(infoArray, fullName);
+#else
+	    infoArray = __extractLogicalFontParameters(lplf);
+#endif
+
+	    __UNPROTECT__(*refToList);
+
+	    if ( dwType & TRUETYPE_FONTTYPE ) {
+		/* change height to 0 to mark variable fonts */
+		__ArrayInstPtr(infoArray)->a_element[0] = __MKSMALLINT(0);
+	    }
+	    list = *refToList;
+	    __SSEND1(list, @symbol(add:), 0, infoArray);
+	}
+	return 1;
 }
 
 struct EnumDisplayMonitorsProcData {
@@ -12941,18 +12994,18 @@
 
     |error|
 
-%{ 
+%{
     registerHotKeyInfo * rhki = NULL;
     HWND hWnd = NULL;
 
     if (__isExternalAddress(aDrawableId)) {
-        hWnd = _HWNDVal(aDrawableId);
-
-        if (! hWnd) {
-            RETURN (false);
-        }
-    } else {
-        RETURN (false);
+	hWnd = _HWNDVal(aDrawableId);
+
+	if (! hWnd) {
+	    RETURN (false);
+	}
+    } else {
+	RETURN (false);
     }
 
     rhki = (registerHotKeyInfo *) malloc(sizeof(registerHotKeyInfo));
@@ -12965,12 +13018,12 @@
 
     // the same thread that created the window musr register the hotkey!
     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_REGISTERHOTKEY, 0, (INT)rhki) == FALSE) {
-        console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in registerHotKeyForWindow: err=%d\n",
-                                        _dispatchThreadId, GetLastError() );
-        RETURN (false);
+	console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in registerHotKeyForWindow: err=%d\n",
+					_dispatchThreadId, GetLastError() );
+	RETURN (false);
     }
     while (rhki->finished == 0) {
-        Sleep(2);   // milliseconds
+	Sleep(2);   // milliseconds
     }
     error = __MKINT(rhki->errorCode);
     free(rhki);
@@ -13011,18 +13064,18 @@
 
     |error|
 
-%{  
+%{
     registerHotKeyInfo * rhki = NULL;
     HWND hWnd = NULL;
 
     if (__isExternalAddress(aDrawableId)) {
-        hWnd = _HWNDVal(aDrawableId);
-
-        if (! hWnd) {
-            RETURN (false);
-        }
-    } else {
-        RETURN (false);
+	hWnd = _HWNDVal(aDrawableId);
+
+	if (! hWnd) {
+	    RETURN (false);
+	}
+    } else {
+	RETURN (false);
     }
 
     rhki = (registerHotKeyInfo *) malloc(sizeof(registerHotKeyInfo));
@@ -13034,13 +13087,13 @@
     rhki->finished   = 0;
 
     if (PostThreadMessage(_dispatchThreadId, WM_THREAD_UNREGISTERHOTKEY, 0, (INT)rhki) == FALSE) {
-        console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in unregisterHotKeyForWindow: err=%d\n",
-                                        _dispatchThreadId, GetLastError() );
-        RETURN (false);
+	console_fprintf(stderr, "WinWorkstation [error]: oops - PostThreadMessage(%x) failed in unregisterHotKeyForWindow: err=%d\n",
+					_dispatchThreadId, GetLastError() );
+	RETURN (false);
     }
 
     while (rhki->finished == 0) {
-        Sleep(2);   // milliseconds
+	Sleep(2);   // milliseconds
     }
     error = __MKINT(rhki->errorCode);
     free(rhki);
@@ -16470,6 +16523,252 @@
     "Modified: / 02-03-2007 / 15:37:47 / cg"
 ! !
 
+!WinWorkstation methodsFor:'native file dialog'!
+
+nativeFileDialogWithTitle:dialogTitle
+    defaultFilename:defaultFilename
+    owningViewId:owningViewId
+    filterString:filterString
+    filterIndex:filterIndexArg
+    doSave:doSave
+
+    "opens a native windows file dialog,
+     supports unicode 16 strings (like windows does it for filenames)
+     see example at the end of the method code"
+
+    |dataAddressAndThreadAddress dataAddress returnValue|
+
+    [
+        dataAddressAndThreadAddress := self 
+            primNativeFileDialogWithTitle:dialogTitle asUnicode16String
+            defaultFilename:defaultFilename asUnicode16String
+            owningViewId:owningViewId
+            filterString:filterString asUnicode16String
+            filterIndex:filterIndexArg 
+            doSave:doSave.
+
+        dataAddress := dataAddressAndThreadAddress first.
+
+        [
+            returnValue := self primGetNativeFileDialogResultByDataAddress:dataAddress.
+        ] doWhile:[
+            returnValue isNil 
+        ].
+    ] ensure:[
+        (dataAddressAndThreadAddress notNil 
+        "/ if #returnValue is not nil, we already finished and did the memory free
+        and:[returnValue isNil]) ifTrue:[
+            Display 
+                primCloseNativeFileDialogByDataAddress:dataAddressAndThreadAddress first
+                threadHandleAddress:dataAddressAndThreadAddress second.    
+        ].
+    ].
+
+    ^ returnValue
+
+    "
+    ########### example1 without owning view ##########
+
+        |null|
+
+        null := (Character codePoint:0) asString.    
+
+        Display 
+            nativeFileDialogWithTitle:'Hello World' 
+            defaultFilename:'D:\sadasdsad'   
+            owningViewId:nil
+            filterString:
+                'expecco Testsuite', null, '*.ets', null, 
+                'expecco Logfile', null, '*.elf', null, 
+                null
+            filterIndex:2
+            doSave:false. 
+
+    ########### example2 without owning view and termination ##########
+
+        |null p|
+
+        null := (Character codePoint:0) asString.    
+
+        p := 
+            [
+                Display 
+                    nativeFileDialogWithTitle:'Hello World' 
+                    defaultFilename:'D:\sadasdsad'   
+                    owningViewId:nil
+                    filterString:
+                        'expecco Testsuite', null, '*.ets', null, 
+                        'expecco Logfile', null, '*.elf', null, 
+                        null
+                    filterIndex:2
+                    doSave:false.    
+            ] fork.
+
+        Delay waitForSeconds:5. 
+
+        p terminate.  
+
+    ########### example2 with owning view (makes the launcher modal) ##########
+
+        |null owningViewId|
+
+        null := (Character codePoint:0) asString.    
+        owningViewId := NewLauncher open window topView id.
+        Delay waitForSeconds:1. 
+
+        Display 
+            nativeFileDialogWithTitle:'Hello World' 
+            defaultFilename:'D:\sadasdsad'   
+            owningViewId:owningViewId
+            filterString:
+                'expecco Testsuite', null, '*.ets', null, 
+                'expecco Logfile', null, '*.elf', null, 
+                null
+            filterIndex:2
+            doSave:false.    
+
+    ########### example3 with owning view (makes the launcher modal) and termination ##########
+
+        |null owningViewId p|
+
+        null := (Character codePoint:0) asString.    
+        owningViewId := NewLauncher open window topView id.
+        Delay waitForSeconds:1. 
+
+        p := 
+            [
+                Display 
+                    nativeFileDialogWithTitle:'Hello World' 
+                    defaultFilename:'D:\sadasdsad'   
+                    owningViewId:owningViewId
+                    filterString:
+                        'expecco Testsuite', null, '*.ets', null, 
+                        'expecco Logfile', null, '*.elf', null, 
+                        null
+                    filterIndex:2
+                    doSave:false.    
+            ] fork.
+
+        Delay waitForSeconds:5. 
+
+        p terminate.
+    "
+
+    "Created: / 22-10-2018 / 11:20:31 / sr"
+    "Modified (comment): / 22-10-2018 / 14:03:20 / sr"
+!
+
+primCloseNativeFileDialogByDataAddress:dataAddress
+    threadHandleAddress:threadHandleAddress
+
+    "this method can cleanly close/destroy an open native file dialog.
+     this is called as an ensure, when the native file dialog process gets terminated
+     this is required because windows does not cleanup the dialog by itself when its thread gets terminated"
+
+%{  /* STACK: 100000 */ 
+    if (__isExternalAddress(threadHandleAddress)) {
+        HANDLE fileDialogThread = _HWNDVal(threadHandleAddress);
+        DWORD fileDialogThreadId = GetThreadId(fileDialogThread);
+
+        BOOL CALLBACK enumWindowsToFindAndDestroyFileDialogProc(HWND hwnd, LPARAM lParam) {
+            if (GetWindowThreadProcessId(hwnd, NULL) == fileDialogThreadId) {
+                EndDialog(hwnd, 0);
+                DestroyWindow(hwnd);
+            }
+
+            return TRUE;
+        };   
+
+        EnumWindows(enumWindowsToFindAndDestroyFileDialogProc, NULL);
+        TerminateThread(fileDialogThread, 0); 
+        CloseHandle(fileDialogThread);
+    };  
+
+    if (__isExternalAddress(dataAddress)) {
+        free(__externalAddressVal(dataAddress));
+    }
+%}.
+
+    "Created: / 22-10-2018 / 13:53:02 / sr"
+!
+
+primGetNativeFileDialogResultByDataAddress:dataAddress
+    "returns nil if the native file dialog is still open
+     returns an empty string if the file dialog was canceled
+     returns the full path to the user selected file"
+
+    |targetFileOrNil|
+
+%{  /* STACK: 100000 */ 
+    if (__isExternalAddress(dataAddress)) {
+        fileDialogData *pFdd = __externalAddressVal(dataAddress);     
+
+        if (pFdd->fileDialogDidReturn) {
+            targetFileOrNil = __MKU16STRING(pFdd->filename);     
+            free(pFdd);
+        }
+    }
+%}.
+
+    ^ targetFileOrNil
+
+    "Created: / 22-10-2018 / 13:52:47 / sr"
+!
+
+primNativeFileDialogWithTitle:dialogTitle
+    defaultFilename:defaultFilename
+    owningViewId:owningViewId
+    filterString:filterString
+    filterIndex:filterIndexArg
+    doSave:doSave
+
+    "do not call this directly, use #nativeFileDialogWithTitle:..."
+
+    |fileDialogDataAddress fileDialogThreadHandle|
+
+%{  /* STACK: 100000 */ 
+    int i;
+    fileDialogData *pFileDialogData = malloc(sizeof(fileDialogData));
+    ZeroMemory(pFileDialogData, sizeof(fileDialogData)); 
+
+    if (__isUnicode16String(defaultFilename)) {
+        for (i = 0; i < __unicode16StringSize(defaultFilename); i++) {
+            pFileDialogData->filename[i] = __unicode16StringVal(defaultFilename)[i];
+        }
+        pFileDialogData->filename[i] = 0;
+    };        
+    if (__isUnicode16String(dialogTitle)) {
+        for (i = 0; i < __unicode16StringSize(dialogTitle); i++) {
+            pFileDialogData->title[i] = __unicode16StringVal(dialogTitle)[i];
+        }
+        pFileDialogData->title[i] = 0;  
+    };         
+    if (__isExternalAddress(owningViewId)) {
+        pFileDialogData->owningWindow = _HWNDVal(owningViewId);
+    };  
+    if (__isUnicode16String(filterString)) {
+        for (i = 0; i < __unicode16StringSize(filterString); i++) {
+            pFileDialogData->filter[i] = __unicode16StringVal(filterString)[i];
+        }
+        pFileDialogData->filter[i] = 0;  
+    };   
+    if (__isInteger(filterIndexArg)) {
+        pFileDialogData->filterIndex = filterIndexArg;
+    }
+    pFileDialogData->trueForSave = doSave == true;
+    pFileDialogData->fileDialogDidReturn = FALSE;
+
+    fileDialogDataAddress = __MKEXTERNALADDRESS(pFileDialogData);   
+    fileDialogThreadHandle = __MKEXTERNALADDRESS(openFileDialogInNewThread(pFileDialogData));
+%}.
+
+    ^ Array
+        with:fileDialogDataAddress
+        with:fileDialogThreadHandle
+
+    "Created: / 22-10-2018 / 13:31:46 / sr"
+! !
+
 !WinWorkstation methodsFor:'native widget support'!
 
 nativeDialogs
@@ -19155,7 +19454,7 @@
     }
 %}
     "
-     (StandardSystemView new label:'äöü') open
+     (StandardSystemView new label:'äöü') open
     "
 !