Index: trunk/src/user32/dc.cpp
===================================================================
--- trunk/src/user32/dc.cpp	(revision 4451)
+++ trunk/src/user32/dc.cpp	(revision 4452)
@@ -1,3 +1,3 @@
-/* $Id: dc.cpp,v 1.71 2000-10-05 18:37:25 sandervl Exp $ */
+/* $Id: dc.cpp,v 1.72 2000-10-08 14:03:48 sandervl Exp $ */
 
 /*
@@ -72,4 +72,23 @@
 LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps);
 
+#ifdef DEBUG
+#define dprintfRegion(a,b,c) if(DbgEnabledLvl2[DBG_LOCALLOG] == 1) dprintfRegion1(a,b,c)
+
+void dprintfRegion1(HPS hps, HWND hWnd, HRGN hrgnClip)
+{
+ RGNRECT rgnRect = {0, 16, 0, RECTDIR_LFRT_TOPBOT};
+ RECTL   rectRegion[16];
+ APIRET  rc;
+
+   dprintf(("dprintfRegion %x %x", hWnd, hps));
+   rc = GpiQueryRegionRects(hps, hrgnClip, NULL, &rgnRect, &rectRegion[0]);
+   for(int i=0;i<rgnRect.crcReturned;i++) {
+	dprintf(("(%d,%d)(%d,%d)", rectRegion[i].xLeft, rectRegion[i].yBottom, rectRegion[i].xRight, rectRegion[i].yTop));
+   }
+}
+#else
+#define dprintfRegion(a,b,c)
+#endif
+
 //******************************************************************************
 //******************************************************************************
@@ -302,5 +321,5 @@
 //******************************************************************************
 //******************************************************************************
-VOID removeClientArea(pDCData pHps)
+VOID removeClientArea(Win32BaseWindow *window, pDCData pHps)
 {
  POINTL point;
@@ -315,5 +334,5 @@
    if(pHps->isClientArea)
    {
-   	dprintf2(("removeClientArea: (%d,%d) -> (%d,%d)", point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
+   	dprintf2(("removeClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
       	pHps->isClientArea = FALSE;
       	GreSetupDC(pHps->hps,
@@ -324,5 +343,5 @@
                    SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
    }
-   else dprintf(("removeClientArea: (%d,%d)", point.x, point.y));
+   else dprintf(("removeClientArea: %x (%d,%d)", window->getWindowHandle(), point.x, point.y));
 
 }
@@ -347,9 +366,4 @@
 	return;
    }
-   if(pHps->isClientArea) {
-	//TODO: counter
-	dprintf(("WARNING: selectClientArea; already selected!!"));
-	return;
-   }
    pHps->isClient = TRUE;
 
@@ -360,13 +374,34 @@
    //convert to screen coordinates
    GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
-   rcl.xLeft   += rcltemp.xLeft;
-   rcl.xRight  += rcltemp.xLeft;
-   rcl.yTop    += rcltemp.yBottom;
-   rcl.yBottom += rcltemp.yBottom;
-	
+
+   if(pHps->isClientArea) 
+   {
+	//TODO: counter
+	dprintf(("WARNING: selectClientArea %x; already selected! origin (%d,%d) original origin (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
+	RECT rectWindow;
+        RECTL rectWindowOS2;
+	GetWindowRect(window->getWindowHandle(), &rectWindow);
+	mapWin32ToOS2Rect(OSLibGetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);
+	if(rectWindowOS2.xLeft + rcl.xLeft != rcltemp.xLeft ||
+           rectWindowOS2.yBottom + rcl.yBottom != rcltemp.yBottom) 
+        {
+		dprintf(("WARNING: origin changed (%d,%d) instead of (%d,%d)!", rcltemp.xLeft, rcltemp.yBottom, rectWindowOS2.xLeft + rcl.xLeft, rectWindowOS2.yBottom + rcl.yBottom));
+        	rcl.xLeft   += rectWindowOS2.xLeft;
+        	rcl.xRight  += rectWindowOS2.xLeft;
+        	rcl.yTop    += rectWindowOS2.yBottom;
+        	rcl.yBottom += rectWindowOS2.yBottom;
+        }
+	else	return;
+   }
+   else {
+        rcl.xLeft   += rcltemp.xLeft;
+        rcl.xRight  += rcltemp.xLeft;
+        rcl.yTop    += rcltemp.yBottom;
+        rcl.yBottom += rcltemp.yBottom;
+   }
    pHps->ptlOrigin.x = rcltemp.xLeft;
    pHps->ptlOrigin.y = rcltemp.yBottom;
  
-   dprintf2(("selectClientArea: (%d,%d) -> (%d,%d)", rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom));
+   dprintf2(("selectClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom));
 
    if(pHps->hrgnVis == 0)
@@ -390,21 +425,4 @@
               SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
 
-/*
-      	GpiQueryRegionBox(pHps->hps, hrgnClip, &rcltemp);
-      	GpiQueryRegionBox(pHps->hps, hrgnOldClip, &rcltemp);
-
-      	GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
-
-      	GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
-
-      	GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_VISRGN);
-      	GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
-      
-      	GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_ALLINTERSECT);
-      	GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
-      
-      	GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_CLIPRGN);
-      	GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
-*/
    pHps->isClientArea = TRUE;
 
@@ -531,4 +549,6 @@
 {
    pDCData pHps = (pDCData)GpiQueryDCData ((HPS)hps);
+  
+   dprintf2(("releaseOwnDC %x", hps));
 
    if (pHps) {
@@ -544,24 +564,4 @@
    }
 }
-//******************************************************************************
-//******************************************************************************
-#ifdef DEBUG
-#define dprintfRegion(a,b,c) if(DbgEnabledLvl2[DBG_LOCALLOG] == 1) dprintfRegion1(a,b,c)
-
-void dprintfRegion1(HPS hps, HWND hWnd, HRGN hrgnClip)
-{
- RGNRECT rgnRect = {0, 16, 0, RECTDIR_LFRT_TOPBOT};
- RECTL   rectRegion[16];
- APIRET  rc;
-
-   dprintf(("dprintfRegion %x %x", hWnd, hps));
-   rc = GpiQueryRegionRects(hps, hrgnClip, NULL, &rgnRect, &rectRegion[0]);
-   for(int i=0;i<rgnRect.crcReturned;i++) {
-	dprintf(("(%d,%d)(%d,%d)", rectRegion[i].xLeft, rectRegion[i].yBottom, rectRegion[i].xRight, rectRegion[i].yTop));
-   }
-}
-#else
-#define dprintfRegion(a,b,c)
-#endif
 //******************************************************************************
 //******************************************************************************
@@ -751,5 +751,5 @@
  		pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
 		if(pHps && pHps->psType == MICRO_CACHED) {
-        		removeClientArea(pHps);
+        		removeClientArea(wnd, pHps);
 			if(pHps->hrgnVis) {
    				GreDestroyRegion(pHps->hps, pHps->hrgnVis);
@@ -762,4 +762,7 @@
 		}
    	}
+	else {
+		dprintf2(("ReleaseDC: CS_OWNDC, not released"));
+	}
    }
 
@@ -898,5 +901,5 @@
  	selectClientArea(wnd, pHps);
    }
-   else removeClientArea(pHps);
+   else removeClientArea(wnd, pHps);
 
    setMapMode(wnd, pHps, MM_TEXT_W);
Index: trunk/src/user32/oslibwin.h
===================================================================
--- trunk/src/user32/oslibwin.h	(revision 4451)
+++ trunk/src/user32/oslibwin.h	(revision 4452)
@@ -1,3 +1,3 @@
-/* $Id: oslibwin.h,v 1.46 2000-06-07 14:51:27 sandervl Exp $ */
+/* $Id: oslibwin.h,v 1.47 2000-10-08 14:03:49 sandervl Exp $ */
 /*
  * Window API wrappers for OS/2
@@ -292,3 +292,6 @@
 BOOL   OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible);
 
+ULONG OSLibGetScreenHeight();
+ULONG OSLibGetScreenWidth();
+
 #endif //__OSLIBWIN_H__
Index: trunk/src/user32/win32wbasepos.cpp
===================================================================
--- trunk/src/user32/win32wbasepos.cpp	(revision 4451)
+++ trunk/src/user32/win32wbasepos.cpp	(revision 4452)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasepos.cpp,v 1.16 2000-10-04 19:35:31 sandervl Exp $ */
+/* $Id: win32wbasepos.cpp,v 1.17 2000-10-08 14:03:49 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (nonclient/position methods)
@@ -75,4 +75,8 @@
             yinc += GetSystemMetrics(SM_CYFRAME);
         }
+	//SvL: Wine has no 'else', but I'm seeing different behaviour in NT
+        //     and it doesn't make much sense either as a window can have
+        //     only one kind of border (see drawing code)
+	else
         if (dwStyle & WS_BORDER)
         {
