Index: trunk/src/user32/pmwindow.cpp
===================================================================
--- trunk/src/user32/pmwindow.cpp	(revision 5215)
+++ trunk/src/user32/pmwindow.cpp	(revision 5217)
@@ -1,3 +1,3 @@
-/* $Id: pmwindow.cpp,v 1.117 2001-02-19 10:15:52 sandervl Exp $ */
+/* $Id: pmwindow.cpp,v 1.118 2001-02-20 17:22:05 sandervl Exp $ */
 /*
  * Win32 Window Managment Code for OS/2
@@ -286,9 +286,4 @@
         dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
 
-        if(win32wnd->getParent() && win32wnd->getParent()->isOwnDC()) {
-            dprintfOrigin(win32wnd->getParent()->getOwnDC());
-            selectClientArea(win32wnd->getParent(), win32wnd->getParent()->getOwnDC());
-        }
-
         if(pswp->fl & SWP_NOADJUST) {
             //ignore weird messages (TODO: why are they sent?)
@@ -387,5 +382,5 @@
       WINDOWPOS wp;
       HWND      hParent = NULLHANDLE;
-      RECTL rect;
+      RECTL     rect;
 
         dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
@@ -396,7 +391,16 @@
             {
                 //Only send PM WM_ACTIVATE to top-level windows (frame windows)
-                if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
+                if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
                 {
                         WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
+                }
+            }
+            else
+            if(pswp->fl & SWP_DEACTIVATE)
+            {
+                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
+                if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
+                {
+                        WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
                 }
             }
@@ -417,111 +421,116 @@
 
         if(win32wnd->getParent()) {
-          OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
-                                     win32wnd->getParent()->getClientRectPtr()->left,
-                                     win32wnd->getParent()->getClientRectPtr()->top,
-                                     hwnd);
-        }
-        else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
+             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
+                                    win32wnd->getParent()->getClientRectPtr()->left,
+                                    win32wnd->getParent()->getClientRectPtr()->top,
+                                    hwnd);
+        }
+        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
 
         wp.hwnd = win32wnd->getWindowHandle();
         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
         {
-           Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
-           if(wndAfter) {
-                wp.hwndInsertAfter = wndAfter->getWindowHandle();
-           }
-           else wp.hwndInsertAfter = HWND_TOP_W;
+            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
+            if(wndAfter) {
+                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
+            }
+            else wp.hwndInsertAfter = HWND_TOP_W;
         }
 
         if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
         {
-          //CB: todo: use result for WM_CALCVALIDRECTS
-          //Get old client rectangle (for invalidation of frame window parts later on)
-          //Use new window height to calculate the client area
-          mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
-
-          //Note: Also updates the new window rectangle
-          win32wnd->MsgFormatFrame(&wp);
-
-          if(win32wnd->CanReceiveSizeMsgs())
-            win32wnd->MsgPosChanged((LPARAM)&wp);
-
-          if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
-          {
-            //redraw the frame (to prevent unnecessary client updates)
-            BOOL redrawAll = FALSE;
-
-            if (win32wnd->getWindowClass())
+            //CB: todo: use result for WM_CALCVALIDRECTS
+            //Get old client rectangle (for invalidation of frame window parts later on)
+            //Use new window height to calculate the client area
+            mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
+
+            //Note: Also updates the new window rectangle
+            win32wnd->MsgFormatFrame(&wp);
+
+            if(win32wnd->CanReceiveSizeMsgs())
+                win32wnd->MsgPosChanged((LPARAM)&wp);
+
+            if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
             {
-              DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
-
-              if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
-                redrawAll = TRUE;
-              else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
-                redrawAll = TRUE;
-            } else redrawAll = TRUE;
-
-            if (redrawAll)
-            {
-              //CB: redraw all children for now
-              //    -> problems with update region if we don't do it
-              //       todo: rewrite whole handling
-              WinInvalidateRect(hwnd,NULL,TRUE);
-            }
-            else
-            {
-              HPS hps = WinGetPS(hwnd);
-              RECTL frame,client,arcl[4];
-
-              WinQueryWindowRect(hwnd,&frame);
-
-               //top
-              arcl[0].xLeft = 0;
-              arcl[0].xRight = frame.xRight;
-              arcl[0].yBottom = rect.yTop;
-              arcl[0].yTop = frame.yTop;
-               //right
-              arcl[1].xLeft = rect.xRight;
-              arcl[1].xRight = frame.xRight;
-              arcl[1].yBottom = 0;
-              arcl[1].yTop = frame.yTop;
-               //left
-              arcl[2].xLeft = 0;
-              arcl[2].xRight = rect.xLeft;
-              arcl[2].yBottom = 0;
-              arcl[2].yTop = frame.yTop;
-               //bottom
-              arcl[3].xLeft = 0;
-              arcl[3].xRight = frame.xRight;
-              arcl[3].yBottom = 0;
-              arcl[3].yTop = rect.yBottom;
-
-              HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
-
-              WinInvalidateRegion(hwnd,hrgn,FALSE);
-              GpiDestroyRegion(hps,hrgn);
-              WinReleasePS(hps);
-            }
-          }
-        }
-        else
-        {
-          if(win32wnd->CanReceiveSizeMsgs())
-            win32wnd->MsgPosChanged((LPARAM)&wp);
-        }
-
-        if(pswp->fl & SWP_ACTIVATE)
-        {
-             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
-             if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
-             {
-                if(isFrame) {
-                     WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
+                //redraw the frame (to prevent unnecessary client updates)
+                BOOL redrawAll = FALSE;
+
+                if (win32wnd->getWindowClass())
+                {
+                    DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
+
+                    if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
+                        redrawAll = TRUE;
+                    else
+                    if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
+                        redrawAll = TRUE;
+                }
+                else redrawAll = TRUE;
+
+                if (redrawAll)
+                {
+                    //CB: redraw all children for now
+                    //    -> problems with update region if we don't do it
+                    //       todo: rewrite whole handling
+                    WinInvalidateRect(hwnd,NULL,TRUE);
                 }
                 else
-                if(win32wnd->IsWindowCreated()) {
-                    win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
+                {
+                    HPS hps = WinGetPS(hwnd);
+                    RECTL frame,client,arcl[4];
+
+                    WinQueryWindowRect(hwnd,&frame);
+
+                    //top
+                    arcl[0].xLeft = 0;
+                    arcl[0].xRight = frame.xRight;
+                    arcl[0].yBottom = rect.yTop;
+                    arcl[0].yTop = frame.yTop;
+                    //right
+                    arcl[1].xLeft = rect.xRight;
+                    arcl[1].xRight = frame.xRight;
+                    arcl[1].yBottom = 0;
+                    arcl[1].yTop = frame.yTop;
+                    //left
+                    arcl[2].xLeft = 0;
+                    arcl[2].xRight = rect.xLeft;
+                    arcl[2].yBottom = 0;
+                    arcl[2].yTop = frame.yTop;
+                    //bottom
+                    arcl[3].xLeft = 0;
+                    arcl[3].xRight = frame.xRight;
+                    arcl[3].yBottom = 0;
+                    arcl[3].yTop = rect.yBottom;
+
+                    HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
+
+                    WinInvalidateRegion(hwnd,hrgn,FALSE);
+                    GpiDestroyRegion(hps,hrgn);
+                    WinReleasePS(hps);
                 }
+            }
+        }
+        else
+        {
+            if(win32wnd->CanReceiveSizeMsgs())
+                win32wnd->MsgPosChanged((LPARAM)&wp);
+        }
+
+        if(pswp->fl & SWP_ACTIVATE)
+        {
+             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
+             if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
+             {
+                WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
              }
+        }
+        else
+        if(pswp->fl & SWP_DEACTIVATE)
+        {
+            //Only send PM WM_ACTIVATE to top-level windows (frame windows)
+            if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
+            {
+                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
+            }
         }
 
@@ -532,9 +541,9 @@
     case WM_ACTIVATE:
     {
-        USHORT flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
+        ULONG flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
 
         dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
 
-        WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
+        WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
         if(win32wnd->IsWindowCreated())
         {
@@ -604,10 +613,10 @@
                 break;
         }
-//test
+        //Restore window origin of window with CS_OWNDC style
+        //(fixes paint offset problems in Opera windows)
         if(win32wnd->isOwnDC()) {
                 dprintfOrigin(win32wnd->getOwnDC());
                 selectClientArea(win32wnd, win32wnd->getOwnDC());
         }
-//test
         goto RunDefWndProc;
 
Index: trunk/src/user32/win32wbase.cpp
===================================================================
--- trunk/src/user32/win32wbase.cpp	(revision 5215)
+++ trunk/src/user32/win32wbase.cpp	(revision 5217)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.cpp,v 1.238 2001-02-20 15:40:22 sandervl Exp $ */
+/* $Id: win32wbase.cpp,v 1.239 2001-02-20 17:22:05 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -925,8 +925,10 @@
         return 0;
     }
-    /* child windows get WM_CHILDACTIVATE message */
+    /* child windows get a WM_CHILDACTIVATE message */
     if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
     {
-        SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
+        if(fActivate) {//WM_CHILDACTIVE is for activation only
+            SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
+        }
         return 0;
     }
@@ -2429,10 +2431,10 @@
     }
 
-//testestest
+    //Restore window origin of parent window with CS_OWNDC style
+    //(fixes paint offset problems in Opera windows)
     if(getParent() && getParent()->isOwnDC()) {
         dprintfOrigin(getParent()->getOwnDC());
         selectClientArea(getParent(), getParent()->getOwnDC());
     }
-//testestest
 
     if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
@@ -3114,4 +3116,19 @@
     hwndActive = GetActiveWindow();
     return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
+}
+//******************************************************************************
+//Used to change active status of an mdi window
+//******************************************************************************
+BOOL Win32BaseWindow::DeactivateChildWindow()
+{
+    /* child windows get a WM_CHILDACTIVATE message */
+    if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
+    {
+        ULONG flags = OSLibWinGetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS);
+        OSLibWinSetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS, (flags & ~WINDOWFLAG_ACTIVE));
+        return TRUE;
+    }
+    DebugInt3();    //should not be called for non-child window
+    return FALSE;
 }
 //******************************************************************************
Index: trunk/src/user32/win32wbase.h
===================================================================
--- trunk/src/user32/win32wbase.h	(revision 5215)
+++ trunk/src/user32/win32wbase.h	(revision 5217)
@@ -1,3 +1,3 @@
-/* $Id: win32wbase.h,v 1.107 2001-02-20 15:40:23 sandervl Exp $ */
+/* $Id: win32wbase.h,v 1.108 2001-02-20 17:22:05 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2
@@ -29,4 +29,6 @@
 #define OFFSET_WIN32FLAGS         8
 #define NROF_WIN32WNDBYTES        12
+
+#define WINDOWFLAG_ACTIVE	  1
 
 #define WIN32PM_MAGIC           0x12345678
@@ -225,4 +227,5 @@
          BOOL   DestroyWindow();
          HWND   SetActiveWindow();
+         BOOL   DeactivateChildWindow();
          HWND   GetParent();
          HWND   SetParent(HWND hwndNewParent);
Index: trunk/src/user32/win32wbasenonclient.cpp
===================================================================
--- trunk/src/user32/win32wbasenonclient.cpp	(revision 5215)
+++ trunk/src/user32/win32wbasenonclient.cpp	(revision 5217)
@@ -1,3 +1,3 @@
-/* $Id: win32wbasenonclient.cpp,v 1.27 2001-02-20 15:40:23 sandervl Exp $ */
+/* $Id: win32wbasenonclient.cpp,v 1.28 2001-02-20 17:22:06 sandervl Exp $ */
 /*
  * Win32 Window Base Class for OS/2 (non-client methods)
@@ -335,11 +335,11 @@
 VOID Win32BaseWindow::AdjustMaximizedRect(LPRECT rect)
 {
-  if (HAS_THICKFRAME(dwStyle,dwExStyle ))
-    InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
-  else
+    if (HAS_THICKFRAME(dwStyle,dwExStyle ))
+        InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
+    else
     if (HAS_DLGFRAME( dwStyle, dwExStyle ))
-      InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
+        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
     else
-      if (HAS_THINFRAME( dwStyle ))
+    if (HAS_THINFRAME( dwStyle ))
         InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
 }
@@ -348,6 +348,6 @@
 VOID Win32BaseWindow::AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize)
 {
-  if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
-    GetMinMaxInfo(NULL,NULL,minTrackSize,maxTrackSize);
+    if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
+        GetMinMaxInfo(NULL,NULL,minTrackSize,maxTrackSize);
 }
 //******************************************************************************
@@ -355,25 +355,25 @@
 VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
 {
-  if(dwStyle & WS_ICONIC) return;
-
-  if (HAS_THICKFRAME(dwStyle,dwExStyle ))
-    InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
-  else
+    if(dwStyle & WS_ICONIC) return;
+
+    if (HAS_THICKFRAME(dwStyle,dwExStyle ))
+        InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
+    else
     if (HAS_DLGFRAME( dwStyle, dwExStyle ))
-      InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
+        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
     else
-      if (HAS_THINFRAME( dwStyle ))
+    if (HAS_THINFRAME( dwStyle ))
         InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
 
-  if ((dwStyle & WS_CAPTION) == WS_CAPTION)
-  {
-    if (dwExStyle & WS_EX_TOOLWINDOW)
-      rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
-    else
-      rect->top -= GetSystemMetrics(SM_CYCAPTION);
-  }
-
-  if (menu)
-    rect->top -= GetSystemMetrics(SM_CYMENU);
+    if ((dwStyle & WS_CAPTION) == WS_CAPTION)
+    {
+        if (dwExStyle & WS_EX_TOOLWINDOW)
+            rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
+        else
+            rect->top -= GetSystemMetrics(SM_CYCAPTION);
+    }
+
+    if (menu)
+        rect->top -= GetSystemMetrics(SM_CYMENU);
 }
 //******************************************************************************
@@ -685,6 +685,6 @@
             GetInsideRect(rect );
             OffsetRect( rect, rectWindow.left, rectWindow.top);
-  	        if(getStyle() & WS_CHILD)
-     	        ClientToScreen(getParent()->getWindowHandle(), (POINT *)rect);
+            if(getStyle() & WS_CHILD)
+                ClientToScreen(getParent()->getWindowHandle(), (POINT *)rect);
 
             rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
Index: trunk/src/user32/win32wmdiclient.cpp
===================================================================
--- trunk/src/user32/win32wmdiclient.cpp	(revision 5215)
+++ trunk/src/user32/win32wmdiclient.cpp	(revision 5217)
@@ -1,3 +1,3 @@
-/* $Id: win32wmdiclient.cpp,v 1.32 2000-12-24 14:54:07 sandervl Exp $ */
+/* $Id: win32wmdiclient.cpp,v 1.33 2001-02-20 17:22:06 sandervl Exp $ */
 /*
  * Win32 MDI Client Window Class for OS/2
@@ -346,4 +346,5 @@
     {
         prevActive->setStyle(prevActive->getStyle() | WS_SYSMENU);
+        prevActive->DeactivateChildWindow();
         prevActive->SendInternalMessageA( WM_NCACTIVATE, FALSE, 0L );
         prevActive->SendInternalMessageA( WM_MDIACTIVATE, (WPARAM)prevActive->getWindowHandle(), (LPARAM)(child) ? child->getWindowHandle() : 0);
