Ignore:
Timestamp:
May 11, 2001, 10:39:46 AM (24 years ago)
Author:
sandervl
Message:

client/frame rewrite

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/pmwindow.cpp

    r5655 r5685  
    1 /* $Id: pmwindow.cpp,v 1.124 2001-05-04 17:02:51 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.125 2001-05-11 08:39:44 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    3434#include "oslibgdi.h"
    3535#include "oslibmsg.h"
     36#define INCLUDED_BY_DC
    3637#include "dc.h"
    3738#include <thread.h>
     
    5960MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    6061MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    61 MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd,
    62                          MSG *pWinMsg, TEB *teb, BOOL isFrame);
    6362
    6463//******************************************************************************
     
    105104        (PSZ)WIN32_STDCLASS,               /* Window class name            */
    106105        (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    107 #ifdef ODIN_HITTEST
    108106        0,
    109 #else
    110         CS_HITTEST,
    111 #endif
    112107        NROF_WIN32WNDBYTES))
    113108    {
     
    129124        (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
    130125        (PFNWP)Win32FrameWindowProc,       /* Address of window procedure  */
    131 #ifdef ODIN_HITTEST
    132126        CS_FRAME,
    133 #else
    134         CS_HITTEST | CS_FRAME,
    135 #endif
    136127        FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES))
    137128    {
     
    166157 MSG              winMsg, *pWinMsg;
    167158 MRESULT          rc = 0;
     159 POSTMSG_PACKET  *postmsg;
     160 OSLIBPOINT       point, ClientPoint;
    168161
    169162    //Restore our FS selector
     
    175168
    176169    if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
    177         dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     170        dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
    178171        goto RunDefWndProc;
    179172    }
     
    205198    }
    206199    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
    207     rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, FALSE);
    208     RestoreOS2TIB();
    209     return rc;
    210 
    211 RunDefWndProc:
    212     RestoreOS2TIB();
    213     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    214 }
    215 //******************************************************************************
    216 //******************************************************************************
    217 MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd, MSG *pWinMsg, TEB *teb, BOOL isFrame)
    218 {
    219  POSTMSG_PACKET  *postmsg;
    220  OSLIBPOINT       point, ClientPoint;
    221  MRESULT          rc = 0;
    222 
    223   if(msg == WIN32APP_POSTMSG) {
     200
     201    if(msg == WIN32APP_POSTMSG) {
    224202        //probably win32 app user message
    225203        if((ULONG)mp1 == WIN32MSG_MAGICA) {
     
    230208            return (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
    231209        }
    232   }
    233   else
    234   if(msg == WIN32APP_SETFOCUSMSG) {
     210    }
     211    else
     212    if(msg == WIN32APP_SETFOCUSMSG) {
    235213      //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
    236214      //must delay this function call
     
    240218      teb->o.odin.hwndFocus = 0;
    241219      WinFocusChange(HWND_DESKTOP, hwnd, mp2 ? FC_NOLOSEACTIVE : 0);
    242   }
    243 
    244   switch( msg )
    245   {
     220    }
     221
     222    switch( msg )
     223    {
    246224    //OS/2 msgs
    247225    case WM_CREATE:
     
    280258    case WM_ENABLE:
    281259        dprintf(("OS2: WM_ENABLE %x", hwnd));
    282         win32wnd->MsgEnable(SHORT1FROMMP(mp1));
    283260        break;
    284261
    285262    case WM_SHOW:
    286263        dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
    287         win32wnd->MsgShow((ULONG)mp1);
    288         break;
    289 
    290     case WM_ADJUSTWINDOWPOS:
    291     {
    292       PSWP     pswp = (PSWP)mp1;
    293       SWP      swpOld;
    294       WINDOWPOS wp,wpOld;
    295       HWND      hParent = NULLHANDLE, hwndAfter;
    296 
    297         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));
    298 
    299         if(pswp->fl & SWP_NOADJUST) {
    300             //ignore weird messages (TODO: why are they sent?)
    301             break;
    302         }
    303         //CB: show dialog in front of owner
    304         if (win32wnd->IsModalDialogOwner())
    305         {
    306             dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
    307             pswp->fl |= SWP_ZORDER;
    308             pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
    309             if (pswp->fl & SWP_ACTIVATE)
    310             {
    311                 pswp->fl &= ~SWP_ACTIVATE;
    312                 WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
    313             }
    314         }
    315 
    316         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    317             goto RunDefWndProc;
    318 
    319         if(!win32wnd->CanReceiveSizeMsgs())
    320             break;
    321 
    322         WinQueryWindowPos(hwnd, &swpOld);
    323         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    324             if (win32wnd->isChild()) {
    325                 if(win32wnd->getParent()) {
    326                         hParent = win32wnd->getParent()->getOS2WindowHandle();
    327                 }
    328                 else    goto RunDefWndProc;
    329             }
    330         }
    331         hwndAfter = pswp->hwndInsertBehind;
    332         if(win32wnd->getParent()) {
    333             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    334                                    win32wnd->getParent()->getClientRectPtr()->left,
    335                                    win32wnd->getParent()->getClientRectPtr()->top,
    336                                    hwnd);
    337         }
    338         else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    339 
    340         wp.hwnd = win32wnd->getWindowHandle();
    341         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    342         {
    343            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    344            if(wndAfter) {
    345                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
    346            }
    347            else wp.hwndInsertAfter = HWND_TOP_W;
    348         }
    349 
    350         wpOld = wp;
    351         win32wnd->MsgPosChanging((LPARAM)&wp);
    352 
    353         if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
    354             (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
    355         {
    356             ULONG flags = pswp->fl;      //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
    357 
    358             dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
    359             dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    360 
    361             if(win32wnd->getParent()) {
    362                   OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    363                                          win32wnd->getParent()->getClientRectPtr()->left,
    364                                          win32wnd->getParent()->getClientRectPtr()->top,
    365                                          hwnd);
    366             }
    367             else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    368 
    369             dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    370 
    371             //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
    372             if(pswp->fl & SWP_SIZE)
    373                 flags |= SWP_SIZE;
    374 
    375             if(pswp->fl & SWP_MOVE)
    376                 flags |= SWP_MOVE;
    377 
    378             pswp->fl = flags;   //restore flags
    379 
    380             pswp->fl |= SWP_NOADJUST;
    381             pswp->hwndInsertBehind = hwndAfter;
    382             pswp->hwnd = hwnd;
    383 
    384             return (MRESULT)0xf;
    385         }
    386         return (MRESULT)0;
    387     }
    388 
    389     case WM_WINDOWPOSCHANGED:
    390     {
    391       PSWP      pswp   = (PSWP)mp1,pswpOld = pswp+1;
    392       SWP       swpOld = *(pswp + 1);
    393       WINDOWPOS wp;
    394       HWND      hParent = NULLHANDLE;
    395       RECTL     rect;
    396 
    397         dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    398 
    399         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    400         {
    401             if(pswp->fl & SWP_ACTIVATE)
    402             {
    403                 //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    404                 if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
    405                 {
    406                         WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    407                 }
    408             }
    409             else
    410             if(pswp->fl & SWP_DEACTIVATE)
    411             {
    412                 //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    413                 if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
    414                 {
    415                         WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
    416                 }
    417             }
    418             goto RunDefWndProc;
    419         }
    420 
    421         if(pswp->fl & (SWP_MOVE | SWP_SIZE))
    422         {
    423             if(win32wnd->isChild())
    424             {
    425                 if(win32wnd->getParent()) {
    426                         hParent = win32wnd->getParent()->getOS2WindowHandle();
    427                 }
    428                 else    goto PosChangedEnd; //parent has just been destroyed
    429             }
    430         }
    431 
    432 
    433         if(win32wnd->getParent()) {
    434              OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    435                                     win32wnd->getParent()->getClientRectPtr()->left,
    436                                     win32wnd->getParent()->getClientRectPtr()->top,
    437                                     hwnd);
    438         }
    439         else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    440 
    441         wp.hwnd = win32wnd->getWindowHandle();
    442         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    443         {
    444             Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    445             if(wndAfter) {
    446                  wp.hwndInsertAfter = wndAfter->getWindowHandle();
    447             }
    448             else wp.hwndInsertAfter = HWND_TOP_W;
    449         }
    450 
    451 #ifndef USE_CALCVALIDRECT
    452         if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
    453         {
    454             //CB: todo: use result for WM_CALCVALIDRECTS
    455             //Get old client rectangle (for invalidation of frame window parts later on)
    456             //Use new window height to calculate the client area
    457             mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
    458 
    459             //Note: Also updates the new window rectangle
    460             win32wnd->MsgFormatFrame(&wp);
    461 
    462             if(win32wnd->isOwnDC()) {
    463                 dprintf(("Mark owndc of %x as dirty", win32wnd->getWindowHandle()));
    464                 win32wnd->invalidateOwnDC(); //mark DC as dirty. origin & visible region must be reinitialized
    465             }
    466             if(win32wnd->CanReceiveSizeMsgs())
    467                 win32wnd->MsgPosChanged((LPARAM)&wp);
    468 
    469             if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
    470             {
    471                 //redraw the frame (to prevent unnecessary client updates)
    472                 BOOL redrawAll = FALSE;
    473 
    474                 if (win32wnd->getWindowClass())
    475                 {
    476                     DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    477 
    478                     if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
    479                         redrawAll = TRUE;
    480                     else
    481                     if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
    482                         redrawAll = TRUE;
    483                 }
    484                 else redrawAll = TRUE;
    485 
    486                 if(win32wnd->IsMixMaxStateChanging()) {
    487                     dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
    488                     redrawAll = TRUE;
    489                 }
    490 
    491                 if (redrawAll)
    492                 {
    493                     //CB: redraw all children for now
    494                     //    -> problems with update region if we don't do it
    495                     //       todo: rewrite whole handling
    496                     WinInvalidateRect(hwnd,NULL,TRUE);
    497                 }
    498                 else
    499                 {
    500                     HPS hps = WinGetPS(hwnd);
    501                     RECTL frame,client,arcl[4];
    502 
    503                     WinQueryWindowRect(hwnd,&frame);
    504 
    505                     //top
    506                     arcl[0].xLeft = 0;
    507                     arcl[0].xRight = frame.xRight;
    508                     arcl[0].yBottom = rect.yTop;
    509                     arcl[0].yTop = frame.yTop;
    510                     //right
    511                     arcl[1].xLeft = rect.xRight;
    512                     arcl[1].xRight = frame.xRight;
    513                     arcl[1].yBottom = 0;
    514                     arcl[1].yTop = frame.yTop;
    515                     //left
    516                     arcl[2].xLeft = 0;
    517                     arcl[2].xRight = rect.xLeft;
    518                     arcl[2].yBottom = 0;
    519                     arcl[2].yTop = frame.yTop;
    520                     //bottom
    521                     arcl[3].xLeft = 0;
    522                     arcl[3].xRight = frame.xRight;
    523                     arcl[3].yBottom = 0;
    524                     arcl[3].yTop = rect.yBottom;
    525 
    526                     HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
    527 
    528                     WinInvalidateRegion(hwnd,hrgn,FALSE);
    529                     GpiDestroyRegion(hps,hrgn);
    530                     WinReleasePS(hps);
    531                 }
    532             }
    533         }
    534         else
    535         {
    536 #endif //USE_CALCVALIDRECT
    537             if(win32wnd->CanReceiveSizeMsgs())
    538                 win32wnd->MsgPosChanged((LPARAM)&wp);
    539 #ifndef USE_CALCVALIDRECT
    540         }
    541 #endif
    542 
    543         if(pswp->fl & SWP_ACTIVATE)
    544         {
    545              //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    546              if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
    547              {
    548                 WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    549              }
    550         }
    551         else
    552         if(pswp->fl & SWP_DEACTIVATE)
    553         {
    554             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    555             if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
    556             {
    557                     WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
    558             }
    559         }
    560 
    561 PosChangedEnd:
    562         return (MRESULT)FALSE;
    563     }
     264        break;
    564265
    565266    case WM_ACTIVATE:
     
    568269
    569270        dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
    570 
    571271        WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
    572272        if(win32wnd->IsWindowCreated())
    573273        {
    574274            win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
    575 
    576             //CB: show owner behind the dialog
    577             if(win32wnd->IsModalDialog())
    578             {
    579                 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
    580 
    581                 if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
    582             }
    583         }
    584         return 0;
     275        }
     276        break;
    585277    }
    586278
    587279    case WM_SIZE:
    588280    {
    589         dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
     281        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
     282        win32wnd->SetVisibleRegionChanged(TRUE);
    590283        goto RunDefWndProc;
    591284    }
    592285
    593     case WM_CALCVALIDRECTS:
    594 #ifdef USE_CALCVALIDRECT
    595     {
    596         PRECTL    oldRect = (PRECTL)mp1, newRect = oldRect+1;
    597         PSWP      pswp = (PSWP)mp2;
    598         SWP       swpOld;
    599         WINDOWPOS wp;
    600         RECTL     newClientRect, oldClientRect;
    601         ULONG     nccalcret;
    602 //        UINT      res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
    603         UINT      res = 0;
    604 
    605         dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    606 
    607         //Get old position info
    608         WinQueryWindowPos(hwnd, &swpOld);
    609 
    610         if(win32wnd->getParent()) {
    611              OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    612                                     win32wnd->getParent()->getClientRectPtr()->left,
    613                                     win32wnd->getParent()->getClientRectPtr()->top,
    614                                     hwnd);
    615         }
    616         else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    617 
    618         wp.hwnd = win32wnd->getWindowHandle();
    619         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    620         {
    621             Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    622             if(wndAfter) {
    623                  wp.hwndInsertAfter = wndAfter->getWindowHandle();
    624             }
    625             else wp.hwndInsertAfter = HWND_TOP_W;
    626         }
    627 
    628         //Get old client rectangle
    629         mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
    630 
    631         //Note: Also updates the new window rectangle
    632         nccalcret = win32wnd->MsgFormatFrame(&wp);
    633 
    634         //Get new client rectangle
    635         mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
    636 
    637         if(nccalcret == 0) {
    638             res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
    639         }
    640         else {
    641             if(nccalcret & WVR_ALIGNTOP_W) {
    642                 res |= CVR_ALIGNTOP;
    643             }
    644             else
    645             if(nccalcret & WVR_ALIGNBOTTOM_W) {
    646                 res |= CVR_ALIGNBOTTOM;
    647             }
    648 
    649             if(nccalcret & WVR_ALIGNLEFT_W) {
    650                 res |= CVR_ALIGNLEFT;
    651             }
    652             else
    653             if(nccalcret & WVR_ALIGNRIGHT_W) {
    654                 res |= CVR_ALIGNRIGHT;
    655             }
    656 
    657             if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
    658                 res |= CVR_REDRAW;
    659             }
    660             else
    661             if(nccalcret & WVR_VALIDRECTS_W) {
    662                 //TODO:
    663                 //res = 0;
    664             }
    665         }
    666         if(win32wnd->IsMixMaxStateChanging()) {
    667             dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
    668             res |= CVR_REDRAW;
    669         }
    670         if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
    671             oldRect->xRight  -= oldClientRect.xLeft;
    672             oldRect->yBottom += oldClientRect.yBottom;
    673             newRect->xRight  -= newClientRect.xLeft;
    674             newRect->yBottom += newClientRect.yBottom;
    675         }
    676 
    677 #if 0
    678             if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
    679             {
    680                 //redraw the frame (to prevent unnecessary client updates)
    681                 BOOL redrawAll = FALSE;
    682 
    683                 if (win32wnd->getWindowClass())
    684                 {
    685                     DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    686 
    687                     if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
    688                         redrawAll = TRUE;
    689                     else
    690                     if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
    691                         redrawAll = TRUE;
    692                 }
    693                 else redrawAll = TRUE;
    694 
    695                 if (redrawAll)
    696                 {
    697                     //CB: redraw all children for now
    698                     //    -> problems with update region if we don't do it
    699                     //       todo: rewrite whole handling
    700                     WinInvalidateRect(hwnd,NULL,TRUE);
    701                 }
    702                 else
    703                 {
    704                     HPS hps = WinGetPS(hwnd);
    705                     RECTL frame,client,arcl[4];
    706 
    707                     WinQueryWindowRect(hwnd,&frame);
    708 
    709                     //top
    710                     arcl[0].xLeft = 0;
    711                     arcl[0].xRight = frame.xRight;
    712                     arcl[0].yBottom = rect.yTop;
    713                     arcl[0].yTop = frame.yTop;
    714                     //right
    715                     arcl[1].xLeft = rect.xRight;
    716                     arcl[1].xRight = frame.xRight;
    717                     arcl[1].yBottom = 0;
    718                     arcl[1].yTop = frame.yTop;
    719                     //left
    720                     arcl[2].xLeft = 0;
    721                     arcl[2].xRight = rect.xLeft;
    722                     arcl[2].yBottom = 0;
    723                     arcl[2].yTop = frame.yTop;
    724                     //bottom
    725                     arcl[3].xLeft = 0;
    726                     arcl[3].xRight = frame.xRight;
    727                     arcl[3].yBottom = 0;
    728                     arcl[3].yTop = rect.yBottom;
    729 
    730                     HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
    731 
    732                     WinInvalidateRegion(hwnd,hrgn,FALSE);
    733                     GpiDestroyRegion(hps,hrgn);
    734                     WinReleasePS(hps);
    735                 }
    736             }
    737 
    738         }
    739 #endif
    740 
    741         return (MRESULT)res;
    742     }
    743 #else
    744       dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    745       return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
    746 #endif
    747286
    748287    case WM_VRNENABLED:
     
    750289        if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
    751290        {
    752                 HWND hwndrelated;
    753                 Win32BaseWindow *topwindow;
    754 
    755                 win32wnd->setComingToTop(TRUE);
    756 
    757                 hwndrelated = WinQueryWindow(hwnd, QW_PREV);
    758                 dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
    759                 topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
    760                 if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
    761                         //put window at the top of z order
    762                         WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
    763                 }
    764 
    765                 win32wnd->setComingToTop(FALSE);
    766                 break;
    767         }
    768         //Restore window origin of window with CS_OWNDC style
    769         //(fixes paint offset problems in Opera windows)
    770         if(win32wnd->isOwnDC()) {
    771                 dprintfOrigin(win32wnd->getOwnDC());
    772                 selectClientArea(win32wnd, win32wnd->getOwnDC());
     291            HWND hwndrelated;
     292            Win32BaseWindow *topwindow;
     293
     294            win32wnd->setComingToTop(TRUE);
     295
     296            hwndrelated = WinQueryWindow(hwnd, QW_PREV);
     297            dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
     298            topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
     299            if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
     300                //put window at the top of z order
     301                WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
     302            }
     303
     304            win32wnd->setComingToTop(FALSE);
     305            break;
    773306        }
    774307        goto RunDefWndProc;
     
    776309    case WM_VRNDISABLED:
    777310        dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    778         if(win32wnd->isOwnDC()) {
    779                 dprintfOrigin(win32wnd->getOwnDC());
    780         }
    781311        goto RunDefWndProc;
    782312
     
    808338    }
    809339
    810 #if 0
    811     //is sent to both windows gaining and loosing the focus
    812     case WM_FOCUSCHANGE:
    813     {
    814      HWND   hwndFocus = (HWND)mp1;
    815      HWND   hwndLoseFocus, hwndGainFocus;
    816      USHORT usSetFocus = SHORT1FROMMP(mp2);
    817      USHORT fsFocusChange = SHORT2FROMMP(mp2);
    818 
    819         rc = 0;
    820         dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    821         if(usSetFocus) {
    822             hwndGainFocus = hwnd;
    823             hwndLoseFocus = hwndFocus;
    824         }
    825         else {
    826             hwndGainFocus = hwndFocus;
    827             hwndLoseFocus = hwnd;
    828         }
    829 
    830         if(usSetFocus)
    831         {
    832           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
    833           if(!(fsFocusChange & FC_NOSETACTIVE))
    834           {
    835             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    836             {
    837               if(winfocus)
    838                 WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    839               else
    840                 WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    841             }
    842           }
    843           //SvL: Check if window is still valid
    844           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    845           if(win32wnd == NULL)
    846             return (MRESULT)rc;
    847 
    848           if(!(fsFocusChange & FC_NOSETACTIVE))
    849           {
    850             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    851             if(!winfocus || (winfocus->GetTopParent() != topparent))
    852             {
    853               if(!(fsFocusChange & FC_NOBRINGTOTOP))
    854               {
    855                 if(topparent) {
    856                   //put window at the top of z order
    857                   WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
    858                 }
    859               }
    860 
    861               // PH 2000/09/01 Netscape 4.7
    862               // check if topparent is valid
    863               if (topparent)
    864                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    865             }
    866           }
    867           //SvL: Check if window is still valid
    868           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    869           if(win32wnd == NULL)
    870             return (MRESULT)rc;
    871 
    872       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    873       if(!(fsFocusChange & FC_NOSETSELECTION)) {
    874             WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
    875       }
    876 
    877       if(!(fsFocusChange & FC_NOSETFOCUS)) {
    878             WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
    879       }
    880         }
    881         else /* no usSetFocus */
    882         {
    883       if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
    884             WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
    885       }
    886       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    887       if(!(fsFocusChange & FC_NOLOSESELECTION)) {
    888             WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
    889       }
    890           //SvL: Check if window is still valid
    891           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    892           if(win32wnd == NULL) {
    893                 return (MRESULT)rc;
    894           }
    895 
    896           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
    897           if(!(fsFocusChange & FC_NOLOSEACTIVE))
    898           {
    899             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    900 
    901             if(!winfocus || (winfocus->GetTopParent() != topparent))
    902             {
    903               // PH 2000/09/01 Netscape 4.7
    904               // check if topparent is valid
    905               if (topparent)
    906                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    907             }
    908           }
    909           //SvL: Check if window is still valid
    910           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    911           if(win32wnd == NULL)
    912             return (MRESULT)rc;
    913 
    914           if(!(fsFocusChange & FC_NOSETACTIVE))
    915           {
    916             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    917             {
    918               if(winfocus)
    919               {
    920                 // PH 2000/09/01 Netscape 4.7
    921                 // check if topparent is valid
    922                 Win32BaseWindow *topparent = winfocus->GetTopParent();
    923                 if (topparent)
    924                   WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    925               }
    926               else
    927                 WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    928             }
    929           }
    930         }
    931 
    932 
    933 #ifdef DEBUG
    934         SetWin32TIB();
    935         dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    936 #endif
    937         return (MRESULT)rc;
    938     }
    939 #endif
    940 
    941340    //**************************************************************************
    942341    //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
    943342    //**************************************************************************
    944 #ifndef ODIN_HITTEST
    945     case WM_HITTEST:
    946     {
    947         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    948             win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    949         }
    950         if(win32wnd && win32wnd->IsWindowCreated())
    951         {
    952             MRESULT rc;
    953 
    954             rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
    955             return rc;
    956         }
    957         return (MRESULT)HT_NORMAL;
    958     }
    959 #endif
    960343
    961344    case WM_BUTTON1DOWN:
     
    991374    case WM_MOUSEMOVE:
    992375    {
    993     if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    994         win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    995     }
     376        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     377            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     378        }
    996379        if(win32wnd)
    997380            win32wnd->MsgMouseMove(pWinMsg);
     
    1068451           rectl.yBottom != rectl.yTop))
    1069452        {
    1070             PRECT pClient = win32wnd->getClientRectPtr();
    1071             PRECT pWindow = win32wnd->getWindowRect();
    1072 
    1073             if(!(pClient->left == 0 && pClient->top == 0 &&
    1074                win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
    1075                win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
    1076             {
    1077                 win32wnd->MsgNCPaint();
    1078             }
    1079             win32wnd->DispatchMsgA(pWinMsg);
     453                win32wnd->DispatchMsgA(pWinMsg);
    1080454        }
    1081455        else    goto RunDefWndProc;
    1082 
    1083         //SvL: Not calling the default window procedure causes all sorts of
    1084         //     strange problems (redraw & hanging app)
    1085         //     -> check what WinBeginPaint does what we're forgetting in BeginPaint
    1086 //      WinQueryUpdateRect(hwnd, &rectl);
    1087 //        if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
    1088 //          RestoreOS2TIB();
    1089 //          return (MRESULT)FALSE;
    1090 //  }
    1091 //  dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
    1092 //  goto RunDefWndProc;
    1093456        break;
    1094457    }
     
    1100463    }
    1101464
    1102 #if 0
    1103     case WM_CONTEXTMENU:
    1104     {
    1105         win32wnd->DispatchMsgA(pWinMsg);
    1106 
    1107         return (MRESULT)TRUE;
    1108     }
    1109 #endif
    1110 
    1111     case WM_QUERYTRACKINFO:
    1112     {
    1113       PTRACKINFO trackInfo = (PTRACKINFO)mp2;
    1114 
    1115         dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
    1116         trackInfo->cxBorder = 4;
    1117         trackInfo->cyBorder = 4;
    1118         win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
    1119         return (MRESULT)TRUE;
    1120     }
    1121 
    1122     case WM_QUERYBORDERSIZE:
    1123     {
    1124       PWPOINT size = (PWPOINT)mp1;
    1125 
    1126       dprintf(("OS2: WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
    1127 
    1128       size->x = 0;
    1129       size->y = 0;
    1130       return (MRESULT)TRUE;
    1131     }
     465    case WM_CALCVALIDRECTS:
     466      dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     467      return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
    1132468
    1133469    case WM_REALIZEPALETTE:
     
    1163499    default:
    1164500        dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
    1165         RestoreOS2TIB();
    1166         if(isFrame) {
    1167              return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1168         }
    1169         else return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    1170   }
    1171   return (MRESULT)rc;
     501        goto RunDefWndProc;
     502    }
     503    return (MRESULT)rc;
    1172504
    1173505RunDefWndProc:
    1174506//  dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    1175   RestoreOS2TIB();
    1176   if(isFrame) {
    1177        return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1178   }
    1179   else return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     507    RestoreOS2TIB();
     508    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    1180509} /* End of Win32WindowProc */
    1181510//******************************************************************************
     
    1195524    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
    1196525    teb = GetThreadTEB();
    1197     win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     526    win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
    1198527
    1199528    if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
    1200         dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     529        dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
    1201530        goto RunDefFrameWndProc;
    1202531    }
     
    1233562    case WM_CREATE:
    1234563    {
    1235         RestoreOS2TIB();
    1236         pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1237         SetWin32TIB();
    1238         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
    1239         break;
    1240     }
     564        //WM_CREATE handled during client window creation
     565        goto RunDefFrameWndProc;
     566    }
     567
     568    case WM_PAINT:
     569    {
     570      RECTL rectl;
     571
     572
     573        HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
     574        dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
     575
     576        if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
     577           rectl.yBottom != rectl.yTop))
     578        {
     579            PRECT pClient = win32wnd->getClientRectPtr();
     580            PRECT pWindow = win32wnd->getWindowRect();
     581
     582            if(!(pClient->left == 0 && pClient->top == 0 &&
     583               win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
     584               win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
     585            {
     586                RECT rectUpdate;
     587
     588                mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
     589                win32wnd->MsgNCPaint(&rectUpdate);
     590            }
     591        }
     592        WinEndPaint(hps);
     593        break;
     594    }
     595
     596    case WM_ERASEBACKGROUND:
     597    {
     598        dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
     599        return (MRESULT)FALSE;
     600    }
     601
     602    //**************************************************************************
     603    //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
     604    //**************************************************************************
     605
     606    case WM_BUTTON1DOWN:
     607    case WM_BUTTON1UP:
     608    case WM_BUTTON1DBLCLK:
     609    case WM_BUTTON2DOWN:
     610    case WM_BUTTON2UP:
     611    case WM_BUTTON2DBLCLK:
     612    case WM_BUTTON3DOWN:
     613    case WM_BUTTON3UP:
     614    case WM_BUTTON3DBLCLK:
     615        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     616            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     617        }
     618        if(win32wnd)
     619            win32wnd->MsgButton(pWinMsg);
     620
     621        rc = (MRESULT)TRUE;
     622        break;
     623
     624    case WM_BUTTON2MOTIONSTART:
     625    case WM_BUTTON2MOTIONEND:
     626    case WM_BUTTON2CLICK:
     627    case WM_BUTTON1MOTIONSTART:
     628    case WM_BUTTON1MOTIONEND:
     629    case WM_BUTTON1CLICK:
     630    case WM_BUTTON3MOTIONSTART:
     631    case WM_BUTTON3MOTIONEND:
     632    case WM_BUTTON3CLICK:
     633        rc = (MRESULT)TRUE;
     634        break;
     635
     636    case WM_MOUSEMOVE:
     637    {
     638        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     639            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     640        }
     641        if(win32wnd)
     642            win32wnd->MsgMouseMove(pWinMsg);
     643        break;
     644    }
     645
     646    case WM_ADJUSTWINDOWPOS:
     647    {
     648      PSWP     pswp = (PSWP)mp1;
     649      SWP      swpOld;
     650      WINDOWPOS wp,wpOld;
     651      HWND      hParent = NULLHANDLE, hwndAfter;
     652
     653        dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     654
     655        if(pswp->fl & SWP_NOADJUST) {
     656            //ignore weird messages (TODO: why are they sent?)
     657            break;
     658        }
     659        //CB: show dialog in front of owner
     660        if (win32wnd->IsModalDialogOwner())
     661        {
     662            dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
     663            pswp->fl |= SWP_ZORDER;
     664            pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
     665            if (pswp->fl & SWP_ACTIVATE)
     666            {
     667                pswp->fl &= ~SWP_ACTIVATE;
     668                WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
     669            }
     670        }
     671
     672        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     673            goto RunDefWndProc;
     674
     675        if(!win32wnd->CanReceiveSizeMsgs())
     676            break;
     677
     678        WinQueryWindowPos(hwnd, &swpOld);
     679        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     680            if (win32wnd->isChild()) {
     681                if(win32wnd->getParent()) {
     682                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     683                }
     684                else    goto RunDefWndProc;
     685            }
     686        }
     687        hwndAfter = pswp->hwndInsertBehind;
     688        if(win32wnd->getParent()) {
     689             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
     690        }
     691        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
     692
     693        wp.hwnd = win32wnd->getWindowHandle();
     694        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     695        {
     696           Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     697           if(wndAfter) {
     698                wp.hwndInsertAfter = wndAfter->getWindowHandle();
     699           }
     700           else wp.hwndInsertAfter = HWND_TOP_W;
     701        }
     702
     703        wpOld = wp;
     704        win32wnd->MsgPosChanging((LPARAM)&wp);
     705
     706        if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
     707            (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
     708        {
     709            ULONG flags = pswp->fl;      //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
     710
     711            dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
     712            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     713
     714            if(win32wnd->getParent()) {
     715                  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
     716                                         hwnd);
     717            }
     718            else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
     719
     720            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     721
     722            //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
     723            if(pswp->fl & SWP_SIZE)
     724                flags |= SWP_SIZE;
     725
     726            if(pswp->fl & SWP_MOVE)
     727                flags |= SWP_MOVE;
     728
     729            pswp->fl = flags;   //restore flags
     730
     731            pswp->fl |= SWP_NOADJUST;
     732            pswp->hwndInsertBehind = hwndAfter;
     733            pswp->hwnd = hwnd;
     734
     735            return (MRESULT)0xf;
     736        }
     737        return (MRESULT)0;
     738    }
     739
     740    case WM_WINDOWPOSCHANGED:
     741    {
     742      PSWP      pswp   = (PSWP)mp1,pswpOld = pswp+1;
     743      SWP       swpOld = *(pswp + 1);
     744      WINDOWPOS wp;
     745      HWND      hParent = NULLHANDLE;
     746      RECTL     rect;
     747
     748        dprintf(("PMFRAME:WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     749
     750        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     751        {
     752            if(pswp->fl & SWP_ACTIVATE)
     753            {
     754                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     755                if(!(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
     756                {
     757                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     758                }
     759            }
     760            else
     761            if(pswp->fl & SWP_DEACTIVATE)
     762            {
     763                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     764                if(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
     765                {
     766                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
     767                }
     768            }
     769            goto RunDefWndProc;
     770        }
     771
     772        if(pswp->fl & (SWP_MOVE | SWP_SIZE))
     773        {
     774            if(win32wnd->isChild())
     775            {
     776                if(win32wnd->getParent()) {
     777                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     778                }
     779                else    goto PosChangedEnd; //parent has just been destroyed
     780            }
     781        }
     782
     783
     784        if(win32wnd->getParent()) {
     785             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
     786                                    hwnd);
     787        }
     788        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
     789
     790        wp.hwnd = win32wnd->getWindowHandle();
     791        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     792        {
     793            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     794            if(wndAfter) {
     795                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     796            }
     797            else wp.hwndInsertAfter = HWND_TOP_W;
     798        }
     799
     800        if(pswp->fl & SWP_SHOW) {
     801            WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
     802        }
     803#ifndef USE_CALCVALIDRECT
     804        if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
     805        {
     806            //CB: todo: use result for WM_CALCVALIDRECTS
     807            //Get old client rectangle (for invalidation of frame window parts later on)
     808            //Use new window height to calculate the client area
     809            mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
     810
     811            //Note: Also updates the new window rectangle
     812            win32wnd->MsgFormatFrame(&wp);
     813
     814            if(win32wnd->isOwnDC()) {
     815                setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
     816            }
     817
     818            if(win32wnd->CanReceiveSizeMsgs())
     819                win32wnd->MsgPosChanged((LPARAM)&wp);
     820
     821            if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
     822            {
     823                //redraw the frame (to prevent unnecessary client updates)
     824                BOOL redrawAll = FALSE;
     825
     826                dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
     827                if (win32wnd->getWindowClass())
     828                {
     829                    DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
     830
     831                    if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
     832                        redrawAll = TRUE;
     833                    else
     834                    if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
     835                        redrawAll = TRUE;
     836                }
     837                else redrawAll = TRUE;
     838
     839                if(win32wnd->IsMixMaxStateChanging()) {
     840                    dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
     841                    redrawAll = TRUE;
     842                }
     843
     844                if (redrawAll)
     845                {
     846                    //CB: redraw all children for now
     847                    //    -> problems with update region if we don't do it
     848                    //       todo: rewrite whole handling
     849                    WinInvalidateRect(hwnd,NULL,TRUE);
     850                }
     851                else
     852                {
     853                    HPS hps = WinGetPS(hwnd);
     854                    RECTL frame,client,arcl[4];
     855
     856                    WinQueryWindowRect(hwnd,&frame);
     857
     858                    //top
     859                    arcl[0].xLeft = 0;
     860                    arcl[0].xRight = frame.xRight;
     861                    arcl[0].yBottom = rect.yTop;
     862                    arcl[0].yTop = frame.yTop;
     863                    //right
     864                    arcl[1].xLeft = rect.xRight;
     865                    arcl[1].xRight = frame.xRight;
     866                    arcl[1].yBottom = 0;
     867                    arcl[1].yTop = frame.yTop;
     868                    //left
     869                    arcl[2].xLeft = 0;
     870                    arcl[2].xRight = rect.xLeft;
     871                    arcl[2].yBottom = 0;
     872                    arcl[2].yTop = frame.yTop;
     873                    //bottom
     874                    arcl[3].xLeft = 0;
     875                    arcl[3].xRight = frame.xRight;
     876                    arcl[3].yBottom = 0;
     877                    arcl[3].yTop = rect.yBottom;
     878
     879                    HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
     880
     881                    WinInvalidateRegion(hwnd,hrgn,FALSE);
     882                    GpiDestroyRegion(hps,hrgn);
     883                    WinReleasePS(hps);
     884                }
     885            }
     886        }
     887        else
     888        {
     889#endif //USE_CALCVALIDRECT
     890            if(win32wnd->CanReceiveSizeMsgs())
     891                win32wnd->MsgPosChanged((LPARAM)&wp);
     892#ifndef USE_CALCVALIDRECT
     893        }
     894#endif
     895
     896        if(pswp->fl & SWP_ACTIVATE)
     897        {
     898             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     899             if(!(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
     900             {
     901                WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     902             }
     903        }
     904        else
     905        if(pswp->fl & SWP_DEACTIVATE)
     906        {
     907            //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     908            if(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
     909            {
     910                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
     911            }
     912        }
     913
     914PosChangedEnd:
     915        return (MRESULT)FALSE;
     916    }
     917
     918    case WM_CALCVALIDRECTS:
     919#ifdef USE_CALCVALIDRECT
     920    {
     921        PRECTL    oldRect = (PRECTL)mp1, newRect = oldRect+1;
     922        PSWP      pswp = (PSWP)mp2;
     923        SWP       swpOld;
     924        WINDOWPOS wp;
     925        RECTL     newClientRect, oldClientRect;
     926        ULONG     nccalcret;
     927//        UINT      res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
     928        UINT      res = 0;
     929
     930        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     931
     932        //Get old position info
     933        WinQueryWindowPos(hwnd, &swpOld);
     934
     935        if(win32wnd->getParent()) {
     936             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
     937                                    win32wnd->getParent()->getClientRectPtr()->left,
     938                                    win32wnd->getParent()->getClientRectPtr()->top,
     939                                    hwnd);
     940        }
     941        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     942
     943        wp.hwnd = win32wnd->getWindowHandle();
     944        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     945        {
     946            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     947            if(wndAfter) {
     948                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     949            }
     950            else wp.hwndInsertAfter = HWND_TOP_W;
     951        }
     952
     953        //Get old client rectangle
     954        mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
     955
     956        //Note: Also updates the new window rectangle
     957        nccalcret = win32wnd->MsgFormatFrame(&wp);
     958
     959        //Get new client rectangle
     960        mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
     961
     962        if(nccalcret == 0) {
     963            res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
     964        }
     965        else {
     966            if(nccalcret & WVR_ALIGNTOP_W) {
     967                res |= CVR_ALIGNTOP;
     968            }
     969            else
     970            if(nccalcret & WVR_ALIGNBOTTOM_W) {
     971                res |= CVR_ALIGNBOTTOM;
     972            }
     973
     974            if(nccalcret & WVR_ALIGNLEFT_W) {
     975                res |= CVR_ALIGNLEFT;
     976            }
     977            else
     978            if(nccalcret & WVR_ALIGNRIGHT_W) {
     979                res |= CVR_ALIGNRIGHT;
     980            }
     981
     982            if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
     983                res |= CVR_REDRAW;
     984            }
     985            else
     986            if(nccalcret & WVR_VALIDRECTS_W) {
     987                //TODO:
     988                //res = 0;
     989            }
     990        }
     991        if(win32wnd->IsMixMaxStateChanging()) {
     992            dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
     993            res |= CVR_REDRAW;
     994        }
     995        if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
     996            oldRect->xRight  -= oldClientRect.xLeft;
     997            oldRect->yBottom += oldClientRect.yBottom;
     998            newRect->xRight  -= newClientRect.xLeft;
     999            newRect->yBottom += newClientRect.yBottom;
     1000        }
     1001        return (MRESULT)res;
     1002    }
     1003#else
     1004        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     1005        return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
     1006#endif
    12411007
    12421008    case WM_CALCFRAMERECT:
    1243         dprintf(("OS2: WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
     1009        dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
    12441010        rc = (MRESULT)TRUE;
    12451011        break;
     
    12471013    case WM_QUERYCTLTYPE:
    12481014        // This is a frame window
    1249         dprintf(("OS2: WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
     1015        dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
    12501016        rc = (MRESULT)CCT_FRAME;
    12511017        break;
    12521018
     1019#ifdef DEBUG
    12531020    case WM_QUERYFOCUSCHAIN:
    1254         dprintf(("OS2: WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2));
    1255        
    1256         RestoreOS2TIB();
    1257         rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1258         SetWin32TIB();
    1259         dprintf(("OS2: WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2, rc));
    1260         break;
    1261 
     1021        dprintf(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2));
     1022
     1023//        RestoreOS2TIB();
     1024//        rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
     1025//        SetWin32TIB();
     1026//        dprintf(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2, rc));
     1027//        break;
     1028        goto RunDefFrameWndProc;
     1029#endif
     1030
     1031#if 0
     1032    //is sent to both windows gaining and loosing the focus
     1033    case WM_FOCUSCHANGE:
     1034    {
     1035     HWND   hwndFocus = (HWND)mp1;
     1036     HWND   hwndLoseFocus, hwndGainFocus;
     1037     USHORT usSetFocus = SHORT1FROMMP(mp2);
     1038     USHORT fsFocusChange = SHORT2FROMMP(mp2);
     1039
     1040        rc = 0;
     1041        dprintf(("PMFRAME:WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     1042        if(usSetFocus) {
     1043            hwndGainFocus = hwnd;
     1044            hwndLoseFocus = hwndFocus;
     1045        }
     1046        else {
     1047            hwndGainFocus = hwndFocus;
     1048            hwndLoseFocus = hwnd;
     1049        }
     1050
     1051        if(usSetFocus)
     1052        {
     1053          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
     1054          if(!(fsFocusChange & FC_NOSETACTIVE))
     1055          {
     1056            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
     1057            {
     1058              if(winfocus)
     1059                WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     1060              else
     1061                WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     1062            }
     1063          }
     1064          //SvL: Check if window is still valid
     1065          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1066          if(win32wnd == NULL)
     1067            return (MRESULT)rc;
     1068
     1069          if(!(fsFocusChange & FC_NOSETACTIVE))
     1070          {
     1071            Win32BaseWindow *topparent = win32wnd->GetTopParent();
     1072            if(!winfocus || (winfocus->GetTopParent() != topparent))
     1073            {
     1074              if(!(fsFocusChange & FC_NOBRINGTOTOP))
     1075              {
     1076                if(topparent) {
     1077                  //put window at the top of z order
     1078                  WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
     1079                }
     1080              }
     1081
     1082              // PH 2000/09/01 Netscape 4.7
     1083              // check if topparent is valid
     1084              if (topparent)
     1085                WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     1086            }
     1087          }
     1088          //SvL: Check if window is still valid
     1089          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1090          if(win32wnd == NULL)
     1091            return (MRESULT)rc;
     1092
     1093      //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     1094      if(!(fsFocusChange & FC_NOSETSELECTION)) {
     1095            WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
     1096      }
     1097
     1098      if(!(fsFocusChange & FC_NOSETFOCUS)) {
     1099            WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
     1100      }
     1101        }
     1102        else /* no usSetFocus */
     1103        {
     1104      if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
     1105            WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
     1106      }
     1107      //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     1108      if(!(fsFocusChange & FC_NOLOSESELECTION)) {
     1109            WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
     1110      }
     1111          //SvL: Check if window is still valid
     1112          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1113          if(win32wnd == NULL) {
     1114                return (MRESULT)rc;
     1115          }
     1116
     1117          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
     1118          if(!(fsFocusChange & FC_NOLOSEACTIVE))
     1119          {
     1120            Win32BaseWindow *topparent = win32wnd->GetTopParent();
     1121
     1122            if(!winfocus || (winfocus->GetTopParent() != topparent))
     1123            {
     1124              // PH 2000/09/01 Netscape 4.7
     1125              // check if topparent is valid
     1126              if (topparent)
     1127                WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     1128            }
     1129          }
     1130          //SvL: Check if window is still valid
     1131          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1132          if(win32wnd == NULL)
     1133            return (MRESULT)rc;
     1134
     1135          if(!(fsFocusChange & FC_NOSETACTIVE))
     1136          {
     1137            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
     1138            {
     1139              if(winfocus)
     1140              {
     1141                // PH 2000/09/01 Netscape 4.7
     1142                // check if topparent is valid
     1143                Win32BaseWindow *topparent = winfocus->GetTopParent();
     1144                if (topparent)
     1145                  WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     1146              }
     1147              else
     1148                WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     1149            }
     1150          }
     1151        }
     1152
     1153
     1154#ifdef DEBUG
     1155        dprintf(("PMFRAME:WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     1156#endif
     1157        return (MRESULT)rc;
     1158    }
     1159#endif
     1160
     1161#ifdef DEBUG
    12621162    case WM_FOCUSCHANGE:
    12631163    {
     
    12671167        USHORT fsFocusChange = SHORT2FROMMP(mp2);
    12681168
    1269         dprintf(("OS2: WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     1169        dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    12701170        goto RunDefFrameWndProc;
    12711171    }
     1172#endif
    12721173
    12731174    case WM_ACTIVATE:
     1175    {
     1176        HWND hwndTitle;
     1177        USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
     1178
     1179        dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
     1180        if (win32wnd->IsWindowCreated())
     1181        {
     1182            WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
     1183            WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
     1184
     1185            //CB: show owner behind the dialog
     1186            if (win32wnd->IsModalDialog())
     1187            {
     1188                Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
     1189
     1190                if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     1191            }
     1192        }
     1193        else
     1194        {
     1195            WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
     1196        }
     1197        RestoreOS2TIB();
     1198        return 0;
     1199    }
     1200
     1201    case WM_ENABLE:
     1202        dprintf(("OS2: WM_ENABLE %x", hwnd));
     1203        win32wnd->MsgEnable(SHORT1FROMMP(mp1));
     1204        break;
     1205
     1206    case WM_SHOW:
     1207        dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
     1208        //show client window
     1209        WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
     1210        win32wnd->MsgShow((ULONG)mp1);
     1211        break;
     1212
    12741213    case WM_SETFOCUS:
    12751214    {
    1276         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
    12771215        goto RunDefFrameWndProc;
    12781216    }
    12791217
    1280 #if 0
    1281 //just a test
    1282     case WM_ADJUSTWINDOWPOS:
    1283     case WM_WINDOWPOSCHANGED:
    1284     {
    1285         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
     1218    case WM_QUERYTRACKINFO:
     1219    {
     1220        PTRACKINFO trackInfo = (PTRACKINFO)mp2;
     1221
     1222        dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
     1223        trackInfo->cxBorder = 4;
     1224        trackInfo->cyBorder = 4;
     1225        win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
     1226        return (MRESULT)TRUE;
     1227    }
     1228
     1229    case WM_QUERYBORDERSIZE:
     1230    {
     1231        PWPOINT size = (PWPOINT)mp1;
     1232
     1233        dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
     1234
     1235        size->x = 0;
     1236        size->y = 0;
     1237        return (MRESULT)TRUE;
     1238    }
     1239
     1240    case WM_QUERYFRAMEINFO:
     1241        dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
    12861242        goto RunDefFrameWndProc;
    1287     }
    1288 #endif
    1289 
    1290     case WM_QUERYFRAMEINFO:
    1291         dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
     1243
     1244    case WM_FORMATFRAME:
     1245        dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
     1246        break;
     1247
     1248    case WM_ADJUSTFRAMEPOS:
     1249    {
     1250        PSWP pswp   = (PSWP)mp1;
     1251
     1252        dprintf(("PMFRAME:WM_ADJUSTFRAMEPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    12921253        goto RunDefFrameWndProc;
    1293 
    1294     case WM_FORMATFRAME:
    1295         dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
     1254    }
     1255
     1256    case WM_OWNERPOSCHANGE:
     1257    {
     1258        PSWP pswp   = (PSWP)mp1;
     1259
     1260        dprintf(("PMFRAME:WM_OWNERPOSCHANGE %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    12961261        goto RunDefFrameWndProc;
    1297 
    1298     case WM_ADJUSTFRAMEPOS:
    1299     {
    1300         PSWP pswp   = (PSWP)mp1;
    1301 
    1302         dprintf(("OS2: WM_ADJUSTFRAMEPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    1303         goto RunDefFrameWndProc;
    1304     }
    1305 
    1306     case WM_OWNERPOSCHANGE:
    1307     {
    1308         PSWP pswp   = (PSWP)mp1;
    1309 
    1310         dprintf(("OS2: WM_OWNERPOSCHANGE %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    1311         goto RunDefFrameWndProc;
    13121262    }
    13131263
     
    13181268        if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
    13191269
    1320         dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
     1270        dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
    13211271        if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
    13221272        {
     
    13461296
    13471297    case WM_UPDATEFRAME:
    1348         dprintf(("OS2: WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
     1298        dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
    13491299        goto RunDefFrameWndProc;
    13501300
    13511301    default:
    1352         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
    1353         break;
     1302        goto RunDefFrameWndProc;
    13541303    }
    13551304    RestoreOS2TIB();
     
    13621311RunDefWndProc:
    13631312    RestoreOS2TIB();
    1364     return Win32WindowProc(hwnd, msg, mp1, mp2);
     1313    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    13651314}
    13661315//******************************************************************************
     
    13731322  PRECT     pWindowRect, pClientRect;
    13741323  HWND      hwndTracking;
    1375   HPS       hpsTrack;
    13761324  LONG      parentHeight, parentWidth;
    1377   LONG      clientOrgX, clientOrgY;
    13781325
    13791326    dprintf(("FrameTrackFrame: %x %x", win32wnd->getWindowHandle(), flags));
     
    13871334    pWindowRect = win32wnd->getWindowRect();
    13881335    if(win32wnd->getParent()) {
    1389         parentHeight = win32wnd->getParent()->getWindowHeight();
    1390         parentWidth  = win32wnd->getParent()->getWindowWidth();
     1336        parentHeight = win32wnd->getParent()->getClientHeight();
     1337        parentWidth  = win32wnd->getParent()->getClientWidth();
    13911338        hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
    1392         hpsTrack     = WinGetPS(hwndTracking);
    1393         clientOrgX   = win32wnd->getParent()->getClientRectPtr()->left;
    1394         clientOrgY   = win32wnd->getParent()->getClientRectPtr()->top;
    13951339    }
    13961340    else {
     
    13981342        parentWidth  = OSLibQueryScreenWidth();
    13991343        hwndTracking = HWND_DESKTOP;
    1400         hpsTrack     = NULL;
    1401         clientOrgX   = 0;
    1402         clientOrgY   = 0;
    14031344    }
    14041345
    14051346    mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
    1406     track.rclTrack.xLeft += clientOrgX;
    1407     track.rclTrack.yTop  -= clientOrgY;
    14081347    rcl = track.rclTrack;
    14091348    WinQueryWindowRect(hwndTracking, &track.rclBoundary);
     
    14201359    if(WinTrackRect(hwndTracking, NULL, &track) )
    14211360    {
    1422         if(hpsTrack)    WinReleasePS(hpsTrack);
    1423 
    14241361        /* if successful copy final position back */
    14251362        if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
    14261363            dprintf(("FrameTrackFrame: new (os/2) window rect: (%d,%d)(%d,%d)", track.rclTrack.xLeft, track.rclTrack.yBottom, track.rclTrack.xRight - track.rclTrack.xLeft, track.rclTrack.yTop - track.rclTrack.yBottom));
    14271364            if(flags == TF_MOVE) {
    1428                 WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     1365                WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),
    14291366                                0, track.rclTrack.xLeft, track.rclTrack.yBottom,
    14301367                                0, 0, SWP_MOVE);
    14311368            }
    14321369            else {
    1433 ////              SetWindowPos(win32wnd->getWindowHandle(), 0, track.rclTrack.xLeft,
    1434 ////                           parentHeight - track.rclTrack.yTop,
    1435 ////                           track.rclTrack.xRight - track.rclTrack.xLeft,
    1436 ////                           track.rclTrack.yTop - track.rclTrack.yBottom,
    1437 ////                           SWP_NOACTIVATE_W | SWP_NOZORDER_W | SWP_NOACTIVATE_W);
    1438                 WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     1370                WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),
    14391371                                0, track.rclTrack.xLeft, track.rclTrack.yBottom,
    14401372                                track.rclTrack.xRight - track.rclTrack.xLeft,
     
    14451377        return;
    14461378   }
    1447    if(hpsTrack) WinReleasePS(hpsTrack);
    14481379   return;
    14491380}
Note: See TracChangeset for help on using the changeset viewer.