Changeset 5217 for trunk/src


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

MDI activation fixes

Location:
trunk/src/user32
Files:
5 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
  • trunk/src/user32/win32wbase.cpp

    r5215 r5217  
    1 /* $Id: win32wbase.cpp,v 1.238 2001-02-20 15:40:22 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.239 2001-02-20 17:22:05 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    925925        return 0;
    926926    }
    927     /* child windows get WM_CHILDACTIVATE message */
     927    /* child windows get a WM_CHILDACTIVATE message */
    928928    if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
    929929    {
    930         SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
     930        if(fActivate) {//WM_CHILDACTIVE is for activation only
     931            SendInternalMessageA(WM_CHILDACTIVATE, 0, 0L);
     932        }
    931933        return 0;
    932934    }
     
    24292431    }
    24302432
    2431 //testestest
     2433    //Restore window origin of parent window with CS_OWNDC style
     2434    //(fixes paint offset problems in Opera windows)
    24322435    if(getParent() && getParent()->isOwnDC()) {
    24332436        dprintfOrigin(getParent()->getOwnDC());
    24342437        selectClientArea(getParent(), getParent()->getOwnDC());
    24352438    }
    2436 //testestest
    24372439
    24382440    if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
     
    31143116    hwndActive = GetActiveWindow();
    31153117    return (hwndActive) ? hwndActive : windowDesktop->getWindowHandle(); //pretend the desktop was active
     3118}
     3119//******************************************************************************
     3120//Used to change active status of an mdi window
     3121//******************************************************************************
     3122BOOL Win32BaseWindow::DeactivateChildWindow()
     3123{
     3124    /* child windows get a WM_CHILDACTIVATE message */
     3125    if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
     3126    {
     3127        ULONG flags = OSLibWinGetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS);
     3128        OSLibWinSetWindowULong(getOS2WindowHandle(), OFFSET_WIN32FLAGS, (flags & ~WINDOWFLAG_ACTIVE));
     3129        return TRUE;
     3130    }
     3131    DebugInt3();    //should not be called for non-child window
     3132    return FALSE;
    31163133}
    31173134//******************************************************************************
  • trunk/src/user32/win32wbase.h

    r5215 r5217  
    1 /* $Id: win32wbase.h,v 1.107 2001-02-20 15:40:23 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.108 2001-02-20 17:22:05 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    2929#define OFFSET_WIN32FLAGS         8
    3030#define NROF_WIN32WNDBYTES        12
     31
     32#define WINDOWFLAG_ACTIVE         1
    3133
    3234#define WIN32PM_MAGIC           0x12345678
     
    225227         BOOL   DestroyWindow();
    226228         HWND   SetActiveWindow();
     229         BOOL   DeactivateChildWindow();
    227230         HWND   GetParent();
    228231         HWND   SetParent(HWND hwndNewParent);
  • trunk/src/user32/win32wbasenonclient.cpp

    r5215 r5217  
    1 /* $Id: win32wbasenonclient.cpp,v 1.27 2001-02-20 15:40:23 sandervl Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.28 2001-02-20 17:22:06 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    335335VOID Win32BaseWindow::AdjustMaximizedRect(LPRECT rect)
    336336{
    337   if (HAS_THICKFRAME(dwStyle,dwExStyle ))
    338     InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
    339   else
     337    if (HAS_THICKFRAME(dwStyle,dwExStyle ))
     338        InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
     339    else
    340340    if (HAS_DLGFRAME( dwStyle, dwExStyle ))
    341       InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
     341        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
    342342    else
    343       if (HAS_THINFRAME( dwStyle ))
     343    if (HAS_THINFRAME( dwStyle ))
    344344        InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
    345345}
     
    348348VOID Win32BaseWindow::AdjustTrackInfo(PPOINT minTrackSize,PPOINT maxTrackSize)
    349349{
    350   if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
    351     GetMinMaxInfo(NULL,NULL,minTrackSize,maxTrackSize);
     350    if ((dwStyle & WS_THICKFRAME) || !(dwStyle & (WS_POPUP | WS_CHILD)))
     351        GetMinMaxInfo(NULL,NULL,minTrackSize,maxTrackSize);
    352352}
    353353//******************************************************************************
     
    355355VOID Win32BaseWindow::AdjustRectOuter(LPRECT rect,BOOL menu)
    356356{
    357   if(dwStyle & WS_ICONIC) return;
    358 
    359   if (HAS_THICKFRAME(dwStyle,dwExStyle ))
    360     InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
    361   else
     357    if(dwStyle & WS_ICONIC) return;
     358
     359    if (HAS_THICKFRAME(dwStyle,dwExStyle ))
     360        InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
     361    else
    362362    if (HAS_DLGFRAME( dwStyle, dwExStyle ))
    363       InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
     363        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
    364364    else
    365       if (HAS_THINFRAME( dwStyle ))
     365    if (HAS_THINFRAME( dwStyle ))
    366366        InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
    367367
    368   if ((dwStyle & WS_CAPTION) == WS_CAPTION)
    369   {
    370     if (dwExStyle & WS_EX_TOOLWINDOW)
    371       rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
    372     else
    373       rect->top -= GetSystemMetrics(SM_CYCAPTION);
    374   }
    375 
    376   if (menu)
    377     rect->top -= GetSystemMetrics(SM_CYMENU);
     368    if ((dwStyle & WS_CAPTION) == WS_CAPTION)
     369    {
     370        if (dwExStyle & WS_EX_TOOLWINDOW)
     371            rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
     372        else
     373            rect->top -= GetSystemMetrics(SM_CYCAPTION);
     374    }
     375
     376    if (menu)
     377        rect->top -= GetSystemMetrics(SM_CYMENU);
    378378}
    379379//******************************************************************************
     
    685685            GetInsideRect(rect );
    686686            OffsetRect( rect, rectWindow.left, rectWindow.top);
    687                 if(getStyle() & WS_CHILD)
    688                 ClientToScreen(getParent()->getWindowHandle(), (POINT *)rect);
     687            if(getStyle() & WS_CHILD)
     688                ClientToScreen(getParent()->getWindowHandle(), (POINT *)rect);
    689689
    690690            rect->right = rect->left + GetSystemMetrics(SM_CYCAPTION) - 1;
  • trunk/src/user32/win32wmdiclient.cpp

    r4839 r5217  
    1 /* $Id: win32wmdiclient.cpp,v 1.32 2000-12-24 14:54:07 sandervl Exp $ */
     1/* $Id: win32wmdiclient.cpp,v 1.33 2001-02-20 17:22:06 sandervl Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    346346    {
    347347        prevActive->setStyle(prevActive->getStyle() | WS_SYSMENU);
     348        prevActive->DeactivateChildWindow();
    348349        prevActive->SendInternalMessageA( WM_NCACTIVATE, FALSE, 0L );
    349350        prevActive->SendInternalMessageA( WM_MDIACTIVATE, (WPARAM)prevActive->getWindowHandle(), (LPARAM)(child) ? child->getWindowHandle() : 0);
Note: See TracChangeset for help on using the changeset viewer.