Ignore:
Timestamp:
Sep 5, 2000, 9:20:38 PM (25 years ago)
Author:
sandervl
Message:

WM_FOCUSCHANGE fixes + misc fixes

File:
1 edited

Legend:

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

    r4140 r4194  
    1 /* $Id: pmwindow.cpp,v 1.102 2000-09-01 01:36:15 phaller Exp $ */
     1/* $Id: pmwindow.cpp,v 1.103 2000-09-05 19:20:34 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    377377        }
    378378
    379         if(pswp->fl & SWP_ACTIVATE)
    380         {
    381              if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE)) {
    382                 WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    383              }
    384         }
    385 
    386379        if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
    387380        {
     
    458451        }
    459452
     453        if(pswp->fl & SWP_ACTIVATE)
     454        {
     455             if(!(WinQueryWindowUShort(hwnd,QWS_FLAGS) & FF_ACTIVE)) {
     456                WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     457             }
     458        }
     459
    460460PosChangedEnd:
    461461        RestoreOS2TIB();
     
    590590    }
    591591
     592    //is sent to both windows gaining and loosing the focus
     593    case WM_FOCUSCHANGE:
     594    {
     595     HWND   hwndFocus = (HWND)mp1;
     596     HWND   hwndLoseFocus, hwndGainFocus;
     597     USHORT usSetFocus = SHORT1FROMMP(mp2);
     598     USHORT fsFocusChange = SHORT2FROMMP(mp2);
     599
     600        rc = 0;
     601        dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     602        RestoreOS2TIB();
     603        if(usSetFocus) {
     604                hwndGainFocus = hwnd;
     605                hwndLoseFocus = hwndFocus;
     606        }
     607        else {
     608                hwndGainFocus = hwndFocus;
     609                hwndLoseFocus = hwnd;
     610        }
     611     
     612        if(usSetFocus)
     613        {
     614          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
     615          if(!(fsFocusChange & FC_NOSETACTIVE))
     616          {
     617            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
     618            {
     619              if(winfocus)
     620                WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     621              else     
     622                WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     623            }
     624          }
     625          //SvL: Check if window is still valid
     626          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     627          if(win32wnd == NULL)
     628            return (MRESULT)rc;
     629
     630          if(!(fsFocusChange & FC_NOSETACTIVE))
     631          {
     632            Win32BaseWindow *topparent = win32wnd->GetTopParent();
     633            if(!winfocus || (winfocus->GetTopParent() != topparent))
     634            {
     635              if(!(fsFocusChange & FC_NOBRINGTOTOP))
     636              {
     637                if(topparent) {
     638                  //put window at the top of z order
     639                  WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
     640                }
     641              }
     642 
     643              // PH 2000/09/01 Netscape 4.7
     644              // check if topparent is valid
     645              if (topparent)
     646                WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     647            }
     648          }
     649          //SvL: Check if window is still valid
     650          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     651          if(win32wnd == NULL)
     652            return (MRESULT)rc;
     653
     654          //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     655          if(!(fsFocusChange & FC_NOSETSELECTION)) {
     656                WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
     657          }
     658
     659          if(!(fsFocusChange & FC_NOSETFOCUS)) {
     660                WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
     661          }
     662        }
     663        else /* no usSetFocus */
     664        {
     665          if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
     666                WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
     667          }
     668          //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     669          if(!(fsFocusChange & FC_NOLOSESELECTION)) {
     670                WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
     671          }
     672          //SvL: Check if window is still valid
     673          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     674          if(win32wnd == NULL) {
     675                return (MRESULT)rc;
     676          }
     677
     678          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
     679          if(!(fsFocusChange & FC_NOLOSEACTIVE))
     680          {
     681            Win32BaseWindow *topparent = win32wnd->GetTopParent();
     682           
     683            if(!winfocus || (winfocus->GetTopParent() != topparent))
     684            {
     685              // PH 2000/09/01 Netscape 4.7
     686              // check if topparent is valid
     687              if (topparent)
     688                WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     689            }
     690          }
     691          //SvL: Check if window is still valid
     692          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     693          if(win32wnd == NULL)
     694            return (MRESULT)rc;
     695 
     696          if(!(fsFocusChange & FC_NOSETACTIVE))
     697          {
     698            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
     699            {
     700              if(winfocus)
     701              {
     702                // PH 2000/09/01 Netscape 4.7
     703                // check if topparent is valid
     704                Win32BaseWindow *topparent = winfocus->GetTopParent();
     705                if (topparent)
     706                  WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     707              }
     708              else     
     709                WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     710            }
     711          }
     712        }
     713     
     714     
     715#ifdef DEBUG
     716        SetWin32TIB();
     717        dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     718        RestoreOS2TIB();
     719#endif
     720        return (MRESULT)rc;
     721    }
     722
    592723    //**************************************************************************
    593724    //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
     
    753884    }
    754885#endif
    755 
    756     case WM_FOCUSCHANGE:
    757     {
    758      HWND   hwndFocus = (HWND)mp1;
    759      HWND   hwndLoseFocus, hwndGainFocus;
    760      USHORT usSetFocus = SHORT1FROMMP(mp2);
    761      USHORT fsFocusChange = SHORT2FROMMP(mp2);
    762 
    763         dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    764         RestoreOS2TIB();
    765         if(usSetFocus) {
    766                 hwndGainFocus = hwnd;
    767                 hwndLoseFocus = hwndFocus;
    768         }
    769         else {
    770                 hwndGainFocus = hwndFocus;
    771                 hwndLoseFocus = hwnd;
    772         }
    773         if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
    774                 WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
    775         }
    776         //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    777         if(!(fsFocusChange & FC_NOLOSESELECTION)) {
    778                 WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
    779         }
    780         //SvL: Check if window is still valid
    781         win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    782         if(win32wnd == NULL) {
    783                 return (MRESULT)rc;
    784         }
    785      
    786      
    787       if(usSetFocus)
    788       {
    789         Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
    790         if(!(fsFocusChange & FC_NOLOSEACTIVE))
    791         {
    792           if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    793           {
    794             if(winfocus)
    795               WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    796             else       
    797               WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    798           }
    799         }
    800         //SvL: Check if window is still valid
    801         win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    802         if(win32wnd == NULL)
    803           return (MRESULT)rc;
    804 
    805         if(!(fsFocusChange & FC_NOSETACTIVE))
    806         {
    807           Win32BaseWindow *topparent = win32wnd->GetTopParent();
    808           if(!winfocus || (winfocus->GetTopParent() != topparent))
    809           {
    810             if(!(fsFocusChange & FC_NOBRINGTOTOP))
    811             {
    812               if(topparent) {
    813                 //put window at the top of z order
    814                 WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
    815               }
    816             }
    817 
    818             // PH 2000/09/01 Netscape 4.7
    819             // check if topparent is valid
    820             if (topparent)
    821               WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    822           }
    823         }
    824       }
    825       else /* no usSetFocus */
    826       {
    827         Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
    828         if(!(fsFocusChange & FC_NOLOSEACTIVE))
    829         {
    830           Win32BaseWindow *topparent = win32wnd->GetTopParent();
    831          
    832           if(!winfocus || (winfocus->GetTopParent() != topparent))
    833           {
    834             // PH 2000/09/01 Netscape 4.7
    835             // check if topparent is valid
    836             if (topparent)
    837               WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    838           }
    839         }
    840         //SvL: Check if window is still valid
    841         win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    842         if(win32wnd == NULL)
    843           return (MRESULT)rc;
    844 
    845         if(!(fsFocusChange & FC_NOSETACTIVE))
    846         {
    847           if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    848           {
    849             if(winfocus)
    850             {
    851               // PH 2000/09/01 Netscape 4.7
    852               // check if topparent is valid
    853               Win32BaseWindow *topparent = winfocus->GetTopParent();
    854               if (topparent)
    855                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    856             }
    857             else       
    858               WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    859           }
    860         }
    861       }
    862      
    863      
    864         //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    865         if(!(fsFocusChange & FC_NOSETSELECTION)) {
    866                 WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
    867         }
    868 
    869         if(!(fsFocusChange & FC_NOSETFOCUS)) {
    870                 WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
    871         }
    872 #ifdef DEBUG
    873         SetWin32TIB();
    874         dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    875         RestoreOS2TIB();
    876 #endif
    877         return (MRESULT)rc;
    878     }
    879886
    880887    case WM_QUERYTRACKINFO:
Note: See TracChangeset for help on using the changeset viewer.