Changeset 5713 for trunk/src


Ignore:
Timestamp:
May 15, 2001, 4:31:40 PM (24 years ago)
Author:
sandervl
Message:

SetFocus fix

Location:
trunk/src/user32
Files:
5 edited

Legend:

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

    r5685 r5713  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.50 2001-05-11 08:39:43 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.51 2001-05-15 14:31:38 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    192192  TEB             *teb = (TEB *)pTeb;
    193193  BOOL             fWasDisabled = FALSE;
     194  BOOL             fIsFrame = FALSE;
    194195  int i;
    195196
     
    198199    if(!win32wnd) {
    199200        win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
     201        if(win32wnd) {
     202            fIsFrame = TRUE;
     203        }
    200204    }
    201205
     
    276280      LONG      xDelta = pswp->cx - swpOld.cx;
    277281
     282        if(!fIsFrame) goto dummymessage;
     283
    278284        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
    279285
     
    294300        if (!win32wnd->CanReceiveSizeMsgs())    goto dummymessage;
    295301
    296         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    297 /////                dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
    298 /////                win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
    299 
     302        if(pswp->fl & (SWP_MOVE | SWP_SIZE))
     303        {
    300304                teb->o.odin.wp.hwnd = win32wnd->getWindowHandle();
    301305                if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
  • trunk/src/user32/oslibwin.cpp

    r5685 r5713  
    1 /* $Id: oslibwin.cpp,v 1.92 2001-05-11 08:39:43 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.93 2001-05-15 14:31:38 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    153153BOOL OSLibWinAlarm(HWND hwndDeskTop,ULONG flStyle)
    154154{
    155   return WinAlarm(hwndDeskTop,flStyle);
     155    return WinAlarm(hwndDeskTop,flStyle);
    156156}
    157157//******************************************************************************
     
    159159APIRET OSLibDosBeep(ULONG freg,ULONG dur)
    160160{
    161   return DosBeep(freg,dur);
     161    return DosBeep(freg,dur);
    162162}
    163163//******************************************************************************
     
    165165HWND OSLibWinQueryFocus(HWND hwndDeskTop)
    166166{
    167   return WinQueryFocus(hwndDeskTop);
     167    return WinQueryFocus(hwndDeskTop);
    168168}
    169169//******************************************************************************
     
    171171HWND OSLibWinWindowFromID(HWND hwndParent,ULONG id)
    172172{
    173   return WinWindowFromID(hwndParent,id);
     173    return WinWindowFromID(hwndParent,id);
    174174}
    175175//******************************************************************************
     
    177177BOOL OSLibWinSetFocus(HWND hwndDeskTop,HWND hwndNewFocus, BOOL activate)
    178178{
    179   return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? FC_NOLOSEACTIVE : 0);
     179    return WinFocusChange (hwndDeskTop, hwndNewFocus, activate ? 0 : FC_NOSETACTIVE);
    180180}
    181181//******************************************************************************
     
    183183BOOL OSLibWinIsChild (HWND hwnd, HWND hwndOf)
    184184{
    185   return WinIsChild (hwnd, hwndOf);
     185    return WinIsChild (hwnd, hwndOf);
    186186}
    187187//******************************************************************************
     
    189189ULONG OSLibGetWindowHeight(HWND hwnd)
    190190{
    191   RECTL rect;
    192 
    193   return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
     191    RECTL rect;
     192
     193    return (WinQueryWindowRect(hwnd,&rect)) ? rect.yTop-rect.yBottom:0;
    194194}
    195195//******************************************************************************
     
    197197LONG OSLibWinQuerySysValue(LONG iSysValue)
    198198{
    199   return WinQuerySysValue(HWND_DESKTOP,iSysValue);
     199    return WinQuerySysValue(HWND_DESKTOP,iSysValue);
    200200}
    201201//******************************************************************************
     
    203203ULONG OSLibWinQueryDlgItemText(HWND hwndDlg,ULONG idItem,LONG cchBufferMax,char* pchBuffer)
    204204{
    205   return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
     205    return WinQueryDlgItemText(hwndDlg,idItem,cchBufferMax,pchBuffer);
    206206}
    207207//******************************************************************************
     
    209209BOOL OSLibWinSetDlgItemText(HWND hwndDlg,ULONG idItem,char* pszText)
    210210{
    211   return WinSetDlgItemText(hwndDlg,idItem,pszText);
     211    return WinSetDlgItemText(hwndDlg,idItem,pszText);
    212212}
    213213//******************************************************************************
     
    215215BOOL OSLibWinQueryPointerPos(PPOINT pptlPoint)
    216216{
    217   return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint);
     217    return WinQueryPointerPos(HWND_DESKTOP,(PPOINTL)pptlPoint);
    218218}
    219219//******************************************************************************
     
    221221BOOL OSLibWinSetPointerPos(int x, int y)
    222222{
    223   return WinSetPointerPos(HWND_DESKTOP, x, y);
     223    return WinSetPointerPos(HWND_DESKTOP, x, y);
    224224}
    225225//******************************************************************************
     
    227227HWND OSLibWinQueryWindow(HWND hwnd, ULONG lCode)
    228228{
    229   return WinQueryWindow(hwnd, lCode);
     229    return WinQueryWindow(hwnd, lCode);
    230230}
    231231//******************************************************************************
  • trunk/src/user32/pmwindow.cpp

    r5698 r5713  
    1 /* $Id: pmwindow.cpp,v 1.129 2001-05-12 08:25:56 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.130 2001-05-15 14:31:39 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    125125        (PFNWP)Win32FrameWindowProc,       /* Address of window procedure  */
    126126        CS_FRAME,
    127         FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES))
     127        FrameClassInfo.cbWindowData))
    128128    {
    129129        dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
     
    145145    DevCloseDC(hdc);
    146146
    147     dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
     147    dprintf(("InitPM: Desktop (%d,%d) bpp %d", ScreenWidth, ScreenHeight, ScreenBitsPerPel));
    148148    return TRUE;
    149149} /* End of main */
     
    310310        //must delay this function call
    311311        //mp1 = win32 window handle
    312         //mp2 = activate flag
    313         dprintf(("USER32: Delayed SetFocus %x %x call!", teb->o.odin.hwndFocus, mp1));
     312        //mp2 = top parent if activation required
     313        dprintf(("USER32: Delayed SetFocus %x %x %x call!", teb->o.odin.hwndFocus, mp1, mp2));
    314314        if(teb->o.odin.hwndFocus) {
    315315            win32wnd = Win32BaseWindow::GetWindowFromHandle(teb->o.odin.hwndFocus);
    316316            if(win32wnd) {
    317                  WinFocusChange(HWND_DESKTOP, win32wnd->getOS2WindowHandle(), (mp2) ? FC_NOLOSEACTIVE : 0);
     317                 if(mp2) {
     318                    SetActiveWindow((HWND)mp2);
     319                 }
     320                 if(!IsWindow(win32wnd->getWindowHandle())) break;       //abort if window destroyed
     321                 WinFocusChange(HWND_DESKTOP, win32wnd->getOS2WindowHandle(), FC_NOSETACTIVE);
    318322            }
    319323            else DebugInt3();
     
    578582    {
    579583        //WM_CREATE handled during client window creation
     584        dprintf(("PMFRAME: WM_CREATE %x"));
    580585        goto RunDefFrameWndProc;
    581586    }
     
    584589    {
    585590      RECTL rectl;
    586 
    587591
    588592        HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
     
    13501354RunDefWndProc:
    13511355    RestoreOS2TIB();
    1352     //calling WinDefWindowProc here break Opera hotlist window (WM_ADJUSTWINDOWPOS)
     1356    //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
    13531357//    return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    13541358    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
  • trunk/src/user32/win32wbase.cpp

    r5685 r5713  
    1 /* $Id: win32wbase.cpp,v 1.255 2001-05-11 08:39:45 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.256 2001-05-15 14:31:39 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    31383138 BOOL rc;
    31393139
    3140   dprintf(("Win32BaseWindow::EnableWindow %x %d", getWindowHandle(), fEnable));
    3141   //return true if previous state was disabled, else false (sdk docs)
    3142   rc = (getStyle() & WS_DISABLED) != 0;
    3143   if(rc && !fEnable) {
     3140    dprintf(("Win32BaseWindow::EnableWindow %x %d", getWindowHandle(), fEnable));
     3141    //return true if previous state was disabled, else false (sdk docs)
     3142    rc = (getStyle() & WS_DISABLED) != 0;
     3143    if(rc && !fEnable) {
    31443144        SendMessageA(WM_CANCELMODE, 0, 0);
    3145   }
    3146   OSLibWinEnableWindow(OS2HwndFrame, fEnable);
    3147   if(fEnable == FALSE) {
     3145    }
     3146    OSLibWinEnableWindow(OS2HwndFrame, fEnable);
     3147    if(fEnable == FALSE) {
    31483148        //SvL: No need to clear focus as PM already does this
    31493149        if(getWindowHandle() == GetCapture()) {
     
    31513151                dprintf(("Released capture for window %x that is being disabled", getWindowHandle()));
    31523152        }
    3153   }
    3154   return rc;
     3153    }
     3154    return rc;
    31553155}
    31563156//******************************************************************************
  • trunk/src/user32/window.cpp

    r5698 r5713  
    1 /* $Id: window.cpp,v 1.97 2001-05-12 08:25:57 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.98 2001-05-15 14:31:40 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    3939#include <heapstring.h>
    4040#include <winuser32.h>
     41#include "hook.h"
    4142
    4243#define DBG_LOCALLOG    DBG_window
     
    715716HWND WIN32API SetFocus(HWND hwnd)
    716717{
    717  Win32BaseWindow *window;
     718 Win32BaseWindow *window, *topparent;
     719 Win32BaseWindow *oldfocuswnd;
    718720 HWND lastFocus, lastFocus_W, hwnd_O;
    719721 BOOL activate;
     
    739741    else lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
    740742
    741     activate  = ((hwnd_O == lastFocus) || OSLibWinIsChild (lastFocus, hwnd_O));
     743    topparent = window->GetTopParent();
     744    activate = FALSE;
    742745    lastFocus_W = OS2ToWin32Handle (lastFocus);
    743 
    744     dprintf(("SetFocus %x (%x) -> %x (%x)\n", lastFocus_W, lastFocus, hwnd, hwnd_O));
     746    if(lastFocus_W) {
     747         oldfocuswnd = Win32BaseWindow::GetWindowFromHandle(lastFocus_W);
     748         if(lastFocus_W != hwnd && topparent != oldfocuswnd->GetTopParent()) {
     749            activate = TRUE;
     750         }
     751    }
     752    else activate = TRUE;
     753
     754    dprintf(("SetFocus %x (%x) -> %x (%x) act %d", lastFocus_W, lastFocus, hwnd, hwnd_O, activate));
     755
     756    if(HOOK_CallHooksA(WH_CBT, HCBT_SETFOCUS, hwnd, (LPARAM)lastFocus_W)) {
     757        dprintf(("hook cancelled SetFocus call!"));
     758        return 0;
     759    }
    745760
    746761    //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
     
    750765        teb->o.odin.hwndFocus = hwnd;
    751766        //mp1 = win32 window handle
    752         //mp2 = activate flag
    753         OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, activate);
     767        //mp2 = top parent if activation required
     768        OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, (activate) ? topparent->getWindowHandle() : 0);
    754769        return lastFocus_W;
    755770    }
    756771    teb->o.odin.hwndFocus = 0;
    757     return (OSLibWinSetFocus (OSLIB_HWND_DESKTOP, hwnd_O, activate)) ? lastFocus_W : 0;
     772    if(activate) {
     773        SetActiveWindow(topparent->getWindowHandle());
     774    }
     775    if(!IsWindow(hwnd)) return FALSE;       //abort if window destroyed
     776
     777    return (OSLibWinSetFocus(OSLIB_HWND_DESKTOP, hwnd_O, 0)) ? lastFocus_W : 0;
    758778}
    759779//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.