Changeset 5246 for trunk/src


Ignore:
Timestamp:
Feb 22, 2001, 7:18:59 PM (25 years ago)
Author:
sandervl
Message:

minimize updates + update region fix in NotifyFrameChanged

Location:
trunk/src/user32
Files:
4 edited

Legend:

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

    r5215 r5246  
    1 /* $Id: dc.cpp,v 1.91 2001-02-20 15:40:22 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.92 2001-02-22 18:18:59 sandervl Exp $ */
    22
    33/*
     
    515515
    516516//testestest
     517#if 0
    517518   GpiQueryViewingLimits(pHps->hps, &rectWindowOS2);
    518519   dprintf2(("view limits (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));
     
    531532   GpiQueryPickApertureSize(pHps->hps, &size);
    532533   dprintf2(("page viewport (%d,%d)", size.cx, size.cy));
     534
     535   GpiQueryPS(pHps->hps, &size);
     536   dprintf2(("page space (%d,%d)", size.cx, size.cy));
     537#endif
    533538//testestest
    534539
     
    12911296         pr->yTop = height - pr->yBottom;
    12921297         pr->yBottom = height - temp;
     1298         dprintf2(("Invalid region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop));
    12931299      }
    12941300
  • trunk/src/user32/pmwindow.cpp

    r5217 r5246  
    1 /* $Id: pmwindow.cpp,v 1.118 2001-02-20 17:22:05 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.119 2001-02-22 18:18:59 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    4444#include "dbglocal.h"
    4545
     46//define this to use the new code for WM_CALCVALIDRECT handling
     47//#define USE_CALCVALIDRECT
     48
    4649HMQ  hmq = 0;                             /* Message queue handle         */
    4750HAB  hab = 0;
     
    438441        }
    439442
    440         if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
     443#ifndef USE_CALCVALIDRECT
     444        if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
    441445        {
    442446            //CB: todo: use result for WM_CALCVALIDRECTS
     
    513517        else
    514518        {
     519#endif //USE_CALCVALIDRECT
    515520            if(win32wnd->CanReceiveSizeMsgs())
    516521                win32wnd->MsgPosChanged((LPARAM)&wp);
    517         }
     522#ifndef USE_CALCVALIDRECT
     523        }
     524#endif
    518525
    519526        if(pswp->fl & SWP_ACTIVATE)
     
    568575
    569576    case WM_CALCVALIDRECTS:
     577#ifdef USE_CALCVALIDRECT
     578    {
     579        PRECTL    oldRect = (PRECTL)mp1, newRect = oldRect+1;
     580        PSWP      pswp = (PSWP)mp2;
     581        SWP       swpOld;
     582        WINDOWPOS wp;
     583        RECTL     newClientrect, oldClientRect;
     584        ULONG     nccalcret;
     585//        UINT      res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
     586        UINT      res = 0;
     587
     588        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     589
     590        //Get old position info
     591        WinQueryWindowPos(hwnd, &swpOld);
     592
     593        if(win32wnd->getParent()) {
     594             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     595                                    win32wnd->getParent()->getClientRectPtr()->left,
     596                                    win32wnd->getParent()->getClientRectPtr()->top,
     597                                    hwnd);
     598        }
     599        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     600
     601        wp.hwnd = win32wnd->getWindowHandle();
     602        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     603        {
     604            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     605            if(wndAfter) {
     606                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     607            }
     608            else wp.hwndInsertAfter = HWND_TOP_W;
     609        }
     610
     611        //Get old client rectangle
     612        mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
     613
     614        //Note: Also updates the new window rectangle
     615        nccalcret = win32wnd->MsgFormatFrame(&wp);
     616
     617        //Get new client rectangle
     618        mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientrect);
     619
     620        if(nccalcret == 0) {
     621            res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
     622        }
     623        else {
     624            if(nccalcret & WVR_ALIGNTOP_W) {
     625                res |= CVR_ALIGNTOP;
     626            }
     627            else
     628            if(nccalcret & WVR_ALIGNBOTTOM_W) {
     629                res |= CVR_ALIGNBOTTOM;
     630            }
     631
     632            if(nccalcret & WVR_ALIGNLEFT_W) {
     633                res |= CVR_ALIGNLEFT;
     634            }
     635            else
     636            if(nccalcret & WVR_ALIGNRIGHT_W) {
     637                res |= CVR_ALIGNRIGHT;
     638            }
     639
     640            if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
     641                res |= CVR_REDRAW;
     642            }
     643            else
     644            if(nccalcret & WVR_VALIDRECTS_W) {
     645                //TODO:
     646                //res = 0;
     647            }
     648        }
     649        if(res != 0) {
     650
     651        }
     652
    570653#if 0
    571     {
    572       PRECTL oldRect = (PRECTL)mp1,newRect = oldRect+1;
    573       UINT res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
    574 
    575 //CB: todo: use WM_NCCALCSIZE result
    576       if (win32wnd->getWindowClass())
    577       {
    578         DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    579 
    580         if ((dwStyle & CS_HREDRAW_W) && (newRect->xRight-newRect->xLeft != oldRect->xRight-oldRect->xLeft))
    581             res |= CVR_REDRAW;
    582         else
    583         if ((dwStyle & CS_VREDRAW_W) && (newRect->yTop-newRect->yBottom != oldRect->yTop-oldRect->yBottom))
    584             res |= CVR_REDRAW;
    585       }
    586       else res |= CVR_REDRAW;
    587 
    588       return (MRESULT)res;
     654            if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
     655            {
     656                //redraw the frame (to prevent unnecessary client updates)
     657                BOOL redrawAll = FALSE;
     658
     659                if (win32wnd->getWindowClass())
     660                {
     661                    DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
     662
     663                    if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
     664                        redrawAll = TRUE;
     665                    else
     666                    if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
     667                        redrawAll = TRUE;
     668                }
     669                else redrawAll = TRUE;
     670
     671                if (redrawAll)
     672                {
     673                    //CB: redraw all children for now
     674                    //    -> problems with update region if we don't do it
     675                    //       todo: rewrite whole handling
     676                    WinInvalidateRect(hwnd,NULL,TRUE);
     677                }
     678                else
     679                {
     680                    HPS hps = WinGetPS(hwnd);
     681                    RECTL frame,client,arcl[4];
     682
     683                    WinQueryWindowRect(hwnd,&frame);
     684
     685                    //top
     686                    arcl[0].xLeft = 0;
     687                    arcl[0].xRight = frame.xRight;
     688                    arcl[0].yBottom = rect.yTop;
     689                    arcl[0].yTop = frame.yTop;
     690                    //right
     691                    arcl[1].xLeft = rect.xRight;
     692                    arcl[1].xRight = frame.xRight;
     693                    arcl[1].yBottom = 0;
     694                    arcl[1].yTop = frame.yTop;
     695                    //left
     696                    arcl[2].xLeft = 0;
     697                    arcl[2].xRight = rect.xLeft;
     698                    arcl[2].yBottom = 0;
     699                    arcl[2].yTop = frame.yTop;
     700                    //bottom
     701                    arcl[3].xLeft = 0;
     702                    arcl[3].xRight = frame.xRight;
     703                    arcl[3].yBottom = 0;
     704                    arcl[3].yTop = rect.yBottom;
     705
     706                    HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
     707
     708                    WinInvalidateRegion(hwnd,hrgn,FALSE);
     709                    GpiDestroyRegion(hps,hrgn);
     710                    WinReleasePS(hps);
     711                }
     712            }
     713
     714        }
     715#endif
     716
     717        return (MRESULT)res;
    589718    }
    590719#else
  • trunk/src/user32/win32wbase.cpp

    r5242 r5246  
    1 /* $Id: win32wbase.cpp,v 1.242 2001-02-22 10:37:31 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.243 2001-02-22 18:18:59 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    21802180 BOOL  rc,wasVisible,showFlag;
    21812181 RECT  newPos = {0, 0, 0, 0};
    2182  BOOL  fInvalidate = FALSE;
    21832182
    21842183    dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
     
    22002199        /* fall through */
    22012200    case SW_MINIMIZE:
    2202 //testesteest
    22032201        if(!(getStyle() & WS_CHILD))
    22042202        {
     
    22122210            if( !(getStyle() & WS_MINIMIZE) ) {
    22132211                 swp |= MinMaximize(SW_MINIMIZE, &newPos );
    2214                  fInvalidate = TRUE;
    22152212            }
    22162213            else swp |= SWP_NOSIZE | SWP_NOMOVE;
    22172214        }
    2218 //testesteest
    22192215        break;
    22202216
     
    22532249         swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
    22542250
    2255          if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) )
     2251         if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) ) {
    22562252              swp |= MinMaximize(SW_RESTORE, &newPos );
     2253         }
    22572254         else swp |= SWP_NOSIZE | SWP_NOMOVE;
    22582255         break;
     
    22922289                              rectClient.bottom-rectClient.top));
    22932290        SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
    2294     }
    2295     if(fInvalidate) {
    2296         InvalidateRect(getWindowHandle(), NULL, 1);
    22972291    }
    22982292END:
     
    25192513    else SendInternalMessageA(WM_WINDOWPOSCHANGED, 0, (LPARAM)wpos);
    25202514
     2515    //Calculate invalid areas
    25212516    rect = rectWindow;
    25222517    OffsetRect(&rect, -rectWindow.left, -rectWindow.top);
     
    25272522    }
    25282523    rect = rectClient;
    2529     OffsetRect(&rect, -rectClient.left, -rectClient.top);
    25302524    hrgnClient = CreateRectRgnIndirect(&rect);
    25312525    if (!hrgn) {
     
    25382532    if(!EqualRect(oldClientRect, &rectClient)) {
    25392533         UnionRect(oldClientRect, oldClientRect, &rectClient);
    2540          OffsetRect(oldClientRect, -rectClient.left, -rectClient.top);
    25412534         hrgnClient = CreateRectRgnIndirect(oldClientRect);
    25422535         if (!hrgn) {
     
    25472540         DeleteObject(hrgnClient);
    25482541    }
    2549     InvalidateRgn(getWindowHandle(), hrgn, TRUE);
     2542    RedrawWindow(getWindowHandle(), NULL, hrgn, RDW_ALLCHILDREN |
     2543                 RDW_INVALIDATE | RDW_ERASE | RDW_FRAME);
    25502544    DeleteObject(hrgn);
    25512545}
  • trunk/src/user32/win32wbasepos.cpp

    r5236 r5246  
    1 /* $Id: win32wbasepos.cpp,v 1.20 2001-02-21 20:51:07 sandervl Exp $ */
     1/* $Id: win32wbasepos.cpp,v 1.21 2001-02-22 18:18:59 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (nonclient/position methods)
     
    155155   if((winpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
    156156   {
    157     params.rgrc[0] = *newWindowRect;
    158     if(calcValidRect)
    159     {
     157        params.rgrc[0] = *newWindowRect;
     158        if(calcValidRect)
     159        {
    160160            winposCopy = *winpos;
    161161            params.rgrc[1] = *oldWindowRect;
     
    165165
    166166            params.lppos = &winposCopy;
    167     }
    168     result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
    169 
    170     /* If the application send back garbage, ignore it */
    171     if(params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
    172     {
     167        }
     168        result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
     169
     170        /* If the application send back garbage, ignore it */
     171        if(params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
     172        {
    173173            *newClientRect = params.rgrc[0];
    174174            //client rectangle now in parent coordinates; convert to 'frame' coordinates
    175175            OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
    176     }
     176        }
    177177
    178178        /* FIXME: WVR_ALIGNxxx */
     
    211211    return 0;
    212212}
     213/***********************************************************************
     214 *           WINPOS_FindIconPos
     215 *
     216 * Find a suitable place for an iconic window.
     217 */
     218static void WINPOS_FindIconPos( HWND hwnd, POINT &pt )
     219{
     220    RECT rectParent;
     221    int  x, y, xspacing, yspacing;
     222    HWND hwndChild, hwndParent;
     223
     224    hwndParent = GetParent(hwnd);
     225    if(hwndParent == 0) {
     226        DebugInt3();
     227        return;
     228    }
     229
     230    GetClientRect(hwndParent, &rectParent );
     231    if ((pt.x >= rectParent.left) && (pt.x + GetSystemMetrics(SM_CXICON) < rectParent.right) &&
     232        (pt.y >= rectParent.top) && (pt.y + GetSystemMetrics(SM_CYICON) < rectParent.bottom))
     233        return;  /* The icon already has a suitable position */
     234
     235    xspacing = GetSystemMetrics(SM_CXICONSPACING);
     236    yspacing = GetSystemMetrics(SM_CYICONSPACING);
     237
     238    y = rectParent.bottom;
     239    for (;;)
     240    {
     241        x = rectParent.left;
     242        do
     243        {
     244            /* Check if another icon already occupies this spot */
     245            hwndChild = GetWindow(hwndParent, GW_CHILD);
     246
     247            while(hwndChild)
     248            {
     249                Win32BaseWindow *child = NULL;
     250                RECT *pRectWindow;
     251
     252                child = Win32BaseWindow::GetWindowFromHandle(hwndChild);
     253                if(!child) {
     254                    dprintf(("ERROR: WINPOS_FindIconPos, child %x not found", hwndChild));
     255                    return;
     256                }
     257                if ((child->getStyle() & WS_MINIMIZE) && (child->getWindowHandle() != hwnd))
     258                {
     259                    pRectWindow = child->getWindowRect();
     260                    if ((pRectWindow->left   < x + xspacing) &&
     261                        (pRectWindow->right  >= x) &&
     262                        (pRectWindow->top    <= y) &&
     263                        (pRectWindow->bottom > y - yspacing))
     264                        break;  /* There's a window in there */
     265                }
     266                hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
     267            }
     268
     269            if (!hwndChild) /* No window was found, so it's OK for us */
     270            {
     271                        pt.x = x + (xspacing - GetSystemMetrics(SM_CXICON)) / 2;
     272                        pt.y = y - (yspacing + GetSystemMetrics(SM_CYICON)) / 2;
     273                        return;
     274            }
     275                x += xspacing;
     276        } while(x <= rectParent.right-xspacing);
     277
     278        y -= yspacing;
     279    }
     280}
    213281/******************************************************************************
    214282 *           WINPOS_MinMaximize
     
    221289{
    222290    UINT swpFlags = 0;
    223     POINT size;
     291    POINT size, iconPos;
    224292
    225293    size.x = rectWindow.left;
     
    248316            setStyle(getStyle() | WS_MINIMIZE);
    249317
    250             SetRect(lpRect, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
    251                     GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
     318            iconPos.x = windowpos.ptMinPosition.x;
     319            iconPos.y = windowpos.ptMinPosition.y;
     320            WINPOS_FindIconPos(getWindowHandle(), iconPos);
     321            SetRect(lpRect, iconPos.x, iconPos.y, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
    252322            break;
    253323
Note: See TracChangeset for help on using the changeset viewer.