Ignore:
Timestamp:
Jun 3, 2003, 1:58:57 PM (22 years ago)
Author:
sandervl
Message:

Send focus messages when we receive the undocumented WM_FOCUSCHANGED PM message. Removes the need for the ugly hack to deal with nested focus changes.

File:
1 edited

Legend:

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

    r10078 r10136  
    1 /* $Id: pmwindow.cpp,v 1.215 2003-05-07 16:13:26 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.216 2003-06-03 11:58:37 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    6060#include "dbglocal.h"
    6161
     62
     63// Notification that focus change has completed (UNDOCUMENTED)
     64#define WM_FOCUSCHANGED            0x000e
     65
    6266//define this to use the new code for WM_CALCVALIDRECT handling
    6367//#define USE_CALCVALIDRECT
     
    727731        break;
    728732
    729     case WIN32APP_SETFOCUSMSG:
     733    case WIN32APP_CHNGEFRAMECTRLS:
     734    {
     735        dprintf(("OS2: WIN32APP_CHANGEFRAMECTRLS"));
     736        OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), (ULONG)mp1, win32wnd->getExStyle(), (ULONG)mp2);
     737        break;
     738    }
     739   
     740    case WM_SETFOCUS:
     741    {
     742        HWND hwndFocus = (HWND)mp1;
     743        dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
     744        break;
     745    }
     746
     747    //Handle all focus processed during WM_FOCUSCHANGED; PM doesn't like focus
     748    //changes during focus processing (WM_SETFOCUS). This message is sent
     749    //after all focus work has been completed.
     750    case WM_FOCUSCHANGED:
     751    {
     752      HWND hwndFocus      = (HWND)mp1;
     753      HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
     754
     755        dprintf(("OS2: WM_FOCUSCHANGED %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
     756
    730757        //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
    731758        //must delay this function call
    732         //mp1 = win32 window handle
    733         //mp2 = top parent if activation required
    734         dprintf(("USER32: Delayed SetFocus %x %x %x call!", teb->o.odin.hwndFocus, mp1, mp2));
    735         if(teb->o.odin.hwndFocus) {
    736             RELEASE_WNDOBJ(win32wnd);
    737             win32wnd = Win32BaseWindow::GetWindowFromHandle(teb->o.odin.hwndFocus);
    738             if(win32wnd) {
    739                  if(mp2) {
    740                     SetActiveWindow((HWND)mp2);
    741                  }
    742                  if(!IsWindow(win32wnd->getWindowHandle())) break;       //abort if window destroyed
    743                  WinFocusChange(HWND_DESKTOP, win32wnd->getOS2WindowHandle(), FC_NOSETACTIVE);
    744             }
    745             else DebugInt3();
    746         }
    747         break;
    748 
    749     case WIN32APP_CHNGEFRAMECTRLS:
    750     {
    751       dprintf(("OS2: WIN32APP_CHANGEFRAMECTRLS"));
    752       OSLibSetWindowStyle(win32wnd->getOS2FrameWindowHandle(), win32wnd->getOS2WindowHandle(), (ULONG)mp1, win32wnd->getExStyle(), (ULONG)mp2);
    753       break;
    754     }
    755 
    756     case WM_SETFOCUS:
    757     {
    758       HWND hwndFocus = (HWND)mp1;
    759 
    760         dprintf(("OS2: WM_SETFOCUS %x %x (%x) %d cur focus %x", win32wnd->getWindowHandle(), mp1, OS2ToWin32Handle(hwndFocus), mp2, WinQueryFocus(HWND_DESKTOP)));
    761 
    762         //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
    763         //must delay this function call
    764 
    765         teb->o.odin.fWM_SETFOCUS = TRUE;
    766         teb->o.odin.hwndFocus    = 0;
     759
    767760        if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC)
    768761        {
    769762            //another (non-win32) application's window
    770763            //set to NULL (allowed according to win32 SDK) to avoid problems
    771             hwndFocus = NULL;
     764            hwndFocus      = 0;
     765            hwndFocusWin32 = 0;
    772766        }
    773767        if((ULONG)mp2 == TRUE) {
    774             HWND hwndFocusWin32 = OS2ToWin32Handle(hwndFocus);
    775             recreateCaret (hwndFocusWin32);
     768            recreateCaret(hwndFocusWin32);
    776769            win32wnd->MsgSetFocus(hwndFocusWin32);
    777770        }
     
    784777            else dprintf(("Window has already received a WM_KILLFOCUS (SetFocus(0)); ignore"));
    785778        }
    786         teb->o.odin.fWM_SETFOCUS = FALSE;
    787 
    788779        break;
    789780    }
Note: See TracChangeset for help on using the changeset viewer.