Changeset 10136 for trunk/src


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.

Location:
trunk/src/user32
Files:
2 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    }
  • trunk/src/user32/window.cpp

    r9974 r10136  
    1 /* $Id: window.cpp,v 1.134 2003-04-02 12:58:02 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.135 2003-06-03 11:58:38 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    781781
    782782    hwnd_O = window->getOS2WindowHandle();
    783     if(teb->o.odin.hwndFocus) {
    784          lastFocus = teb->o.odin.hwndFocus;
    785     }
    786     else lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
     783    lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
    787784
    788785    hwndTopParent = window->GetTopParent();
     
    806803    }
    807804
    808     //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
    809     //must delay this function call
    810     if(teb->o.odin.fWM_SETFOCUS) {
    811         dprintf(("USER32: Delay SetFocus call!"));
    812         teb->o.odin.hwndFocus = hwnd;
    813 
    814         //If keystrokes were ignored and focus is set to the old focus window, then
    815         //PM won't send us a WM_SETFOCUS message. (as we don't inform PM for SetFocus(0))
    816         if(fIgnoreKeystrokes && lastFocus_W == hwnd) {
    817             dprintf(("Manually send WM_SETFOCUS; real focus window hasn't changed"));
    818             SendMessageA(lastFocus_W, WM_SETFOCUS, 0, 0);
    819         }
    820         else {
    821             //mp1 = win32 window handle
    822             //mp2 = top parent if activation required
    823             OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, (activate) ? hwndTopParent : 0);
    824         }
    825         RELEASE_WNDOBJ(window);
    826         return lastFocus_W;
    827     }
    828     teb->o.odin.hwndFocus = 0;
    829805    if(!IsWindow(hwnd)) return FALSE;       //abort if window destroyed
    830806
     
    839815        SendMessageA(lastFocus_W, WM_SETFOCUS, 0, 0);
    840816    }
    841 
    842817    fIgnoreKeystrokes = FALSE;
    843818    return ret;
     
    860835        return 0;
    861836    }
    862     //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
    863     //If focus was changed during WM_SETFOCUS, the focus window handle is
    864     //stored in teb->o.odin.hwndFocus (set back to 0 when delayed SetFocus
    865     //is activated)
    866     if(teb->o.odin.hwndFocus) {
    867         dprintf(("USER32: GetFocus %x (DURING WM_SETFOCUS PROCESSING)", teb->o.odin.hwndFocus));
    868         return teb->o.odin.hwndFocus;
    869     }
    870 
    871837    hwnd = OSLibWinQueryFocus(OSLIB_HWND_DESKTOP);
    872838    hwnd = OS2ToWin32Handle(hwnd);
Note: See TracChangeset for help on using the changeset viewer.