Ignore:
Timestamp:
Feb 20, 2001, 6:22:06 PM (25 years ago)
Author:
sandervl
Message:

MDI activation fixes

File:
1 edited

Legend:

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

    r5189 r5217  
    1 /* $Id: pmwindow.cpp,v 1.117 2001-02-19 10:15:52 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.118 2001-02-20 17:22:05 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    286286        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));
    287287
    288         if(win32wnd->getParent() && win32wnd->getParent()->isOwnDC()) {
    289             dprintfOrigin(win32wnd->getParent()->getOwnDC());
    290             selectClientArea(win32wnd->getParent(), win32wnd->getParent()->getOwnDC());
    291         }
    292 
    293288        if(pswp->fl & SWP_NOADJUST) {
    294289            //ignore weird messages (TODO: why are they sent?)
     
    387382      WINDOWPOS wp;
    388383      HWND      hParent = NULLHANDLE;
    389       RECTL rect;
     384      RECTL     rect;
    390385
    391386        dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     
    396391            {
    397392                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    398                 if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
     393                if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
    399394                {
    400395                        WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     396                }
     397            }
     398            else
     399            if(pswp->fl & SWP_DEACTIVATE)
     400            {
     401                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     402                if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
     403                {
     404                        WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
    401405                }
    402406            }
     
    417421
    418422        if(win32wnd->getParent()) {
    419           OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    420                                      win32wnd->getParent()->getClientRectPtr()->left,
    421                                      win32wnd->getParent()->getClientRectPtr()->top,
    422                                      hwnd);
    423         }
    424         else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     423             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     424                                    win32wnd->getParent()->getClientRectPtr()->left,
     425                                    win32wnd->getParent()->getClientRectPtr()->top,
     426                                    hwnd);
     427        }
     428        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    425429
    426430        wp.hwnd = win32wnd->getWindowHandle();
    427431        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    428432        {
    429            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    430            if(wndAfter) {
    431                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
    432            }
    433            else wp.hwndInsertAfter = HWND_TOP_W;
     433            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     434            if(wndAfter) {
     435                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     436            }
     437            else wp.hwndInsertAfter = HWND_TOP_W;
    434438        }
    435439
    436440        if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
    437441        {
    438           //CB: todo: use result for WM_CALCVALIDRECTS
    439           //Get old client rectangle (for invalidation of frame window parts later on)
    440           //Use new window height to calculate the client area
    441           mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
    442 
    443           //Note: Also updates the new window rectangle
    444           win32wnd->MsgFormatFrame(&wp);
    445 
    446           if(win32wnd->CanReceiveSizeMsgs())
    447             win32wnd->MsgPosChanged((LPARAM)&wp);
    448 
    449           if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
    450           {
    451             //redraw the frame (to prevent unnecessary client updates)
    452             BOOL redrawAll = FALSE;
    453 
    454             if (win32wnd->getWindowClass())
     442            //CB: todo: use result for WM_CALCVALIDRECTS
     443            //Get old client rectangle (for invalidation of frame window parts later on)
     444            //Use new window height to calculate the client area
     445            mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
     446
     447            //Note: Also updates the new window rectangle
     448            win32wnd->MsgFormatFrame(&wp);
     449
     450            if(win32wnd->CanReceiveSizeMsgs())
     451                win32wnd->MsgPosChanged((LPARAM)&wp);
     452
     453            if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
    455454            {
    456               DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    457 
    458               if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
    459                 redrawAll = TRUE;
    460               else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
    461                 redrawAll = TRUE;
    462             } else redrawAll = TRUE;
    463 
    464             if (redrawAll)
    465             {
    466               //CB: redraw all children for now
    467               //    -> problems with update region if we don't do it
    468               //       todo: rewrite whole handling
    469               WinInvalidateRect(hwnd,NULL,TRUE);
    470             }
    471             else
    472             {
    473               HPS hps = WinGetPS(hwnd);
    474               RECTL frame,client,arcl[4];
    475 
    476               WinQueryWindowRect(hwnd,&frame);
    477 
    478                //top
    479               arcl[0].xLeft = 0;
    480               arcl[0].xRight = frame.xRight;
    481               arcl[0].yBottom = rect.yTop;
    482               arcl[0].yTop = frame.yTop;
    483                //right
    484               arcl[1].xLeft = rect.xRight;
    485               arcl[1].xRight = frame.xRight;
    486               arcl[1].yBottom = 0;
    487               arcl[1].yTop = frame.yTop;
    488                //left
    489               arcl[2].xLeft = 0;
    490               arcl[2].xRight = rect.xLeft;
    491               arcl[2].yBottom = 0;
    492               arcl[2].yTop = frame.yTop;
    493                //bottom
    494               arcl[3].xLeft = 0;
    495               arcl[3].xRight = frame.xRight;
    496               arcl[3].yBottom = 0;
    497               arcl[3].yTop = rect.yBottom;
    498 
    499               HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
    500 
    501               WinInvalidateRegion(hwnd,hrgn,FALSE);
    502               GpiDestroyRegion(hps,hrgn);
    503               WinReleasePS(hps);
    504             }
    505           }
    506         }
    507         else
    508         {
    509           if(win32wnd->CanReceiveSizeMsgs())
    510             win32wnd->MsgPosChanged((LPARAM)&wp);
    511         }
    512 
    513         if(pswp->fl & SWP_ACTIVATE)
    514         {
    515              //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    516              if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & FF_ACTIVE))
    517              {
    518                 if(isFrame) {
    519                      WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     455                //redraw the frame (to prevent unnecessary client updates)
     456                BOOL redrawAll = FALSE;
     457
     458                if (win32wnd->getWindowClass())
     459                {
     460                    DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
     461
     462                    if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
     463                        redrawAll = TRUE;
     464                    else
     465                    if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
     466                        redrawAll = TRUE;
     467                }
     468                else redrawAll = TRUE;
     469
     470                if (redrawAll)
     471                {
     472                    //CB: redraw all children for now
     473                    //    -> problems with update region if we don't do it
     474                    //       todo: rewrite whole handling
     475                    WinInvalidateRect(hwnd,NULL,TRUE);
    520476                }
    521477                else
    522                 if(win32wnd->IsWindowCreated()) {
    523                     win32wnd->MsgActivate(1, 0, win32wnd->getWindowHandle(), hwnd);
     478                {
     479                    HPS hps = WinGetPS(hwnd);
     480                    RECTL frame,client,arcl[4];
     481
     482                    WinQueryWindowRect(hwnd,&frame);
     483
     484                    //top
     485                    arcl[0].xLeft = 0;
     486                    arcl[0].xRight = frame.xRight;
     487                    arcl[0].yBottom = rect.yTop;
     488                    arcl[0].yTop = frame.yTop;
     489                    //right
     490                    arcl[1].xLeft = rect.xRight;
     491                    arcl[1].xRight = frame.xRight;
     492                    arcl[1].yBottom = 0;
     493                    arcl[1].yTop = frame.yTop;
     494                    //left
     495                    arcl[2].xLeft = 0;
     496                    arcl[2].xRight = rect.xLeft;
     497                    arcl[2].yBottom = 0;
     498                    arcl[2].yTop = frame.yTop;
     499                    //bottom
     500                    arcl[3].xLeft = 0;
     501                    arcl[3].xRight = frame.xRight;
     502                    arcl[3].yBottom = 0;
     503                    arcl[3].yTop = rect.yBottom;
     504
     505                    HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
     506
     507                    WinInvalidateRegion(hwnd,hrgn,FALSE);
     508                    GpiDestroyRegion(hps,hrgn);
     509                    WinReleasePS(hps);
    524510                }
     511            }
     512        }
     513        else
     514        {
     515            if(win32wnd->CanReceiveSizeMsgs())
     516                win32wnd->MsgPosChanged((LPARAM)&wp);
     517        }
     518
     519        if(pswp->fl & SWP_ACTIVATE)
     520        {
     521             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     522             if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
     523             {
     524                WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    525525             }
     526        }
     527        else
     528        if(pswp->fl & SWP_DEACTIVATE)
     529        {
     530            //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     531            if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
     532            {
     533                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
     534            }
    526535        }
    527536
     
    532541    case WM_ACTIVATE:
    533542    {
    534         USHORT flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
     543        ULONG flags = WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS);
    535544
    536545        dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
    537546
    538         WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
     547        WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
    539548        if(win32wnd->IsWindowCreated())
    540549        {
     
    604613                break;
    605614        }
    606 //test
     615        //Restore window origin of window with CS_OWNDC style
     616        //(fixes paint offset problems in Opera windows)
    607617        if(win32wnd->isOwnDC()) {
    608618                dprintfOrigin(win32wnd->getOwnDC());
    609619                selectClientArea(win32wnd, win32wnd->getOwnDC());
    610620        }
    611 //test
    612621        goto RunDefWndProc;
    613622
Note: See TracChangeset for help on using the changeset viewer.