Index: trunk/src/gdi32/gdi32.DEF
===================================================================
--- trunk/src/gdi32/gdi32.DEF	(revision 4753)
+++ trunk/src/gdi32/gdi32.DEF	(revision 4755)
@@ -1,3 +1,3 @@
-; $Id: gdi32.DEF,v 1.12 2000-08-14 15:51:19 cbratschi Exp $
+; $Id: gdi32.DEF,v 1.13 2000-12-05 13:04:05 sandervl Exp $
 
 ;Created by BLAST for IBM's compiler
@@ -357,6 +357,6 @@
 ;
     ObjAllocateHandle__FPUlUl10ObjectType                       @1201
-    ObjFreeHandle__FUl                                                          @1202
-    ObjGetHandleData__FUl                                       @1203
+    ObjFreeHandle__FUl                                          @1202
+    ObjGetHandleData__FUl10ObjectType                           @1203
     ObjGetHandleType__FUl                                       @1204
 
Index: trunk/src/gdi32/objhandle.cpp
===================================================================
--- trunk/src/gdi32/objhandle.cpp	(revision 4753)
+++ trunk/src/gdi32/objhandle.cpp	(revision 4755)
@@ -1,3 +1,3 @@
-/* $Id: objhandle.cpp,v 1.6 2000-11-15 13:56:45 sandervl Exp $ */
+/* $Id: objhandle.cpp,v 1.7 2000-12-05 13:04:06 sandervl Exp $ */
 /*
  * Win32 Handle Management Code for OS/2
@@ -30,7 +30,12 @@
 //******************************************************************************
 
-static ULONG  objHandleTable[MAX_OBJECT_HANDLES] = {0};
-static ULONG  lowestFreeIndex = 0;
-static VMutex objTableMutex;
+typedef struct {
+  ULONG      dwUserData;
+  ObjectType type;
+} GdiObject;
+
+static GdiObject objHandleTable[MAX_OBJECT_HANDLES] = {0};
+static ULONG     lowestFreeIndex = 0;
+static VMutex    objTableMutex;
 
 //******************************************************************************
@@ -38,27 +43,28 @@
 BOOL ObjAllocateHandle(HANDLE *hObject, DWORD dwUserData, ObjectType type)
 {
-  objTableMutex.enter(VMUTEX_WAIT_FOREVER);
-  if(lowestFreeIndex == -1) {
-    //oops, out of handles
-    dprintf(("ERROR: GDI: HwAllocateWindowHandle OUT OF GDI OBJECT HANDLES!!"));
+    objTableMutex.enter(VMUTEX_WAIT_FOREVER);
+    if(lowestFreeIndex == -1) {
+        //oops, out of handles
+        objTableMutex.leave();
+        dprintf(("ERROR: GDI: HwAllocateWindowHandle OUT OF GDI OBJECT HANDLES!!"));
+        DebugInt3();
+        return FALSE;
+    }
+    *hObject  = lowestFreeIndex;
+    *hObject |= MAKE_HANDLE(type);
+    objHandleTable[lowestFreeIndex].dwUserData = dwUserData;
+    objHandleTable[lowestFreeIndex].type       = type;
+
+    lowestFreeIndex = -1;
+
+    //find next free handle
+    for(int i=0;i<MAX_OBJECT_HANDLES;i++) {
+        if(objHandleTable[i].dwUserData == 0) {
+            lowestFreeIndex = i;
+            break;
+        }
+    }
     objTableMutex.leave();
-    DebugInt3();
-    return FALSE;
-  }
-  *hObject  = lowestFreeIndex;
-  *hObject |= MAKE_HANDLE(type);
-  objHandleTable[lowestFreeIndex] = dwUserData;
-
-  lowestFreeIndex = -1;
-
-  //find next free handle
-  for(int i=0;i<MAX_OBJECT_HANDLES;i++) {
-    if(objHandleTable[i] == 0) {
-        lowestFreeIndex = i;
-        break;
-    }
-  }
-  objTableMutex.leave();
-  return TRUE;
+    return TRUE;
 }
 //******************************************************************************
@@ -66,35 +72,24 @@
 void ObjFreeHandle(HANDLE hObject)
 {
-  hObject &= OBJHANDLE_MAGIC_MASK;
-  if(hObject < MAX_OBJECT_HANDLES) {
-    objTableMutex.enter(VMUTEX_WAIT_FOREVER);
-    objHandleTable[hObject] = 0;
-    if(lowestFreeIndex == -1 || hObject < lowestFreeIndex)
-        lowestFreeIndex = hObject;
-
-    objTableMutex.leave();
-  }
-}
-//******************************************************************************
-//******************************************************************************
-DWORD ObjGetHandleData(HANDLE hObject)
-{
-  switch(GET_OBJTYPE(hObject))
-  {
-  case GDIOBJ_REGION:
-    break;
-  //case GDIOBJ_BITMAP
-  //case GDIOBJ_BRUSH
-  //case GDIOBJ_PALETTE
-  //case GDIOBJ_FONT
-  default:
+    hObject &= OBJHANDLE_MAGIC_MASK;
+    if(hObject < MAX_OBJECT_HANDLES) {
+        objTableMutex.enter(VMUTEX_WAIT_FOREVER);
+        objHandleTable[hObject].dwUserData = 0;
+        objHandleTable[hObject].type = GDIOBJ_NONE;
+        if(lowestFreeIndex == -1 || hObject < lowestFreeIndex)
+            lowestFreeIndex = hObject;
+
+        objTableMutex.leave();
+    }
+}
+//******************************************************************************
+//******************************************************************************
+DWORD ObjGetHandleData(HANDLE hObject, ObjectType type)
+{
+    hObject &= OBJHANDLE_MAGIC_MASK;
+    if(hObject < MAX_OBJECT_HANDLES && type == objHandleTable[hObject].type) {
+        return objHandleTable[hObject].dwUserData;
+    }
     return HANDLE_OBJ_ERROR;
-  }
-
-  hObject &= OBJHANDLE_MAGIC_MASK;
-  if(hObject < MAX_OBJECT_HANDLES) {
-    return objHandleTable[hObject];
-  }
-  return HANDLE_OBJ_ERROR;
 }
 //******************************************************************************
@@ -102,15 +97,9 @@
 ObjectType ObjGetHandleType(HANDLE hObject)
 {
-  switch(GET_OBJTYPE(hObject))
-  {
-  case GDIOBJ_REGION:
-    return GDIOBJ_REGION;
-  //case GDIOBJ_BITMAP
-  //case GDIOBJ_BRUSH
-  //case GDIOBJ_PALETTE
-  //case GDIOBJ_FONT
-  default:
-    return GDIOBJ_ERROR;
-  }
+    hObject &= OBJHANDLE_MAGIC_MASK;
+    if(hObject < MAX_OBJECT_HANDLES && objHandleTable[hObject].dwUserData != 0) {
+        return objHandleTable[hObject].type;
+    }
+    return GDIOBJ_NONE;
 }
 //******************************************************************************
@@ -226,34 +215,34 @@
     if(DIBSection::getSection() != NULL)
     {
-      DIBSection *dsect;
-
-      dsect = DIBSection::find(hdc);
-      if(dsect)
-      {
-        //remove previously selected dibsection
-        dsect->UnSelectDIBObject();
-      }
-      dsect = DIBSection::find((DWORD)hObj);
-      if(dsect)
-      {
-        dsect->SelectDIBObject(hdc);
-      }
+        DIBSection *dsect;
+
+        dsect = DIBSection::find(hdc);
+        if(dsect)
+        {
+            //remove previously selected dibsection
+            dsect->UnSelectDIBObject();
+        }
+        dsect = DIBSection::find((DWORD)hObj);
+        if(dsect)
+        {
+            dsect->SelectDIBObject(hdc);
+        }
     }
     rc = O32_SelectObject(hdc, hObj);
     if(rc != 0 && DIBSection::getSection != NULL)
     {
-      DIBSection *dsect = DIBSection::find((DWORD)rc);
-      if(dsect)
-      {
-        dsect->UnSelectDIBObject();
-      }
+        DIBSection *dsect = DIBSection::find((DWORD)rc);
+        if(dsect)
+        {
+            dsect->UnSelectDIBObject();
+        }
     }
 #ifdef USING_OPEN32
-    if(O32_GetObjectType(hObj) == OBJ_BITMAP) 
-    {
-	//SvL: Open32 messes up the height of the hdc (for windows)
+    if(O32_GetObjectType(hObj) == OBJ_BITMAP)
+    {
+        //SvL: Open32 messes up the height of the hdc (for windows)
         pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
         if(pHps && pHps->hwnd) {
-      	      dprintf2(("change back origin"));
+              dprintf2(("change back origin"));
               selectClientArea(pHps);
               setPageXForm(pHps);
@@ -269,10 +258,10 @@
 DWORD WIN32API GetObjectType( HGDIOBJ hObj)
 {
-  dprintf2(("GDI32: GetObjectType\n"));
-  if(ObjGetHandleType(hObj) == GDIOBJ_REGION) {
+    dprintf2(("GDI32: GetObjectType\n"));
+    if(ObjGetHandleType(hObj) == GDIOBJ_REGION) {
         SetLastError(ERROR_SUCCESS);
-    return OBJ_REGION;
-  }
-  return O32_GetObjectType(hObj);
+        return OBJ_REGION;
+    }
+    return O32_GetObjectType(hObj);
 }
 //******************************************************************************
@@ -280,13 +269,13 @@
 BOOL WIN32API DeleteObject(HANDLE hObj)
 {
-  dprintf(("GDI32: DeleteObject %x", hObj));
-  if(ObjGetHandleType(hObj) == GDIOBJ_REGION) {
-    OSLibDeleteRegion(ObjGetHandleData(hObj));
-    ObjFreeHandle(hObj);
+    dprintf(("GDI32: DeleteObject %x", hObj));
+    if(ObjGetHandleType(hObj) == GDIOBJ_REGION) {
+        OSLibDeleteRegion(ObjGetHandleData(hObj, GDIOBJ_REGION));
+        ObjFreeHandle(hObj);
         SetLastError(ERROR_SUCCESS);
-    return OBJ_REGION;
-  }
-  DIBSection::deleteSection((DWORD)hObj);
-  return O32_DeleteObject(hObj);
+        return OBJ_REGION;
+    }
+    DIBSection::deleteSection((DWORD)hObj);
+    return O32_DeleteObject(hObj);
 }
 //******************************************************************************
@@ -294,8 +283,8 @@
 BOOL WIN32API SetObjectOwner( HGDIOBJ arg1, int arg2 )
 {
-  // Here is a guess for a undocumented entry
-  dprintf(("WARNING: GDI32: SetObjectOwner - stub (TRUE)\n"));
-  return TRUE;
-}
-//******************************************************************************
-//******************************************************************************
+    // Here is a guess for a undocumented entry
+    dprintf(("WARNING: GDI32: SetObjectOwner - stub (TRUE)\n"));
+    return TRUE;
+}
+//******************************************************************************
+//******************************************************************************
Index: trunk/src/gdi32/region.cpp
===================================================================
--- trunk/src/gdi32/region.cpp	(revision 4753)
+++ trunk/src/gdi32/region.cpp	(revision 4755)
@@ -1,3 +1,3 @@
-/* $Id: region.cpp,v 1.17 2000-11-15 13:56:46 sandervl Exp $ */
+/* $Id: region.cpp,v 1.18 2000-12-05 13:04:07 sandervl Exp $ */
 
 /*
@@ -378,5 +378,5 @@
     if(hrgn)
     {
-        hrgn = ObjGetHandleData(hrgn);
+        hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
         if(hrgn == HANDLE_OBJ_ERROR) {
             dprintf(("WARNING: SelectClipRgn: invalid region!", hdc, hrgn));
@@ -414,5 +414,5 @@
             //SvL: Must check if origin changed here. Sometimes happens when
             //     window looses focus. (don't know why....)
-            if(pHps->isClient) 
+            if(pHps->isClient)
                 selectClientArea(pHps);
             return lComplexity;
@@ -467,5 +467,5 @@
    if(hrgn)
    {
-        hrgn = ObjGetHandleData(hrgn);
+        hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
         if(hrgn == HANDLE_OBJ_ERROR) {
             dprintf(("WARNING: ExtSelectRgn %x %x %d invalid region handle", hdc, hrgn, mode));
@@ -527,5 +527,5 @@
         //SvL: Must check if origin changed here. Sometimes happens when
         //     window looses focus. (don't know why....)
-        if(pHps->isClient) 
+        if(pHps->isClient)
             selectClientArea(pHps);
 
@@ -614,5 +614,5 @@
    HRGN       hrgnClip = NULL, hrgnTemp;
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR || !pHps) {
         dprintf(("WARNING: GetClipRgn %x %x invalid handle", hdc, hrgn));
@@ -1079,7 +1079,7 @@
     }
 
-    hrgnDest = ObjGetHandleData(hrgnDest);
-    hrgnSrc1 = ObjGetHandleData(hrgnSrc1);
-    hrgnSrc2 = ObjGetHandleData(hrgnSrc2);
+    hrgnDest = ObjGetHandleData(hrgnDest, GDIOBJ_REGION);
+    hrgnSrc1 = ObjGetHandleData(hrgnSrc1, GDIOBJ_REGION);
+    hrgnSrc2 = ObjGetHandleData(hrgnSrc2, GDIOBJ_REGION);
     if(hrgnDest == HANDLE_OBJ_ERROR || hrgnSrc1 == HANDLE_OBJ_ERROR  || (hrgnSrc2 == HANDLE_OBJ_ERROR && combineMode != RGN_COPY_W)) {
         dprintf(("WARNING: CombineRgn %x %x %x %d invalid region", hrgnDest, hrgnSrc1, hrgnSrc2, combineMode));
@@ -1103,6 +1103,6 @@
    LONG lEquality;
 
-   hrgn1 = ObjGetHandleData(hrgn1);
-   hrgn2 = ObjGetHandleData(hrgn2);
+   hrgn1 = ObjGetHandleData(hrgn1, GDIOBJ_REGION);
+   hrgn2 = ObjGetHandleData(hrgn2, GDIOBJ_REGION);
    if(hrgn1 == HANDLE_OBJ_ERROR || hrgn2 == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: EqualRgn %x %x invalid region", hrgn1, hrgn2));
@@ -1130,5 +1130,5 @@
    BOOL    result = FALSE;
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: SetRectRgn %x (%d,%d)(%d,%d) invalid region handle", hrgn, left, top, right, bottom));
@@ -1154,5 +1154,5 @@
         return 0;
     }
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: GetRegionData %x %d %x; invalid region handle", hrgn, count, pData));
@@ -1212,5 +1212,5 @@
    LONG      lComplexity;
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: GetRgnBox %x %x invalid region!", hrgn, pRect));
@@ -1246,5 +1246,5 @@
     pDCData pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: InvertRgn %x %x invalid handle!", hdc, hrgn));
@@ -1294,5 +1294,5 @@
    LONG   lComplexity;
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: OffsetRgn %x %d %d invalid handle!", hrgn, xOffset, yOffset));
@@ -1340,5 +1340,5 @@
     pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: FrameRgn %x %x %x (%d,%d) invalid handle!", hdc, hrgn, hBrush, width, height));
@@ -1384,5 +1384,5 @@
     pDCData  pHps = (pDCData)OSLibGpiQueryDCData((HPS)hdc);
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(!pHps || hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: FillRgn %x %x %x invalid handle!", hdc, hrgn, hBrush));
@@ -1435,5 +1435,5 @@
    LONG      lInside;
 
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: PtInRgn %x (%d,%d) invalid region!", hrgn, x, y));
@@ -1470,5 +1470,5 @@
         return FALSE;
     }
-    hrgn = ObjGetHandleData(hrgn);
+    hrgn = ObjGetHandleData(hrgn, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: RectInRgn %x %x invalid region", hrgn, pRect));
@@ -1521,5 +1521,5 @@
 
     hrgnwin = CreateRectRgn(1, 1, 2, 2);
-    hrgn = ObjGetHandleData(hrgnwin);
+    hrgn = ObjGetHandleData(hrgnwin, GDIOBJ_REGION);
     if(hrgn == HANDLE_OBJ_ERROR) {
         dprintf(("WARNING: PathToRegion invalid region", hrgnwin));
