Ignore:
Timestamp:
Jun 29, 2000, 2:26:01 PM (25 years ago)
Author:
sandervl
Message:

activation fixes

File:
1 edited

Legend:

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

    r3708 r3773  
    1 /* $Id: pmwindow.cpp,v 1.95 2000-06-14 14:25:57 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.96 2000-06-29 12:26:00 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    5353MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    5454
    55 PFNWP PMFrameWindowProc = 0;
    56 
    5755//******************************************************************************
    5856//Initialize PM; create hab, message queue and register special Win32 window classes
     
    111109  dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
    112110
    113   PMFrameWindowProc = FrameClassInfo.pfnWindowProc;
    114111  if(!WinRegisterClass(                 /* Register window class        */
    115112     hab,                               /* Anchor block handle          */
     
    200197    case WM_CREATE:
    201198    {
    202         RestoreOS2TIB();
    203         PMFrameWindowProc(hwnd, msg, mp1, mp2);
    204         SetWin32TIB();
    205 
    206199        if(thdb->newWindow == 0)
    207200            goto createfail;
     
    235228        win32wnd->MsgDestroy();
    236229        WinSetVisibleRegionNotify(hwnd, FALSE);
    237         goto RunDefFrameProc;
     230        goto RunDefWndProc;
    238231
    239232    case WM_ENABLE:
     
    344337        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    345338        {
     339                if(pswp->fl & SWP_ACTIVATE)
     340                {
     341                        WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     342                }
    346343                goto RunDefWndProc;
    347344        }
     
    364361        }
    365362        else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     363
     364        if(pswp->fl & SWP_ACTIVATE)
     365        {
     366             WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     367        }
    366368
    367369        if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
     
    477479      PSWP swp = (PSWP)mp1;
    478480
    479       if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
     481      if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
     482
    480483      dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
    481484      if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
     
    500503        win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
    501504      }
    502       goto RunDefFrameProc;
    503     }
    504 
    505     case WM_OWNERPOSCHANGE:
    506     {
    507         dprintf(("OS2: WM_OWNERPOSCHANGE"));
    508         goto RunDefWndProc;
     505      goto RunDefWndProc;
    509506    }
    510507
     
    536533
    537534    case WM_VRNENABLED:
     535        dprintf(("OS2: WM_VRNENABLED %x", win32wnd->getWindowHandle()));
    538536        if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
    539537        {
     
    740738
    741739    case WM_FOCUSCHANGE:
    742         dprintf(("OS2: WM_FOCUSCHANGE %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    743         goto RunDefFrameProc;  //partly responsible for activation of frame windows
     740    {
     741     HWND   hwndFocus = (HWND)mp1;
     742     HWND   hwndLoseFocus, hwndGainFocus;
     743     USHORT usSetFocus = SHORT1FROMMP(mp2);
     744     USHORT fsFocusChange = SHORT2FROMMP(mp2);
     745
     746        dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     747        RestoreOS2TIB();
     748        if(usSetFocus) {
     749                hwndGainFocus = hwnd;
     750                hwndLoseFocus = hwndFocus;
     751        }
     752        else {
     753                hwndGainFocus = hwndFocus;
     754                hwndLoseFocus = hwnd;
     755        }
     756        if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
     757                WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
     758        }
     759        //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     760        if(!(fsFocusChange & FC_NOLOSESELECTION)) {
     761                WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
     762        }
     763        if(usSetFocus)
     764        {
     765          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
     766          if(!(fsFocusChange & FC_NOLOSEACTIVE)) {
     767                if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent())) {
     768                        if(winfocus) {
     769                                WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     770                        }
     771                        else    WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     772                }
     773          }
     774          if(!(fsFocusChange & FC_NOSETACTIVE))
     775          {
     776                Win32BaseWindow *topparent = win32wnd->GetTopParent();
     777                if(!winfocus || (winfocus->GetTopParent() != topparent))
     778                {
     779                        if(!(fsFocusChange & FC_NOBRINGTOTOP))
     780                        {
     781                                if(topparent) {
     782                                        //put window at the top of z order
     783                                        WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
     784                                }
     785                        }
     786                        WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     787                }
     788          }
     789        }
     790        else
     791        {
     792          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
     793          if(!(fsFocusChange & FC_NOLOSEACTIVE)) {
     794                if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent())) {
     795                        WinSendMsg(win32wnd->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     796                }
     797          }
     798          if(!(fsFocusChange & FC_NOSETACTIVE)) {
     799                if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent())) {
     800                        if(winfocus) {
     801                                WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     802                        }
     803                        else    WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     804                }
     805          }
     806        }
     807        //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     808        if(!(fsFocusChange & FC_NOSETSELECTION)) {
     809                WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
     810        }
     811
     812        if(!(fsFocusChange & FC_NOSETFOCUS)) {
     813                WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
     814        }
     815#ifdef DEBUG
     816        SetWin32TIB();
     817        dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     818        RestoreOS2TIB();
     819#endif
     820        return (MRESULT)rc;
     821    }
    744822
    745823    case WM_QUERYTRACKINFO:
     
    748826
    749827        dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
    750         RestoreOS2TIB();
    751         PMFrameWindowProc(hwnd,msg,mp1,mp2);
    752         SetWin32TIB();
    753828        trackInfo->cxBorder = 4;
    754829        trackInfo->cyBorder = 4;
     
    770845    }
    771846
     847    case WM_OWNERPOSCHANGE:
     848    {
     849        dprintf(("OS2: WM_OWNERPOSCHANGE"));
     850        goto RunDefWndProc;
     851    }
     852
    772853    case WM_FORMATFRAME:
    773854        dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
    774         break;
    775 
    776 #if 0
     855//        goto RunDefWndProc;
     856        break;
     857
    777858    case WM_ADJUSTFRAMEPOS:
    778         dprintf(("OS2: WM_ADJUSTFRAMEPOS %x", win32wnd->getWindowHandle()));
    779         break;
     859    {
     860      PSWP pswp   = (PSWP)mp1;
     861
     862        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));
     863        break;
     864    }
    780865
    781866    case WM_QUERYFRAMEINFO:
     
    788873
    789874        dprintf(("OS2: WM_QUERYFOCUSCHAIN %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     875#if 1
     876        goto RunDefWndProc;
     877#else
    790878        switch(fsCmd) {
    791879        case QFC_NEXTINCHAIN:
     
    804892        }
    805893        break;
    806     }
    807894#endif
     895    }
    808896
    809897    case WM_INITMENU:
     
    834922//        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    835923        RestoreOS2TIB();
    836         return PMFrameWindowProc(hwnd, msg, mp1, mp2);
    837 //        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     924        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    838925  }
    839926  RestoreOS2TIB();
    840927  return (MRESULT)rc;
    841928
    842 RunDefFrameProc:
    843   RestoreOS2TIB();
    844   return PMFrameWindowProc(hwnd, msg, mp1, mp2);
    845 
    846929RunDefWndProc:
    847930//  dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    848931  RestoreOS2TIB();
    849   return PMFrameWindowProc(hwnd, msg, mp1, mp2);
    850 //  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     932  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    851933} /* End of Win32WindowProc */
    852934//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.