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

SetFocus fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.