Index: trunk/src/user32/Makefile
===================================================================
--- trunk/src/user32/Makefile	(revision 5399)
+++ trunk/src/user32/Makefile	(revision 5404)
@@ -1,3 +1,3 @@
-# $Id: Makefile,v 1.80 2001-01-09 18:14:01 sandervl Exp $
+# $Id: Makefile,v 1.81 2001-03-30 11:14:35 sandervl Exp $
 
 #
@@ -18,7 +18,7 @@
 #
 !ifndef WAT
-CDEFINES = $(CDEFINES) -DINVERT
+CDEFINES = $(CDEFINES) -DINVERT -DODIN_HITTEST
 !else
-CDEFINES += -DINVERT
+CDEFINES += -DINVERT -DODIN_HITTEST
 !endif
 
Index: trunk/src/user32/oslibmsgtranslate.cpp
===================================================================
--- trunk/src/user32/oslibmsgtranslate.cpp	(revision 5399)
+++ trunk/src/user32/oslibmsgtranslate.cpp	(revision 5404)
@@ -1,3 +1,3 @@
-/* $Id: oslibmsgtranslate.cpp,v 1.42 2001-03-25 22:41:50 sandervl Exp $ */
+/* $Id: oslibmsgtranslate.cpp,v 1.43 2001-03-30 11:14:35 sandervl Exp $ */
 /*
  * Window message translation functions for OS/2
@@ -22,4 +22,5 @@
 #include <misc.h>
 #include <winconst.h>
+#include <win32api.h>
 #include "oslibmsg.h"
 #include <winuser32.h>
@@ -360,4 +361,5 @@
     //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
     //**************************************************************************
+#ifndef ODIN_HITTEST
     case WM_HITTEST:
       winMsg->message = WINWM_NCHITTEST;
@@ -371,4 +373,5 @@
       }
       break;
+#endif
 
     case WM_BUTTON1DOWN:
@@ -381,18 +384,26 @@
     case WM_BUTTON3UP:
     case WM_BUTTON3DBLCLK:
+    {
         //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
 
 #ifdef ODIN_HITTEST
-        //Send WM_HITTEST message
-        win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
+        HWND hwnd;
+
+        hwnd = WindowFromPoint(winMsg->pt);
+        if(win32wnd->getWindowHandle() != hwnd) {
+            win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
+            if(win32wnd == NULL) {
+                DebugInt3();
+                goto dummymessage;
+            }
+        }
 #endif
-        win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
 
         //if a window is disabled, it's parent receives the mouse messages
         if(!win32wnd->IsWindowEnabled()) {
-                if(win32wnd->getParent()) {
-                        win32wnd = win32wnd->getParent();
-                }
-                fWasDisabled = TRUE;
+            if(win32wnd->getParent()) {
+                win32wnd = win32wnd->getParent();
+            }
+            fWasDisabled = TRUE;
         }
 
@@ -403,9 +414,14 @@
         }
         else {
+#ifdef ODIN_HITTEST
+            ClientPoint.x = winMsg->pt.x;
+            ClientPoint.y = winMsg->pt.y;
+            MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
+#else
             point.x         = (*(POINTS *)&os2Msg->mp1).x;
             point.y         = (*(POINTS *)&os2Msg->mp1).y;
             ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
             ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
-
+#endif
             winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
             winMsg->wParam  = GetMouseKeyState();
@@ -420,10 +436,11 @@
 
         if(fWasDisabled) {
-                if(win32wnd) {
-                        winMsg->hwnd = win32wnd->getWindowHandle();
-                }
-                else    goto dummymessage; //don't send mouse messages to disabled windows
-        }
-        break;
+            if(win32wnd) {
+                winMsg->hwnd = win32wnd->getWindowHandle();
+            }
+            else goto dummymessage; //don't send mouse messages to disabled windows
+        }
+        break;
+    }
 
     case WM_BUTTON2CLICK:
@@ -447,31 +464,45 @@
 
 #ifdef ODIN_HITTEST
-        //Send WM_HITTEST message
-        win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
+        HWND hwnd;
+
+        hwnd = WindowFromPoint(winMsg->pt);
+        if(win32wnd->getWindowHandle() != hwnd) {
+            win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
+            if(win32wnd == NULL) {
+                DebugInt3();
+                goto dummymessage;
+            }
+        }
 #endif
 
         //if a window is disabled, it's parent receives the mouse messages
         if(!win32wnd->IsWindowEnabled()) {
-                if(win32wnd->getParent()) {
-                        win32wnd = win32wnd->getParent();
-                }
-                fWasDisabled = TRUE;
+            if(win32wnd->getParent()) {
+                win32wnd = win32wnd->getParent();
+            }
+            fWasDisabled = TRUE;
         }
         if(IsNCMouseMsg(win32wnd))
         {
-          winMsg->message = WINWM_NCMOUSEMOVE;
-          winMsg->wParam  = (WPARAM)win32wnd->getLastHitTestVal();
-          winMsg->lParam  = MAKELONG(winMsg->pt.x,winMsg->pt.y);
+            winMsg->message = WINWM_NCMOUSEMOVE;
+            winMsg->wParam  = (WPARAM)win32wnd->getLastHitTestVal();
+            winMsg->lParam  = MAKELONG(winMsg->pt.x,winMsg->pt.y);
         }
         else
         {
-          point.x         = (*(POINTS *)&os2Msg->mp1).x;
-          point.y         = (*(POINTS *)&os2Msg->mp1).y;
-          ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
-          ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
-
-          winMsg->message = WINWM_MOUSEMOVE;
-          winMsg->wParam  = GetMouseKeyState();
-          winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
+#ifdef ODIN_HITTEST
+            ClientPoint.x = winMsg->pt.x;
+            ClientPoint.y = winMsg->pt.y;
+            MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
+#else
+            point.x         = (*(POINTS *)&os2Msg->mp1).x;
+            point.y         = (*(POINTS *)&os2Msg->mp1).y;
+            ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
+            ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
+#endif
+
+            winMsg->message = WINWM_MOUSEMOVE;
+            winMsg->wParam  = GetMouseKeyState();
+            winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
         }
         if((fMsgRemoved == MSG_REMOVE) && ISMOUSE_CAPTURED())
Index: trunk/src/user32/pmwindow.cpp
===================================================================
--- trunk/src/user32/pmwindow.cpp	(revision 5399)
+++ trunk/src/user32/pmwindow.cpp	(revision 5404)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.120 2001-02-23 14:52:41 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.121 2001-03-30 11:14:35 sandervl Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -105,5 +105,9 @@
         (PSZ)WIN32_STDCLASS,               /* Window class name            */
         (PFNWP)Win32WindowProc,            /* Address of window procedure  */
+#ifdef ODIN_HITTEST
+        0,
+#else
         CS_HITTEST,
+#endif
         NROF_WIN32WNDBYTES))
     {
@@ -125,5 +129,9 @@
         (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
         (PFNWP)Win32FrameWindowProc,       /* Address of window procedure  */
+#ifdef ODIN_HITTEST
+        CS_FRAME,
+#else
         CS_HITTEST | CS_FRAME,
+#endif
         FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES))
     {
@@ -930,4 +938,5 @@
     //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
     //**************************************************************************
+#ifndef ODIN_HITTEST
     case WM_HITTEST:
     {
@@ -944,4 +953,5 @@
         return (MRESULT)HT_NORMAL;
     }
+#endif
 
     case WM_BUTTON1DOWN:
Index: trunk/src/user32/static.cpp
===================================================================
--- trunk/src/user32/static.cpp	(revision 5399)
+++ trunk/src/user32/static.cpp	(revision 5404)
@@ -1,3 +1,3 @@
-/* $Id: static.cpp,v 1.22 2001-03-25 08:50:42 sandervl Exp $ */
+/* $Id: static.cpp,v 1.23 2001-03-30 11:14:36 sandervl Exp $ */
 /*
  * Static control
@@ -414,4 +414,5 @@
   LRESULT lResult;
 
+#ifndef ODIN_HITTEST
   //SvL: If a static window has children, then we can't return HTTRANSPARENT
   //     here. For some reason PM then sends all mouse messages to the parent
@@ -423,4 +424,5 @@
        return HTCLIENT;
   }
+#endif
 
   if (dwStyle & SS_NOTIFY)
@@ -656,5 +658,5 @@
                              hdc, hwnd );
         if (!hBrush) hBrush = GetStockObject(WHITE_BRUSH);
-        FillRect( hdc, &rc, hBrush );    
+        FillRect( hdc, &rc, hBrush );
     }
 #else
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 5399)
+++ trunk/src/user32/win32wbase.cpp	(revision 5404)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.246 2001-03-29 17:39:19 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.247 2001-03-30 11:14:36 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -906,4 +906,5 @@
 //******************************************************************************
 //******************************************************************************
+#ifndef ODIN_HITTEST
 ULONG Win32BaseWindow::MsgHitTest(MSG *msg)
 {
@@ -917,4 +918,5 @@
     return HTOS_NORMAL;
 }
+#endif
 //******************************************************************************
 //******************************************************************************
@@ -1220,11 +1222,4 @@
 //******************************************************************************
 //******************************************************************************
-LONG Win32BaseWindow::sendHitTest(ULONG lParam)
-{
-    lastHitTestVal = SendInternalMessageA(WM_NCHITTEST, 0, lParam);
-    return lastHitTestVal;
-}
-//******************************************************************************
-//******************************************************************************
 BOOL Win32BaseWindow::isMDIClient()
 {
@@ -1967,4 +1962,7 @@
                 break;
         }
+        case WM_NCHITTEST:
+                rc = lastHitTestVal = win32wndproc(getWindowHandle(), WM_NCHITTEST, wParam, lParam);
+                break;
 
         case WM_DESTROY:
@@ -2023,4 +2021,8 @@
                 NotifyParent(Msg, wParam, lParam);
                 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
+                break;
+
+        case WM_NCHITTEST:
+                rc = lastHitTestVal = win32wndproc(getWindowHandle(), WM_NCHITTEST, wParam, lParam);
                 break;
 
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 5399)
+++ trunk/src/user32/win32wbase.h	(revision 5404)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.111 2001-02-23 14:52:42 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.112 2001-03-30 11:14:36 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -134,5 +134,7 @@
          ULONG  MsgPaint(ULONG tmp1, BOOL select = TRUE);
          ULONG  MsgEraseBackGround(HDC hdc);
+#ifndef ODIN_HITTEST
          ULONG  MsgHitTest(MSG *msg);
+#endif
          ULONG  MsgNCPaint();
          ULONG  MsgFormatFrame(WINDOWPOS *lpWndPos);
@@ -161,5 +163,4 @@
 
          LONG   getLastHitTestVal()             { return lastHitTestVal; }
-         LONG   sendHitTest(ULONG lParam);
 
          DWORD  getWindowContextHelpId()        { return contextHelpId; };
Index: trunk/src/user32/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/win32wbasenonclient.cpp	(revision 5399)
+++ trunk/src/user32/win32wbasenonclient.cpp	(revision 5404)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.29 2001-02-21 20:51:07 sandervl Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.30 2001-03-30 11:14:36 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -450,4 +450,7 @@
   if (dwStyle & WS_MINIMIZE) return HTCAPTION;
 
+  //TODO: is this correct???
+  if (dwStyle & WS_DISABLED) return HTERROR;
+
   GetWindowRect(getWindowHandle(), &rect);
 
Index: trunk/src/user32/window.cpp
===================================================================
--- trunk/src/user32/window.cpp	(revision 5399)
+++ trunk/src/user32/window.cpp	(revision 5404)
@@ -1,7 +1,7 @@
-/* $Id: window.cpp,v 1.89 2001-02-21 21:30:44 sandervl Exp $ */
+/* $Id: window.cpp,v 1.90 2001-03-30 11:14:36 sandervl Exp $ */
 /*
  * Win32 window apis for OS/2
  *
- * Copyright 1999 Sander van Leeuwen
+ * Copyright 1999-2001 Sander van Leeuwen (sandervl@xs4all.nl)
  * Copyright 1999 Daniela Engert (dani@ngrt.de)
  * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
@@ -18,5 +18,5 @@
  * TODO: ShowOwnedPopups needs to be tested
  *       GetLastActivePopup needs to be rewritten
- *       ArrangeIconicWindows probably also
+ *       ArrangeIconicWindows probably too
  *
  */
@@ -700,5 +700,5 @@
     dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
 
-    //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing; 
+    //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
     //must delay this function call
     if(teb->o.odin.fWM_SETFOCUS) {
@@ -724,5 +724,5 @@
         return 0;
     }
-    //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing; 
+    //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
     //If focus was changed during WM_SETFOCUS, the focus window handle is
     //stored in teb->o.odin.hwndFocus (set back to 0 when delayed SetFocus
@@ -1493,74 +1493,7 @@
 HWND WIN32API WindowFromPoint( POINT point)
 {
-#if 0
-    INT     hittest = HTERROR;
-    HWND    retvalue = 0;
-    HWND    hwnd = GetDesktopWindow();
-    DWORD   dwStyle;
-    RECT    rectWindow, rectClient;
-    Win32BaseWindow *window;
-
-    dprintf(("WindowFromPoint (%d,%d)", point.x, point.y));
-
-    while(hwnd)
-    {
-        window = Win32BaseWindow::GetWindowFromHandle(hwnd);
-
-        /* If point is in window, and window is visible, and it  */
-        /* is enabled (or it's a top-level window), then explore */
-        /* its children. Otherwise, go to the next window.       */
-        dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
-
-        if ((dwStyle & WS_VISIBLE) && (!(dwStyle & WS_DISABLED) ||
-           ((dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD)))
-        {
-            GetWindowRect(hwnd, &rectWindow);
-            if(PtInRect(&rectWindow, point) == TRUE)
-            {
-                /* If window is minimized or disabled, return at once */
-                if(dwStyle & WS_MINIMIZE)
-                {
-                    break;
-                }
-                if(dwStyle & WS_DISABLED)
-                {
-                    break;
-                }
-                retvalue = hwnd;
-
-                GetClientRect(hwnd, &rectClient);
-                InflateRect(&rectClient, rectWindow.left, rectWindow.top);
-
-                /* If point is not in client area, ignore the children */
-                if(PtInRect(&rectClient, point) == FALSE) {
-                    break;
-                }
-                if(window->getFirstChild()) {
-                     hwnd = ((Win32BaseWindow *)window->getFirstChild())->getWindowHandle();
-                }
-                else break;
-            }
-            else
-            {
-                if(window->getNextChild()) {
-                     hwnd = ((Win32BaseWindow *)window->getNextChild())->getWindowHandle();
-                }
-                else hwnd = 0;
-            }
-        }
-        else
-        {
-            if(window->getNextChild()) {
-                 hwnd = ((Win32BaseWindow *)window->getNextChild())->getWindowHandle();
-            }
-            else hwnd = 0;
-        }
-    }
-
-    dprintf(("WindowFromPoint (%d,%d) -> %x", point.x, point.y, hwnd));
-    return retvalue;
-#else
     HWND  hwndOS2, hwnd;
     POINT wPoint;
+    DWORD hittest, dwStyle, dwExStyle;
 
     wPoint.x = point.x;
@@ -1570,13 +1503,36 @@
     if(hwndOS2)
     {
-      hwnd = OS2ToWin32Handle(hwndOS2);
-      if(hwnd) {
-              dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
-              return hwnd;
-      }
+        hwnd = OS2ToWin32Handle(hwndOS2);
+        while(hwnd)
+        {
+                dwStyle   = GetWindowLongA(hwnd, GWL_STYLE);
+                dwExStyle = GetWindowLongA(hwnd, GWL_EXSTYLE);
+
+                /* If point is in window, and window is visible, and it  */
+                /* is enabled (or it's a top-level window), then explore */
+                /* its children. Otherwise, go to the next window.       */
+
+                if( (dwStyle & WS_VISIBLE) &&
+                    ((dwExStyle & (WS_EX_LAYERED | WS_EX_TRANSPARENT)) != (WS_EX_LAYERED | WS_EX_TRANSPARENT)) &&
+                    (!(dwStyle & WS_DISABLED) || ((dwStyle & (WS_POPUP | WS_CHILD)) != WS_CHILD))
+#if 1
+                    )
+#else
+                    &&
+                    (wndPtr->hrgnWnd ?  PtInRegion(wndPtr->hrgnWnd, 1))
+#endif
+                {
+                    hittest = SendMessageA(hwnd, WM_NCHITTEST, 0, MAKELONG(point.x, point.y));
+                    if(hittest != HTTRANSPARENT) {
+                        dprintf(("WindowFromPoint (%d,%d) %x->%x\n", point.x, point.y, hwndOS2, hwnd));
+                        return hwnd;
+                    }
+                }
+                //TODO: Not correct for overlapping sibling windows!
+                hwnd = GetParent(hwnd);
+        }
     }
     dprintf(("WindowFromPoint (%d,%d) %x->1\n", point.x, point.y, hwndOS2));
     return windowDesktop->getWindowHandle();
-#endif
 }
 //******************************************************************************
