Ignore:
Timestamp:
Dec 24, 2000, 3:54:07 PM (25 years ago)
Author:
sandervl
Message:

MDI + SetParent + activation fixes

File:
1 edited

Legend:

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

    r4825 r4839  
    1 /* $Id: pmwindow.cpp,v 1.109 2000-12-17 15:04:10 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.110 2000-12-24 14:54:07 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    5050ULONG ScreenBitsPerPel = 0;
    5151
     52static PFNWP pfnFrameWndProc = NULL;
    5253
    5354MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     55MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     56MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd,
     57                         MSG *pWinMsg, TEB *teb, BOOL isFrame);
    5458
    5559//******************************************************************************
     
    5862BOOL InitPM()
    5963{
    60  
    61   hab = WinInitialize(0);
    62   dprintf(("Winitialize returned %x", hab));
    63   hmq = WinCreateMsgQueue(hab, 0);
    64 
    65   if(!hab || !hmq)
    66   {
     64
     65    hab = WinInitialize(0);
     66    dprintf(("Winitialize returned %x", hab));
     67    hmq = WinCreateMsgQueue(hab, 0);
     68
     69    if(!hab || !hmq)
     70    {
    6771        UINT error;
    6872        //CB: only fail on real error
     
    7478            return(FALSE);
    7579        }
    76     else
    77         {
    78         if(!hab) {
     80        else
     81        {
     82            if(!hab) {
    7983                hab = WinQueryAnchorBlock(HWND_DESKTOP);
    80             dprintf(("WinQueryAnchorBlock returned %x", hab));
    81         }
    82         if(!hmq) {
    83             hmq = HMQ_CURRENT;
    84         }
    85         }
    86   }
    87   SetThreadHAB(hab);
    88   dprintf(("InitPM: hmq = %x", hmq));
    89   SetThreadMessageQueue(hmq);
    90 
    91   BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
    92   dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
    93 
    94   if(!WinRegisterClass(                 /* Register window class        */
    95      hab,                               /* Anchor block handle          */
    96      (PSZ)WIN32_STDCLASS,               /* Window class name            */
    97      (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    98      CS_HITTEST,
    99      NROF_WIN32WNDBYTES)) {
    100         dprintf(("WinRegisterClass Win32BaseWindow failed"));
    101         return(FALSE);
    102   }
    103 
    104   CLASSINFO FrameClassInfo;
    105   if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
    106      dprintf (("WinQueryClassInfo WC_FRAME failed"));
    107      return (FALSE);
    108   }
    109   dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
    110 
    111   if(!WinRegisterClass(                 /* Register window class        */
    112      hab,                               /* Anchor block handle          */
    113      (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
    114      (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    115      CS_HITTEST | CS_FRAME,
    116      FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES)) {
     84                dprintf(("WinQueryAnchorBlock returned %x", hab));
     85            }
     86            if(!hmq) {
     87                hmq = HMQ_CURRENT;
     88            }
     89        }
     90    }
     91    SetThreadHAB(hab);
     92    dprintf(("InitPM: hmq = %x", hmq));
     93    SetThreadMessageQueue(hmq);
     94
     95    BOOL rc = WinSetCp(hmq, GetDisplayCodepage());
     96    dprintf(("InitPM: WinSetCP was %sOK", rc ? "" : "not "));
     97
     98    if(!WinRegisterClass(                 /* Register window class        */
     99        hab,                               /* Anchor block handle          */
     100        (PSZ)WIN32_STDCLASS,               /* Window class name            */
     101        (PFNWP)Win32WindowProc,            /* Address of window procedure  */
     102        CS_HITTEST,
     103        NROF_WIN32WNDBYTES))
     104    {
     105            dprintf(("WinRegisterClass Win32BaseWindow failed"));
     106            return(FALSE);
     107    }
     108
     109    CLASSINFO FrameClassInfo;
     110    if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
     111        dprintf (("WinQueryClassInfo WC_FRAME failed"));
     112        return (FALSE);
     113    }
     114    pfnFrameWndProc = FrameClassInfo.pfnWindowProc;
     115
     116    dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
     117
     118    if(!WinRegisterClass(                 /* Register window class        */
     119        hab,                               /* Anchor block handle          */
     120        (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
     121        (PFNWP)Win32FrameWindowProc,       /* Address of window procedure  */
     122        CS_HITTEST | CS_FRAME,
     123        FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES))
     124    {
    117125        dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
    118126        return(FALSE);
    119   }
    120 
    121   WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
    122   ScreenWidth  = desktopRectl.xRight;
    123   ScreenHeight = desktopRectl.yTop;
    124 
    125   HDC   hdc;              /* Device-context handle                */
    126   /* context data structure */
    127   DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
    128                      NULL, NULL, NULL};
    129 
    130   /* create memory device context */
    131   hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
    132   DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
    133   DevCloseDC(hdc);
    134 
    135   dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
    136   return TRUE;
     127    }
     128
     129    WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
     130    ScreenWidth  = desktopRectl.xRight;
     131    ScreenHeight = desktopRectl.yTop;
     132
     133    HDC   hdc;              /* Device-context handle                */
     134    /* context data structure */
     135    DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
     136                        NULL, NULL, NULL};
     137
     138    /* create memory device context */
     139    hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
     140    DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
     141    DevCloseDC(hdc);
     142
     143    dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
     144    return TRUE;
    137145} /* End of main */
    138146//******************************************************************************
     
    141149MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    142150{
    143  POSTMSG_PACKET  *postmsg;
    144  OSLIBPOINT       point, ClientPoint;
    145151 Win32BaseWindow *win32wnd;
    146152 TEB             *teb;
    147  APIRET           rc = 0;
    148153 MSG              winMsg, *pWinMsg;
    149 
    150   //Restore our FS selector
    151   SetWin32TIB();
    152 
    153   teb = GetThreadTEB();
    154   win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    155 
    156   if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
     154 MRESULT          rc = 0;
     155
     156    //Restore our FS selector
     157    SetWin32TIB();
     158
     159    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
     160    teb = GetThreadTEB();
     161    win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     162
     163    if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
    157164        dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
    158165        goto RunDefWndProc;
    159   }
    160 
    161   if((teb->o.odin.msgstate & 1) == 0)
    162   {//message that was sent directly to our window proc handler; translate it here
     166    }
     167
     168    if((teb->o.odin.msgstate & 1) == 0)
     169    {//message that was sent directly to our window proc handler; translate it here
    163170        QMSG qmsg;
    164171
     
    176183        }
    177184        pWinMsg = &winMsg;
    178   }
    179   else {
     185    }
     186    else {
    180187        pWinMsg = &teb->o.odin.msg;
    181188        teb->o.odin.msgstate++;
    182   }
     189    }
     190    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
     191    rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, FALSE);
     192    RestoreOS2TIB();
     193    return rc;
     194
     195RunDefWndProc:
     196    RestoreOS2TIB();
     197    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     198}
     199//******************************************************************************
     200//******************************************************************************
     201MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd, MSG *pWinMsg, TEB *teb, BOOL isFrame)
     202{
     203 POSTMSG_PACKET  *postmsg;
     204 OSLIBPOINT       point, ClientPoint;
     205 MRESULT          rc = 0;
    183206
    184207  if(msg == WIN32APP_POSTMSG) {
     
    192215        }
    193216  }
     217
    194218  switch( msg )
    195219  {
     
    206230        if(win32wnd->MsgCreate(hwnd) == FALSE)
    207231        {
    208             RestoreOS2TIB();
    209232            return (MRESULT)TRUE; //discontinue window creation
    210233        }
    211234    createfail:
    212         RestoreOS2TIB();
    213235        return (MRESULT)FALSE;
    214236    }
     
    228250        win32wnd->MsgDestroy();
    229251        WinSetVisibleRegionNotify(hwnd, FALSE);
    230         goto RunDefWndProc;
     252        goto RunDefWndProc;
    231253
    232254    case WM_ENABLE:
     
    248270
    249271        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));
    250  
     272
    251273        if(pswp->fl & SWP_NOADJUST) {
    252                 //ignore weird messages (TODO: why are they sent?)
    253                 break;
    254         }
     274            //ignore weird messages (TODO: why are they sent?)
     275            break;
     276        }
    255277        //CB: show dialog in front of owner
    256278        if (win32wnd->IsModalDialogOwner())
    257279        {
    258           pswp->fl |= SWP_ZORDER;
    259           pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
    260           if (pswp->fl & SWP_ACTIVATE)
    261           {
    262             pswp->fl &= ~SWP_ACTIVATE;
    263             WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
    264           }
     280            pswp->fl |= SWP_ZORDER;
     281            pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
     282            if (pswp->fl & SWP_ACTIVATE)
     283            {
     284                pswp->fl &= ~SWP_ACTIVATE;
     285                WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
     286            }
    265287        }
    266288
     
    282304        hwndAfter = pswp->hwndInsertBehind;
    283305        if(win32wnd->getParent()) {
    284               OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    285                                      win32wnd->getParent()->getClientRectPtr()->left,
    286                                      win32wnd->getParent()->getClientRectPtr()->top,
    287                                      hwnd);
    288         } 
    289         else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     306            OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     307                                   win32wnd->getParent()->getClientRectPtr()->left,
     308                                   win32wnd->getParent()->getClientRectPtr()->top,
     309                                   hwnd);
     310        }
     311        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    290312
    291313        wp.hwnd = win32wnd->getWindowHandle();
     
    305327            (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
    306328        {
    307           dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
    308           dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    309 
    310           if(win32wnd->getParent()) {
    311                 OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    312                                        win32wnd->getParent()->getClientRectPtr()->left,
    313                                        win32wnd->getParent()->getClientRectPtr()->top,
     329            dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
     330            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     331
     332            if(win32wnd->getParent()) {
     333                OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     334                                       win32wnd->getParent()->getClientRectPtr()->left,
     335                                       win32wnd->getParent()->getClientRectPtr()->top,
    314336                                       hwnd);
    315           }
    316           else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    317 
    318           dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    319           pswp->fl |= SWP_NOADJUST;
    320           pswp->hwndInsertBehind = hwndAfter;
    321           pswp->hwnd = hwnd;
    322 
    323           RestoreOS2TIB();
    324           return (MRESULT)0xf;
    325         }
    326         RestoreOS2TIB();
     337            }
     338            else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     339
     340            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     341            pswp->fl |= SWP_NOADJUST;
     342            pswp->hwndInsertBehind = hwndAfter;
     343            pswp->hwnd = hwnd;
     344
     345            return (MRESULT)0xf;
     346        }
    327347        return (MRESULT)0;
    328348    }
     
    340360        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    341361        {
    342                 if(pswp->fl & SWP_ACTIVATE)
    343                 {
    344                         if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE)) {
    345                                 WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    346                         }
    347                 }
    348                 goto RunDefWndProc;
    349         }
    350 
    351         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    352             if(win32wnd->isChild()) {
     362            if(pswp->fl & SWP_ACTIVATE)
     363            {
     364                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     365                if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE))
     366                {
     367                    if(isFrame) {
     368                        WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     369                    }
     370                    else
     371                    if(win32wnd->IsWindowCreated()) {
     372                        win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
     373                    }
     374                }
     375            }
     376            goto RunDefWndProc;
     377        }
     378
     379        if(pswp->fl & (SWP_MOVE | SWP_SIZE))
     380        {
     381            if(win32wnd->isChild())
     382            {
    353383                if(win32wnd->getParent()) {
    354384                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     
    360390
    361391        if(win32wnd->getParent()) {
    362               OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     392          OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    363393                                     win32wnd->getParent()->getClientRectPtr()->left,
    364394                                     win32wnd->getParent()->getClientRectPtr()->top,
    365395                                     hwnd);
    366         } 
     396        }
    367397        else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    368398
     
    454484        if(pswp->fl & SWP_ACTIVATE)
    455485        {
    456              if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE)) {
    457                 WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    458              }
     486             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     487             if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE))
     488             {
     489                if(isFrame) {
     490                     WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     491                }
     492                else
     493                if(win32wnd->IsWindowCreated()) {
     494                    win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
     495                }
     496             }
    459497        }
    460498
    461499PosChangedEnd:
    462         RestoreOS2TIB();
    463500        return (MRESULT)FALSE;
    464501    }
     
    471508
    472509        WinSetWindowUShort(hwnd,QWS_FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
    473         if(win32wnd->IsWindowCreated())
    474         {
    475           win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
    476 
    477           //CB: show owner behind the dialog
    478           if(win32wnd->IsModalDialog())
    479           {
    480             Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
    481 
    482             if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
    483           }
    484         }
    485         RestoreOS2TIB();
     510        if(win32wnd->IsWindowCreated())
     511        {
     512            win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
     513
     514            //CB: show owner behind the dialog
     515            if(win32wnd->IsModalDialog())
     516            {
     517                Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
     518
     519                if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     520            }
     521        }
    486522        return 0;
    487523    }
     
    491527        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
    492528        goto RunDefWndProc;
    493     }
    494 
    495     case WM_MINMAXFRAME:
    496     {
    497       PSWP swp = (PSWP)mp1;
    498 
    499       if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
    500 
    501       dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
    502       if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
    503       {
    504         win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
    505 
    506         RECT rect;
    507 
    508         rect.left = rect.top = rect.right = rect.bottom = 0;
    509         win32wnd->AdjustMaximizedRect(&rect);
    510         swp->x += rect.left;
    511         swp->cx += rect.right-rect.left;
    512         swp->y -= rect.bottom;
    513         swp->cy += rect.bottom-rect.top;
    514       }
    515       else if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
    516       {
    517         win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
    518       }
    519       else if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
    520       {
    521         win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
    522       }
    523       goto RunDefWndProc;
    524529    }
    525530
     
    536541
    537542        if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
    538           res |= CVR_REDRAW;
    539         else if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
    540           res |= CVR_REDRAW;
    541       } else res |= CVR_REDRAW;
    542 
    543       RestoreOS2TIB();
     543            res |= CVR_REDRAW;
     544        else
     545        if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
     546            res |= CVR_REDRAW;
     547      }
     548      else res |= CVR_REDRAW;
     549
    544550      return (MRESULT)res;
    545551    }
    546552#else
    547553      dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    548       RestoreOS2TIB();
    549554      return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
    550555#endif
    551556
    552557    case WM_VRNENABLED:
    553         dprintf(("OS2: WM_VRNENABLED %x", win32wnd->getWindowHandle()));
     558        dprintf(("OS2: WM_VRNENABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    554559        if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
    555560        {
     
    576581      HWND hwndFocus = (HWND)mp1;
    577582
    578         dprintf(("OS2: WM_SETFOCUS %x %x %d", win32wnd->getWindowHandle(), mp1, mp2));
     583        dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d", win32wnd->getWindowHandle(), mp1, Win32BaseWindow::OS2ToWin32Handle(hwndFocus), mp2));
    579584        if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    580585                //another (non-win32) application's window
     
    591596    }
    592597
     598#if 0
    593599    //is sent to both windows gaining and loosing the focus
    594600    case WM_FOCUSCHANGE:
     
    601607        rc = 0;
    602608        dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    603         RestoreOS2TIB();
    604         if(usSetFocus) {
    605                 hwndGainFocus = hwnd;
    606                 hwndLoseFocus = hwndFocus;
    607         }
    608         else {
    609                 hwndGainFocus = hwndFocus;
    610                 hwndLoseFocus = hwnd;
    611         }
    612      
     609        if(usSetFocus) {
     610            hwndGainFocus = hwnd;
     611            hwndLoseFocus = hwndFocus;
     612        }
     613        else {
     614            hwndGainFocus = hwndFocus;
     615            hwndLoseFocus = hwnd;
     616        }
     617
    613618        if(usSetFocus)
    614619        {
     
    616621          if(!(fsFocusChange & FC_NOSETACTIVE))
    617622          {
    618             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent())) 
     623            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    619624            {
    620625              if(winfocus)
    621626                WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    622               else     
     627              else
    623628                WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    624629            }
     
    641646                }
    642647              }
    643  
     648
    644649              // PH 2000/09/01 Netscape 4.7
    645650              // check if topparent is valid
     
    653658            return (MRESULT)rc;
    654659
    655           //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    656           if(!(fsFocusChange & FC_NOSETSELECTION)) {
    657                 WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
    658           }
    659 
    660           if(!(fsFocusChange & FC_NOSETFOCUS)) {
    661                 WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
    662           }
     660      //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     661      if(!(fsFocusChange & FC_NOSETSELECTION)) {
     662            WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
     663      }
     664
     665      if(!(fsFocusChange & FC_NOSETFOCUS)) {
     666            WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
     667      }
    663668        }
    664669        else /* no usSetFocus */
    665670        {
    666           if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
    667                 WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
    668           }
    669           //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    670           if(!(fsFocusChange & FC_NOLOSESELECTION)) {
    671                 WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
    672           }
     671      if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
     672            WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
     673      }
     674      //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     675      if(!(fsFocusChange & FC_NOLOSESELECTION)) {
     676            WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
     677      }
    673678          //SvL: Check if window is still valid
    674679          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    675680          if(win32wnd == NULL) {
    676681                return (MRESULT)rc;
    677           } 
     682          }
    678683
    679684          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
    680           if(!(fsFocusChange & FC_NOLOSEACTIVE)) 
     685          if(!(fsFocusChange & FC_NOLOSEACTIVE))
    681686          {
    682687            Win32BaseWindow *topparent = win32wnd->GetTopParent();
    683            
     688
    684689            if(!winfocus || (winfocus->GetTopParent() != topparent))
    685690            {
     
    694699          if(win32wnd == NULL)
    695700            return (MRESULT)rc;
    696  
    697           if(!(fsFocusChange & FC_NOSETACTIVE)) 
     701
     702          if(!(fsFocusChange & FC_NOSETACTIVE))
    698703          {
    699             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent())) 
     704            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    700705            {
    701706              if(winfocus)
     
    707712                  WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    708713              }
    709               else     
     714              else
    710715                WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    711716            }
    712717          }
    713718        }
    714      
    715      
     719
     720
    716721#ifdef DEBUG
    717         SetWin32TIB();
     722        SetWin32TIB();
    718723        dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    719         RestoreOS2TIB();
    720724#endif
    721725        return (MRESULT)rc;
    722726    }
     727#endif
    723728
    724729    //**************************************************************************
     
    728733    {
    729734        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    730                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     735            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    731736        }
    732737        if(win32wnd && win32wnd->IsWindowCreated())
    733738        {
    734           MRESULT rc;
    735 
    736           rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
    737           RestoreOS2TIB();
    738           return rc;
     739            MRESULT rc;
     740
     741            rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
     742            return rc;
    739743        }
    740744        return (MRESULT)HT_NORMAL;
     
    750754    case WM_BUTTON3UP:
    751755    case WM_BUTTON3DBLCLK:
    752         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    753                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    754         }
     756        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     757            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     758        }
    755759        if(win32wnd)
    756                 win32wnd->MsgButton(pWinMsg);
    757         rc = TRUE;
     760            win32wnd->MsgButton(pWinMsg);
     761
     762        rc = (MRESULT)TRUE;
    758763        break;
    759764
     
    767772    case WM_BUTTON3MOTIONEND:
    768773    case WM_BUTTON3CLICK:
    769         rc = TRUE;
     774        rc = (MRESULT)TRUE;
    770775        break;
    771776
    772777    case WM_MOUSEMOVE:
    773778    {
    774         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    775                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    776         }
     779    if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     780        win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     781    }
    777782        if(win32wnd)
    778                 win32wnd->MsgMouseMove(pWinMsg);
     783            win32wnd->MsgMouseMove(pWinMsg);
    779784        break;
    780785    }
     
    808813    case WM_SETWINDOWPARAMS:
    809814    {
    810       WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
     815        WNDPARAMS *wndParams = (WNDPARAMS *)mp1;
    811816
    812817        dprintf(("OS2: WM_SETWINDOWPARAMS %x", hwnd));
     
    833838            wndpars->cbCtlData = 0;
    834839            wndpars->cbPresParams = 0;
    835             RestoreOS2TIB();
    836840            return (MRESULT)TRUE;
    837841        }
     
    844848      BOOL  rc;
    845849
    846         rc = WinQueryUpdateRect(hwnd, &rectl);
     850        rc = WinQueryUpdateRect(hwnd, &rectl);
    847851        dprintf(("OS2: WM_PAINT %x (%d,%d) (%d,%d) rc=%d", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop, rc));
    848852
    849853        if(rc && win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
    850            rectl.yBottom != rectl.yTop)) 
    851         {
    852                 PRECT pClient = win32wnd->getClientRectPtr();
    853                 PRECT pWindow = win32wnd->getWindowRect();
    854 
    855                 if(!(pClient->left == 0 && pClient->top == 0 &&
    856                    win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
    857                    win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
    858                 {
    859                         win32wnd->MsgNCPaint();
    860                 }
    861                 win32wnd->DispatchMsgA(pWinMsg);
    862         }
    863         else    goto RunDefWndProc;
    864 
    865         //SvL: Not calling the default window procedure causes all sorts of
     854           rectl.yBottom != rectl.yTop))
     855        {
     856            PRECT pClient = win32wnd->getClientRectPtr();
     857            PRECT pWindow = win32wnd->getWindowRect();
     858
     859            if(!(pClient->left == 0 && pClient->top == 0 &&
     860               win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
     861               win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
     862            {
     863                win32wnd->MsgNCPaint();
     864            }
     865            win32wnd->DispatchMsgA(pWinMsg);
     866        }
     867        else    goto RunDefWndProc;
     868
     869        //SvL: Not calling the default window procedure causes all sorts of
    866870        //     strange problems (redraw & hanging app)
    867871        //     -> check what WinBeginPaint does what we're forgetting in BeginPaint
    868 //      WinQueryUpdateRect(hwnd, &rectl);
     872//      WinQueryUpdateRect(hwnd, &rectl);
    869873//        if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
    870 //              RestoreOS2TIB();
    871 //              return (MRESULT)FALSE;
    872 //      }
    873 //      dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
    874 //      goto RunDefWndProc;
     874//          RestoreOS2TIB();
     875//          return (MRESULT)FALSE;
     876//  }
     877//  dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
     878//  goto RunDefWndProc;
    875879        break;
    876880    }
     
    879883    {
    880884        dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
    881         RestoreOS2TIB();
    882885        return (MRESULT)FALSE;
    883886    }
     
    888891        win32wnd->DispatchMsgA(pWinMsg);
    889892
    890         RestoreOS2TIB();
    891893        return (MRESULT)TRUE;
    892894    }
     
    898900
    899901        dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
    900         trackInfo->cxBorder = 4;
    901         trackInfo->cyBorder = 4;
    902         win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
    903         RestoreOS2TIB();
    904         return (MRESULT)TRUE;
     902        trackInfo->cxBorder = 4;
     903        trackInfo->cyBorder = 4;
     904        win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
     905        return (MRESULT)TRUE;
    905906    }
    906907
     
    913914      size->x = 0;
    914915      size->y = 0;
    915       RestoreOS2TIB();
    916916      return (MRESULT)TRUE;
    917917    }
     
    927927        dprintf(("OS2: WM_OWNERPOSCHANGE"));
    928928        goto RunDefWndProc;
    929     }
    930 
    931     case WM_FORMATFRAME:
    932         dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
    933 //        goto RunDefWndProc;
    934         break;
    935 
    936     case WM_ADJUSTFRAMEPOS:
    937     {
    938       PSWP pswp   = (PSWP)mp1;
    939 
    940         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));
    941         break;
    942     }
    943 
    944     case WM_QUERYFRAMEINFO:
    945         dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
    946         return (MRESULT)(FI_FRAME|FI_ACTIVATEOK);
    947 
    948     case WM_QUERYFOCUSCHAIN:
    949     {
    950       USHORT fsCmd = SHORT1FROMMP(mp1);
    951 
    952         dprintf(("OS2: WM_QUERYFOCUSCHAIN %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    953 #if 1
    954         goto RunDefWndProc;
    955 #else
    956         switch(fsCmd) {
    957         case QFC_NEXTINCHAIN:
    958                 goto RunDefWndProc;
    959         case QFC_ACTIVE:
    960         case QFC_FRAME:
    961                 if(win32wnd->GetTopParent()) {
    962                         dprintf(("Frame = %x", win32wnd->GetTopParent()->getOS2WindowHandle()));
    963                         return (MRESULT)win32wnd->GetTopParent()->getOS2WindowHandle();
    964                 }
    965                 break;
    966         case QFC_SELECTACTIVE:
    967                 goto RunDefWndProc;
    968         case QFC_PARTOFCHAIN:
    969                 goto RunDefWndProc;
    970         }
    971         break;
    972 #endif
    973929    }
    974930
     
    998954    case WM_SEMANTICEVENT:
    999955    default:
    1000 //        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     956        dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
    1001957        RestoreOS2TIB();
    1002958        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    1003959  }
    1004   RestoreOS2TIB();
    1005960  return (MRESULT)rc;
    1006961
     
    1010965  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    1011966} /* End of Win32WindowProc */
     967//******************************************************************************
     968//******************************************************************************
     969MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     970{
     971 POSTMSG_PACKET  *postmsg;
     972 OSLIBPOINT       point, ClientPoint;
     973 Win32BaseWindow *win32wnd;
     974 TEB             *teb;
     975 MRESULT          rc = 0;
     976 MSG              winMsg, *pWinMsg;
     977
     978    //Restore our FS selector
     979    SetWin32TIB();
     980
     981    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
     982    teb = GetThreadTEB();
     983    win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     984
     985    if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
     986        dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     987        goto RunDefFrameWndProc;
     988    }
     989
     990    if((teb->o.odin.msgstate & 1) == 0)
     991    {//message that was sent directly to our window proc handler; translate it here
     992        QMSG qmsg;
     993
     994        qmsg.msg  = msg;
     995        qmsg.hwnd = hwnd;
     996        qmsg.mp1  = mp1;
     997        qmsg.mp2  = mp2;
     998        qmsg.time = WinQueryMsgTime(teb->o.odin.hab);
     999        WinQueryMsgPos(teb->o.odin.hab, &qmsg.ptl);
     1000        qmsg.reserved = 0;
     1001
     1002        if(OS2ToWinMsgTranslate((PVOID)teb, &qmsg, &winMsg, FALSE, MSG_REMOVE) == FALSE)
     1003        {//message was not translated
     1004            memset(&winMsg, 0, sizeof(MSG));
     1005        }
     1006        pWinMsg = &winMsg;
     1007    }
     1008    else {
     1009        pWinMsg = &teb->o.odin.msg;
     1010        teb->o.odin.msgstate++;
     1011    }
     1012    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
     1013
     1014    switch( msg )
     1015    {
     1016    case WM_CREATE:
     1017    {
     1018        RestoreOS2TIB();
     1019        pfnFrameWndProc(hwnd, msg, mp1, mp2);
     1020        SetWin32TIB();
     1021        rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
     1022        break;
     1023    }
     1024
     1025    case WM_CALCFRAMERECT:
     1026        dprintf(("OS2: WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
     1027        rc = (MRESULT)TRUE;
     1028        break;
     1029
     1030    case WM_QUERYCTLTYPE:
     1031        // This is a frame window
     1032        dprintf(("OS2: WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
     1033        rc = (MRESULT)CCT_FRAME;
     1034        break;
     1035
     1036    case WM_QUERYFOCUSCHAIN:
     1037        dprintf(("OS2: WM_QUERYFOCUSCHAIN %x", win32wnd->getWindowHandle()));
     1038        goto RunDefFrameWndProc;
     1039
     1040    case WM_FOCUSCHANGE:
     1041    {
     1042        HWND   hwndFocus = (HWND)mp1;
     1043        HWND   hwndLoseFocus, hwndGainFocus;
     1044        USHORT usSetFocus = SHORT1FROMMP(mp2);
     1045        USHORT fsFocusChange = SHORT2FROMMP(mp2);
     1046
     1047        dprintf(("OS2: WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     1048        goto RunDefFrameWndProc;
     1049    }
     1050
     1051    case WM_ACTIVATE:
     1052    case WM_SETFOCUS:
     1053    {
     1054        rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
     1055        goto RunDefFrameWndProc;
     1056    }
     1057
     1058#if 0
     1059//just a test
     1060    case WM_ADJUSTWINDOWPOS:
     1061    case WM_WINDOWPOSCHANGED:
     1062    {
     1063        rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
     1064        goto RunDefFrameWndProc;
     1065    }
     1066#endif
     1067
     1068    case WM_QUERYFRAMEINFO:
     1069        dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
     1070        goto RunDefFrameWndProc;
     1071
     1072    case WM_FORMATFRAME:
     1073        dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
     1074        goto RunDefFrameWndProc;
     1075
     1076    case WM_ADJUSTFRAMEPOS:
     1077    {
     1078        PSWP pswp   = (PSWP)mp1;
     1079
     1080        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));
     1081        goto RunDefFrameWndProc;
     1082    }
     1083
     1084    case WM_MINMAXFRAME:
     1085    {
     1086        PSWP swp = (PSWP)mp1;
     1087
     1088        if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
     1089
     1090        dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
     1091        if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
     1092        {
     1093            win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
     1094
     1095            RECT rect;
     1096
     1097            rect.left = rect.top = rect.right = rect.bottom = 0;
     1098            win32wnd->AdjustMaximizedRect(&rect);
     1099            swp->x += rect.left;
     1100            swp->cx += rect.right-rect.left;
     1101            swp->y -= rect.bottom;
     1102            swp->cy += rect.bottom-rect.top;
     1103        }
     1104        else
     1105        if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
     1106        {
     1107            win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
     1108        }
     1109        else
     1110        if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
     1111        {
     1112            win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
     1113        }
     1114        goto RunDefWndProc;
     1115    }
     1116
     1117    case WM_UPDATEFRAME:
     1118        dprintf(("OS2: WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
     1119        goto RunDefFrameWndProc;
     1120
     1121    default:
     1122        rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
     1123        break;
     1124    }
     1125    RestoreOS2TIB();
     1126    return (MRESULT)rc;
     1127
     1128RunDefFrameWndProc:
     1129    RestoreOS2TIB();
     1130    return pfnFrameWndProc(hwnd, msg, mp1, mp2);
     1131
     1132RunDefWndProc:
     1133    RestoreOS2TIB();
     1134    return Win32WindowProc(hwnd, msg, mp1, mp2);
     1135}
    10121136//******************************************************************************
    10131137//TODO: Quickly moving a window two times doesn't force a repaint (1st time)
     
    10221146  LONG      parentHeight, parentWidth;
    10231147
    1024    dprintf(("FrameTrackFrame: %x %x", win32wnd->getWindowHandle(), flags));
    1025    track.cxBorder = 4;
    1026    track.cyBorder = 4;  /* 4 pel wide lines used for rectangle */
    1027    track.cxGrid = 1;
    1028    track.cyGrid = 1;    /* smooth tracking with mouse */
    1029    track.cxKeyboard = 8;
    1030    track.cyKeyboard = 8; /* faster tracking using cursor keys */
    1031 
    1032    pWindowRect = win32wnd->getWindowRect();
    1033    if(win32wnd->getParent()) {
    1034         parentHeight = win32wnd->getParent()->getWindowHeight();
    1035         parentWidth  = win32wnd->getParent()->getWindowWidth();
    1036         hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
    1037         hpsTrack     = WinGetPS(hwndTracking); 
     1148    dprintf(("FrameTrackFrame: %x %x", win32wnd->getWindowHandle(), flags));
     1149    track.cxBorder = 4;
     1150    track.cyBorder = 4;  /* 4 pel wide lines used for rectangle */
     1151    track.cxGrid = 1;
     1152    track.cyGrid = 1;    /* smooth tracking with mouse */
     1153    track.cxKeyboard = 8;
     1154    track.cyKeyboard = 8; /* faster tracking using cursor keys */
     1155
     1156    pWindowRect = win32wnd->getWindowRect();
     1157    if(win32wnd->getParent()) {
     1158        parentHeight = win32wnd->getParent()->getWindowHeight();
     1159        parentWidth  = win32wnd->getParent()->getWindowWidth();
     1160        hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
     1161        hpsTrack     = WinGetPS(hwndTracking);
     1162    }
     1163    else {
     1164        parentHeight = OSLibQueryScreenHeight();
     1165        parentWidth  = OSLibQueryScreenWidth();
     1166        hwndTracking = HWND_DESKTOP;
     1167        hpsTrack     = NULL;
     1168    }
     1169
     1170    mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
     1171    WinQueryWindowRect(hwndTracking, &track.rclBoundary);
     1172
     1173    track.ptlMinTrackSize.x = 10;
     1174    track.ptlMinTrackSize.y = 10;  /* set smallest allowed size of rectangle */
     1175    track.ptlMaxTrackSize.x = parentWidth;
     1176    track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
     1177
     1178    win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
     1179
     1180    track.fs = flags;
     1181
     1182    if(WinTrackRect(hwndTracking, NULL, &track) )
     1183    {
     1184        if(hpsTrack)    WinReleasePS(hpsTrack);
     1185
     1186        /* if successful copy final position back */
     1187        if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
     1188            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));
     1189        if(flags == TF_MOVE) {
     1190            WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     1191                                        0, track.rclTrack.xLeft, track.rclTrack.yBottom,
     1192                                        0, 0, SWP_MOVE);
     1193        }
     1194        else {
     1195            WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     1196                                        0, track.rclTrack.xLeft, track.rclTrack.yBottom,
     1197                                        track.rclTrack.xRight - track.rclTrack.xLeft,
     1198                                        track.rclTrack.yTop - track.rclTrack.yBottom,
     1199                                        SWP_SIZE|SWP_MOVE);
     1200        }
     1201        }
     1202        return;
    10381203   }
    1039    else {
    1040         parentHeight = OSLibQueryScreenHeight();
    1041         parentWidth  = OSLibQueryScreenWidth();
    1042         hwndTracking = HWND_DESKTOP;
    1043         hpsTrack     = NULL;
    1044    }
    1045 
    1046    mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
    1047    WinQueryWindowRect(hwndTracking, &track.rclBoundary);
    1048 
    1049    track.ptlMinTrackSize.x = 10;
    1050    track.ptlMinTrackSize.y = 10;  /* set smallest allowed size of rectangle */
    1051    track.ptlMaxTrackSize.x = parentWidth;
    1052    track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
    1053 
    1054    win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
    1055  
    1056    track.fs = flags;
    1057  
    1058    if(WinTrackRect(hwndTracking, NULL, &track) )
    1059    {
    1060         if(hpsTrack)    WinReleasePS(hpsTrack);
    1061 
    1062         /* if successful copy final position back */
    1063         if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
    1064                 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));
    1065                 if(flags == TF_MOVE) {
    1066                         WinSetWindowPos(win32wnd->getOS2WindowHandle(),
    1067                                         0, track.rclTrack.xLeft, track.rclTrack.yBottom,
    1068                                         0, 0, SWP_MOVE);
    1069                 }
    1070                 else {
    1071                         WinSetWindowPos(win32wnd->getOS2WindowHandle(),
    1072                                         0, track.rclTrack.xLeft, track.rclTrack.yBottom,
    1073                                         track.rclTrack.xRight - track.rclTrack.xLeft,
    1074                                         track.rclTrack.yTop - track.rclTrack.yBottom,
    1075                                         SWP_SIZE|SWP_MOVE);
    1076                 }
    1077         }
    1078         return;
    1079    }
    1080    if(hpsTrack) WinReleasePS(hpsTrack);
     1204   if(hpsTrack) WinReleasePS(hpsTrack);
    10811205   return;
    10821206}
Note: See TracChangeset for help on using the changeset viewer.