Changeset 10031 for trunk/src


Ignore:
Timestamp:
Apr 23, 2003, 8:01:01 PM (22 years ago)
Author:
sandervl
Message:

KSO: Properties allocated from shared memory & Fake window updates & SW_SHOWDEFAULT update

Location:
trunk/src/user32
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/USER32.DEF

    r9889 r10031  
    1 ; $Id: USER32.DEF,v 1.78 2003-03-03 16:36:25 sandervl Exp $
     1; $Id: USER32.DEF,v 1.79 2003-04-23 18:00:58 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    3636;;;; Present in WGSS50
    3737;;;;    _GpiQueryDCData             = PMGPI.665
     38
     39    WinQueryProperty  = PMMERGE.5450
     40    WinRemoveProperty = PMMERGE.5451
     41    WinSetProperty    = PMMERGE.5452
    3842
    3943EXPORTS
  • trunk/src/user32/oslibwin.cpp

    r10013 r10031  
    1 /* $Id: oslibwin.cpp,v 1.142 2003-04-11 15:22:33 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.143 2003-04-23 18:00:58 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    127127//Note: Also check OSLibSetWindowStyle when changing this!!
    128128//******************************************************************************
    129 BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle, 
     129BOOL OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle,
    130130                          ULONG *OSFrameStyle)
    131131{
     
    144144
    145145  //WS_EX_TOOLWINDOW is incompatible with the OS2Look (titlebar thinner + smaller font)
    146   if(fOS2Look && !(dwExStyle & WS_EX_TOOLWINDOW_W)) 
     146  if(fOS2Look && !(dwExStyle & WS_EX_TOOLWINDOW_W))
    147147  {
    148148      if((dwStyle & WS_CAPTION_W) == WS_CAPTION_W) {
     
    168168//******************************************************************************
    169169//******************************************************************************
    170 BOOL OSLibWinPositionFrameControls(HWND hwndFrame, RECTLOS2 *pRect, DWORD dwStyle, 
    171                                    DWORD dwExStyle, HICON hSysMenuIcon, 
     170BOOL OSLibWinPositionFrameControls(HWND hwndFrame, RECTLOS2 *pRect, DWORD dwStyle,
     171                                   DWORD dwExStyle, HICON hSysMenuIcon,
    172172                                   BOOL drawCloseButton, BOOL fClassIcon)
    173173{
     
    190190      minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
    191191  }
    192  
     192
    193193  if(fOS2Look == OS2_APPEARANCE_SYSMENU) {
    194194      //Note: If no class icon *and* WS_EX_DLGMODALFRAME -> no system menu!!
     
    236236              swp[i].cx -= minmaxwidth/2;
    237237          }
    238           //there is no close button in warp 3 and sometimes we do not 
     238          //there is no close button in warp 3 and sometimes we do not
    239239          //have close button as well
    240240          if((dwStyle & WS_SYSMENU_W) && !fVersionWarp3 && drawCloseButton) {
     
    578578
    579579//******************************************************************************
    580 //@PF This is exactly that weird message PM sends when we maximize window from 
     580//@PF This is exactly that weird message PM sends when we maximize window from
    581581//icon - this coordinates NEVER surface later and this combination of SWP
    582582//commands is useless, yet it starts the correct reaction of maximiztion from
     
    595595 /* @@PF The reason for this weird minimize algorithm is that we are not fully
    596596    using PM for minimization. I.e. we respect all PM messages yet we do mess
    597     so much with some messages that minimization is based partly on vodoo. 
     597    so much with some messages that minimization is based partly on vodoo.
    598598    That is if you try minimize and deactivate in one call it will fail.
    599599    Here we deactivate yourselves and give focus to next window that is
     
    635635{
    636636    ULONG hIconOS2 = GetOS2Icon(hIcon);
    637     if(hIconOS2) 
     637    if(hIconOS2)
    638638       return (BOOL) WinSendMsg(hwnd, WM_SETICON, (MPARAM)hIconOS2, 0);
    639639    return FALSE;
     
    996996//PF: PM Logic approved by numerous testcases shows this:
    997997//There is no other way to tweak FID_MINMAX without deleting it
    998 //Controls are created with size 0,0, invisible and should be immediately 
     998//Controls are created with size 0,0, invisible and should be immediately
    999999//positioned. MINMAX control can't function properly without FID_SYSMENU
    10001000//control if it is present, so we need to recreate BOTH controls.
     
    10061006//leave old, WinCreateFrameControls can't tweak anything.
    10071007
    1008 void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, 
     1008void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle,
    10091009                         ULONG dwExStyle, ULONG dwOldWindowsStyle)
    10101010{
     
    10121012    ULONG dwOldWinStyle;
    10131013
    1014     int checksum, checksum2; 
     1014    int checksum, checksum2;
    10151015    DWORD dest_tid, dest_pid;
    10161016
     
    10241024    dest_tid = GetWindowThreadProcessId(OS2ToWin32Handle(hwndClient) , &dest_pid );
    10251025
    1026     if (dest_tid != GetCurrentThreadId()) 
     1026    if (dest_tid != GetCurrentThreadId())
    10271027    {
    10281028        dprintf(("OSLibSetWindowStyle: Redirecting Change Frame controls to another thread"));
     
    10341034        minmaxheight = WinQuerySysValue(HWND_DESKTOP, SV_CYMINMAXBUTTON);
    10351035    }
    1036  
     1036
    10371037    if (hwndClient)
    10381038    {
     
    10811081         dwWinStyle |= WS_MAXIMIZED;
    10821082    }
    1083     else 
     1083    else
    10841084      dwWinStyle &= ~WS_MAXIMIZED;
    10851085
     
    10961096            }
    10971097            else
    1098               WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR), &rc1);           
     1098              WinQueryWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR), &rc1);
    10991099
    11001100            if((dwStyle & WS_SYSMENU_W) && !(dwExStyle & WS_EX_TOOLWINDOW_W))
     
    11261126              {
    11271127                  OSFrameStyle |= FCF_CLOSEBUTTON;
    1128                   OSFrameStyle |= FCF_SYSMENU;                   
     1128                  OSFrameStyle |= FCF_SYSMENU;
    11291129                  totalwidth += minmaxwidth/2;
    11301130                  dprintf(("close button"));
     
    11321132            }
    11331133       }
    1134        else 
     1134       else
    11351135       {
    1136           if (WinWindowFromID(hwndFrame, FID_TITLEBAR)) 
     1136          if (WinWindowFromID(hwndFrame, FID_TITLEBAR))
    11371137              WinDestroyWindow(WinWindowFromID(hwndFrame, FID_TITLEBAR));
    11381138       }
     
    11401140       if (checksum != checksum2)
    11411141       {
    1142          if (WinWindowFromID(hwndFrame, FID_SYSMENU)) 
     1142         if (WinWindowFromID(hwndFrame, FID_SYSMENU))
    11431143             WinDestroyWindow(WinWindowFromID(hwndFrame, FID_SYSMENU));
    1144          if (WinWindowFromID(hwndFrame, FID_MINMAX)) 
     1144         if (WinWindowFromID(hwndFrame, FID_MINMAX))
    11451145             WinDestroyWindow(WinWindowFromID(hwndFrame, FID_MINMAX));
    11461146       }
     
    11541154            GetWindowTextA(OS2ToWin32Handle(hwndClient), buffer, sizeof(buffer));
    11551155            WinCreateFrameControls(hwndFrame, &FCData, buffer );
    1156  
     1156
    11571157            if (totalwidth != rc3.cx)
    11581158            {
     
    11621162              rc3.x = rc3.x + totalwidth;
    11631163            }
    1164              
    1165             WinSetWindowPos(WinWindowFromID(hwndFrame, FID_MINMAX),0,rc3.x,rc3.y,rc3.cx,rc3.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);     
    1166             WinSetWindowPos(WinWindowFromID(hwndFrame, FID_SYSMENU),0,rc2.x,rc2.y,rc2.cx,rc2.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);     
    1167             WinSetWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR),0,rc1.x,rc1.y,rc1.cx,rc1.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);     
     1164
     1165            WinSetWindowPos(WinWindowFromID(hwndFrame, FID_MINMAX),0,rc3.x,rc3.y,rc3.cx,rc3.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     1166            WinSetWindowPos(WinWindowFromID(hwndFrame, FID_SYSMENU),0,rc2.x,rc2.y,rc2.cx,rc2.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
     1167            WinSetWindowPos(WinWindowFromID(hwndFrame, FID_TITLEBAR),0,rc1.x,rc1.y,rc1.cx,rc1.cy, SWP_MOVE | SWP_SIZE | SWP_SHOW);
    11681168
    11691169            if (WinQueryActiveWindow(HWND_DESKTOP) == hwndFrame)
     
    13451345//******************************************************************************
    13461346//******************************************************************************
     1347
     1348/* 'Private' PM property stuff. */
     1349PVOID APIENTRY WinQueryProperty(HWND hwnd, PCSZ pszNameOrAtom);
     1350PVOID APIENTRY WinRemoveProperty(HWND hwnd, PCSZ pszNameOrAtom);
     1351BOOL  APIENTRY WinSetProperty(HWND hwnd, PCSZ pszNameOrAtom, PVOID pvData, ULONG ulFlags);
     1352
     1353/**
     1354 * Set Property.
     1355 * @returns Success indicator.
     1356 * @param   hwnd    Window the property is associated with.
     1357 * @param   psz     The property atom or name.
     1358 * @param   pv      Property value.
     1359 * @param   fFlags  Flags. Use 0.
     1360 */
     1361BOOL    OSLibSetProperty(HWND hwnd, const char *psz, void *pv, unsigned fFlags)
     1362{
     1363    USHORT selFS = RestoreOS2FS();
     1364    BOOL fRet = WinSetProperty(hwnd, psz, pv, fFlags);
     1365    SetFS(selFS);
     1366    return fRet;
     1367}
     1368
     1369/**
     1370 * Get Property.
     1371 * @returns Property value.
     1372 * @param   hwnd    Window the property is associated with.
     1373 * @param   psz     The property atom or name.
     1374 */
     1375void *  OSLibQueryProperty(HWND hwnd, const char *psz)
     1376{
     1377    USHORT selFS = RestoreOS2FS();
     1378    void *pvRet = WinQueryProperty(hwnd, psz);
     1379    SetFS(selFS);
     1380    return pvRet;
     1381}
     1382
     1383/**
     1384 * Remove Property.
     1385 * @returns Property value.
     1386 * @param   hwnd    Window the property is associated with.
     1387 * @param   psz     The property atom or name.
     1388 */
     1389void *  OSLibRemoveProperty(HWND hwnd, const char *psz)
     1390{
     1391    USHORT selFS = RestoreOS2FS();
     1392    void *pvRet = WinRemoveProperty(hwnd, psz);
     1393    SetFS(selFS);
     1394    return pvRet;
     1395}
     1396
  • trunk/src/user32/oslibwin.h

    r10013 r10031  
    1 /* $Id: oslibwin.h,v 1.75 2003-04-11 15:22:33 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.76 2003-04-23 18:00:58 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    398398
    399399
     400void *  OSLibRemoveProperty(HWND hwnd, const char *psz);
     401BOOL    OSLibSetProperty(HWND hwnd, const char *psz, void *pv, unsigned fFlags);
     402void *  OSLibQueryProperty(HWND hwnd, const char *psz);
     403
    400404#endif //__OSLIBWIN_H__
  • trunk/src/user32/pmwindow.cpp

    r10008 r10031  
    1 /* $Id: pmwindow.cpp,v 1.208 2003-04-11 10:55:02 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.209 2003-04-23 18:00:59 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    3131#include <dbglog.h>
    3232#include <win32wbase.h>
     33#include <win32wfake.h>
    3334#include <win32dlg.h>
    3435#include "win32wdesktop.h"
     
    884885        {
    885886                win32wnd->DispatchMsgA(pWinMsg);
    886                 if(WinQueryUpdateRect(hwnd, NULL) == TRUE) 
     887                if(WinQueryUpdateRect(hwnd, NULL) == TRUE)
    887888                {//the application didn't validate the update region; Windows
    888889                 //will only send a WM_PAINT once until another part of the
     
    10181019            break;
    10191020        }
    1020  
     1021
    10211022        ULONG ulBytes, cItems;
    10221023        char *pszFiles;
     
    10361037        else {
    10371038            rc = (MRFROM2SHORT (DOR_NEVERDROP, 0));
    1038         } 
     1039        }
    10391040        break;
    10401041    }
     
    12721273    {
    12731274        //ignore this message. don't forward it to the default PM frame window handler
    1274         //as that one sends it to the client. as a result we end up translating 
     1275        //as that one sends it to the client. as a result we end up translating
    12751276        //it twice
    12761277        break;
     
    13661367                 DWORD dwOldStyle = win32wnd->getOldStyle();
    13671368                 DWORD dwStyle    = win32wnd->getStyle();
    1368    
     1369
    13691370                 win32wnd->setOldStyle(dwStyle);
    13701371                 if((dwOldStyle & WS_MINIMIZE_W) && !(dwStyle & WS_MINIMIZE_W)) {
     
    15531554                WinShowWindow(win32wnd->getOS2WindowHandle(), 0);
    15541555            }
    1555             if(pswp->fl & (SWP_SHOW|SWP_HIDE)) 
     1556            if(pswp->fl & (SWP_SHOW|SWP_HIDE))
    15561557            {//TODO: necessary for more options? (activate?)
    15571558                if(win32wnd->CanReceiveSizeMsgs())
     
    19481949        //result will be illegal. Btw we do not honour PM border size settings
    19491950        //and never will. I was unable to figure out why only X coordinate
    1950         //is being broken but not Y as well. 
    1951 
    1952         if ((pswp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE) 
     1951        //is being broken but not Y as well.
     1952
     1953        if ((pswp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
    19531954        {
    19541955            RECT rect;
     
    20912092    SetWin32TIB();
    20922093
    2093     //We can't query the window object directly from this window as it's not the
    2094     //real thing. There should be a genuine win32 child window which we can use.
    2095     HWND hwndChild = WinQueryWindow(hwnd, QW_TOP);
    2096 
    2097     win32wndchild = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndChild);
    2098     if(win32wndchild == NULL) {
    2099         DebugInt3();
    2100         goto RunDefWndProc;
    2101     }
    2102     //now get the parent window object
    2103     win32wnd = Win32BaseWindow::GetWindowFromHandle(GetParent(win32wndchild->getWindowHandle()));
    2104     if(win32wndchild) RELEASE_WNDOBJ(win32wndchild);
    2105 
     2094    win32wnd = Win32FakeWindow::GetWindowFromOS2Handle(hwnd);
    21062095    if(win32wnd == NULL) {
    21072096        DebugInt3();
     
    22072196//******************************************************************************
    22082197//******************************************************************************
    2209 static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes) 
     2198static char *PMDragExtractFiles(PDRAGINFO pDragInfo, ULONG *pcItems, ULONG *pulBytes)
    22102199{
    22112200    PDRAGITEM pDragItem;
     
    22252214
    22262215    //computer memory required to hold all filenames
    2227     int bufsize = 0;       
     2216    int bufsize = 0;
    22282217    for (i = 0; i < cItems; i++) {
    22292218        pDragItem = DrgQueryDragitemPtr(pDragInfo, i);
     
    22402229        goto failure;
    22412230    }
    2242     memset(pszFiles, 0, bufsize); 
     2231    memset(pszFiles, 0, bufsize);
    22432232
    22442233    pszCurFile = pszFiles;
     
    22852274//******************************************************************************
    22862275//******************************************************************************
    2287 static BOOL PMDragValidate(PDRAGINFO pDragInfo) 
     2276static BOOL PMDragValidate(PDRAGINFO pDragInfo)
    22882277{
    22892278    PDRAGITEM pDragItem;
     
    23242313
    23252314        dprintf(("dropped file %s%s", szContainerName, szFileName));
    2326         break; 
     2315        break;
    23272316    }
    23282317
     
    23472336failure:
    23482337    DrgFreeDraginfo(pDragInfo);
    2349     return FALSE;   
     2338    return FALSE;
    23502339}
    23512340
     
    23762365{
    23772366    static char szSWPFlags[512];
    2378  
     2367
    23792368    szSWPFlags[0] = 0;
    23802369
     
    24022391    if(flags & SWP_ACTIVATE) {
    24032392        strcat(szSWPFlags, "SWP_ACTIVATE ");
    2404     }                                   
     2393    }
    24052394    if(flags & SWP_DEACTIVATE) {
    24062395        strcat(szSWPFlags, "SWP_DEACTIVATE ");
  • trunk/src/user32/user32dbg.def

    r9889 r10031  
    1 ; $Id: user32dbg.def,v 1.11 2003-03-03 16:36:26 sandervl Exp $
     1; $Id: user32dbg.def,v 1.12 2003-04-23 18:00:59 sandervl Exp $
    22
    33LIBRARY USER32 INITINSTANCE TERMINSTANCE
     
    3636;;;; Present in WGSS50
    3737;;;;    _GpiQueryDCData             = PMGPI.665
     38
     39    WinQueryProperty  = PMMERGE.5450
     40    WinRemoveProperty = PMMERGE.5451
     41    WinSetProperty    = PMMERGE.5452
    3842
    3943EXPORTS
  • trunk/src/user32/win32wbase.cpp

    r10013 r10031  
    1 /* $Id: win32wbase.cpp,v 1.366 2003-04-11 15:22:33 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.367 2003-04-23 18:00:59 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    23612361    dwOldStyle = getStyle();
    23622362
     2363    /*
     2364     * SW_SHOWDEFAULT is an reference to the startup info wShowWindow member.
     2365     */
     2366    if (nCmdShow == SW_SHOWDEFAULT)
     2367    {
     2368        nCmdShow = GetProcessDword(0, GPD_STARTF_SHOWWINDOW);
     2369        dprintf(("ShowWindow: GetProcessDword(0, GPD_STARTF_SHOWWINDOW) -> %x", nCmdShow));
     2370    }
     2371 
     2372
    23632373    switch(nCmdShow)
    23642374    {
  • trunk/src/user32/win32wbaseprop.cpp

    r3493 r10031  
    1 /* $Id: win32wbaseprop.cpp,v 1.1 2000-05-05 11:32:38 sandervl Exp $ */
     1/* $Id: win32wbaseprop.cpp,v 1.2 2003-04-23 18:01:00 sandervl Exp $ */
    22/*
    33 * Window properties
     
    9292    {
    9393        /* We need to create it */
    94         if (!(prop = (PROPERTY *)HeapAlloc(GetProcessHeap(), 0, sizeof(*prop) )))
     94        if (!(prop = (PROPERTY *)_smalloc(sizeof(*prop) )))
    9595        {
    9696             dprintf(("setProp: malloc failed!!"));
     
    9999        if(HIWORD(str))
    100100        {
    101              if (!(prop->string = HEAP_strdupA(GetProcessHeap(), 0, str)))
     101             unsigned cch = strlen(str) + 1;
     102             if (!(prop->string = (LPSTR)_smalloc(cch)))
    102103             {
    103                 HeapFree( GetProcessHeap(), 0, prop );
     104                _sfree(prop);
    104105                return FALSE;
    105106             }
     107             memcpy(prop->string, str, cch);
    106108        }
    107109        else prop->string = (char *)str;  //atom
     
    158160    *pprop = prop->next;
    159161    if(HIWORD(prop->string))
    160         HeapFree(GetProcessHeap(), 0, prop->string);
    161     HeapFree( GetProcessHeap(), 0, prop );
     162        _sfree(prop->string);
     163    _sfree(prop);
    162164    return handle;
    163165}
     
    176178        next = prop->next;
    177179        if(HIWORD(prop->string))
    178             HeapFree(GetProcessHeap(), 0, prop->string);
    179         HeapFree(GetProcessHeap(), 0, prop);
     180            _sfree(prop->string);
     181        _sfree(prop);
    180182    }
    181183    propertyList = NULL;
  • trunk/src/user32/win32wfake.cpp

    r9941 r10031  
    1 /* $Id: win32wfake.cpp,v 1.2 2003-03-27 10:42:42 sandervl Exp $ */
     1/* $Id: win32wfake.cpp,v 1.3 2003-04-23 18:01:01 sandervl Exp $ */
    22/*
    33 * Win32 Fake Window Class for OS/2
     
    2424#include "dbglocal.h"
    2525
    26 //******************************************************************************
    27 //******************************************************************************
     26/** The Odin HWND Property - must be unique for this (custom)build. */
     27char Win32FakeWindow::szPropOdinHandle[64] = "OdinFakeHWND";
     28/** Flag which tells if we've inited or not. */
     29BOOL Win32FakeWindow::fInited = FALSE;
     30
     31/**
     32 * Creates a fake Odin window for an existing OS/2 window.
     33 *
     34 * @returns odin handle to the fake window.
     35 * @returns NULL on failure.
     36 * @param   hwndOS2     Window handle.
     37 * @param   classAtom   The atom of the Odin window class.
     38 * @author  Sander van Leeuwen <sandervl@innotek.de>
     39 * @author  knut st. osmundsen <bird@anduin.net>
     40 */
    2841HWND WIN32API CreateFakeWindowEx(HWND  hwndOS2, ATOM  classAtom)
    2942{
    3043    Win32FakeWindow *window;
    3144
     45    /*
     46     * Check if already faked - fail.
     47     */
     48    window = Win32FakeWindow::GetWindowFromOS2Handle(hwndOS2);
     49    if (window)
     50    {
     51        dprintf(("CreateFakeWindowEx: already faked!!! (hwndOS2=%x hwndOdin=%x)",
     52                 hwndOS2, window->getOS2WindowHandle()));
     53        return NULL;
     54    }
     55
     56    /*
     57     * Now proceed.
     58     */
    3259    window = new Win32FakeWindow(hwndOS2, classAtom);
    33     if(window == NULL)
    34     {
    35         dprintf(("Win32FakeWindow creation failed!!"));
     60    if (window == NULL)
     61    {
     62        dprintf(("Win32FakeWindow creation failed for %x!!!", hwndOS2));
    3663        return 0;
    3764    }
    3865    HWND hwnd = window->getWindowHandle();
    39  
     66
    4067    // set myself as last active popup / window
    4168    window->setLastActive( hwnd );
    42  
     69
    4370    RELEASE_WNDOBJ(window);
     71    dprintf(("CreateFakeWindowEx: created %x for %x", hwnd, hwndOS2));
    4472    return hwnd;
    4573}
     
    5179
    5280    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    53     if(!window) {
     81    if (!window) {
    5482        dprintf(("DestroyFakeWindow, window %x not found", hwnd));
    5583        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    6492                     : Win32BaseWindow()
    6593{
     94    if (!fInited)  init();
     95
    6696    OS2Hwnd = OS2HwndFrame = hwndOS2;
    6797
     
    93123    OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
    94124
     125    //Store the window handle as a property of the OS/2 window.
     126    if (!OSLibSetProperty(OS2Hwnd, szPropOdinHandle, (void*)getWindowHandle(), 0))
     127    {
     128        dprintf(("%s: f**k! WinSetProperty(%x,%s,%x,0) failed!!!", __FUNCTION__,
     129                 hwndOS2, szPropOdinHandle, getWindowHandle()));
     130    }
     131
     132    //See if parent window is either odin or fake window.
     133    Win32BaseWindow * pParent = NULL;
     134    HWND hwndParentOS2 = OSLibWinQueryWindow(OS2Hwnd, QWOS_PARENT);
     135    if (hwndParentOS2 != OSLIB_HWND_DESKTOP)
     136    {
     137        pParent = Win32FakeWindow::GetWindowFromOS2Handle(hwndParentOS2);
     138        if (!pParent)
     139            pParent = Win32BaseWindow::GetWindowFromOS2Handle(hwndParentOS2);
     140        if (pParent)
     141        {
     142            setParent(pParent);
     143            dprintf(("%s: hwndParentOS2=%x %s window, set as parent.", __FUNCTION__,
     144                     hwndParentOS2, pParent->isFakeWindow() ? "fake" : "odin"));
     145            dwStyle |= WS_CHILD;
     146        }
     147        else
     148        {
     149            dprintf(("%s: hwndParentOS2=%x but not a fake nor odin window.", __FUNCTION__, hwndParentOS2));
     150        }
     151    }
     152
     153    //See if owner widnow is either odin or fake window.
     154    HWND hwndOwnerOS2 = OSLibWinQueryWindow(OS2Hwnd, QWOS_OWNER);
     155    if (hwndOwnerOS2 != OSLIB_HWND_DESKTOP)
     156    {
     157        Win32BaseWindow * pOwner;
     158        if (hwndOwnerOS2 == hwndParentOS2)
     159            pOwner = pParent;
     160        else
     161        {
     162            pOwner = Win32FakeWindow::GetWindowFromOS2Handle(hwndOwnerOS2);
     163            if (!pOwner)
     164                pOwner = Win32BaseWindow::GetWindowFromOS2Handle(hwndOwnerOS2);
     165        }
     166        if (pOwner)
     167        {
     168            setOwner(pOwner);
     169            dprintf(("%s: hwndOwnerOS2=%x %s window, set as owner.", __FUNCTION__,
     170                     hwndOwnerOS2, pOwner->isFakeWindow() ? "fake" : "odin"));
     171            dwStyle |= WS_CHILD;
     172        }
     173        else
     174        {
     175            dprintf(("%s: hwndOwnerOS2=%x but not a fake nor odin window.", __FUNCTION__, hwndOwnerOS2));
     176        }
     177    }
     178
     179
    95180    setOldPMWindowProc(PMWinSubclassFakeWindow(OS2Hwnd));
    96181}
     
    99184Win32FakeWindow::~Win32FakeWindow()
    100185{
    101 
     186    OSLibRemoveProperty(OS2Hwnd, szPropOdinHandle);
    102187}
    103188//******************************************************************************
    104189//******************************************************************************
    105190PRECT Win32FakeWindow::getWindowRect()
    106 { 
     191{
    107192    //the coordinates can change without us being notified, so recheck every time
    108     OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
    109     return &rectWindow;
    110 }
    111 //******************************************************************************
    112 //******************************************************************************
    113 BOOL Win32FakeWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx,
     193
     194    Win32BaseWindow * pParent = getParent();
     195    if (pParent)
     196    {
     197        SWP     swp;
     198        if (OSLibWinQueryWindowPos(OS2Hwnd, &swp))
     199        {
     200            ULONG y = pParent->getWindowHeight();
     201            rectWindow.left   = swp.x;
     202            rectWindow.right  = swp.x + swp.cx;
     203            rectWindow.top    = y - swp.y - swp.cy;
     204            rectWindow.bottom = y - swp.y;
     205        }
     206    }
     207    else
     208        OSLibQueryWindowRectAbsolute(OS2Hwnd, &rectWindow);
     209
     210    return &rectWindow;
     211}
     212//******************************************************************************
     213//******************************************************************************
     214BOOL Win32FakeWindow::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx,
    114215                                   int cy, UINT fuFlags, BOOL fShowWindow)
    115216{
     217    // we don't trust input either.
    116218    dprintf(("Win32FakeWindow::SetWindowPos; don't change window position, just update internal position"));
    117219
    118     //We pretend this window has no parent and its position is in screen coordinates
    119220    OSLibWinQueryWindowClientRect(OS2Hwnd, &rectClient);
    120     OSLibQueryWindowRectAbsolute (OS2Hwnd, &rectWindow);
    121 
     221    getWindowRect();
    122222    return TRUE;
    123223}
     
    130230//******************************************************************************
    131231//******************************************************************************
     232
     233/**
     234 * Locates window in linked list and increases reference count if found.
     235 * The window object msut be unreferenced after usage.
     236 *
     237 * @returns Pointer to fake window.
     238 * @returns NULL if not found.
     239 * @param   hwndOS2     OS/2 window handle of the fake window.
     240 */
     241Win32FakeWindow *Win32FakeWindow::GetWindowFromOS2Handle(HWND hwndOS2)
     242{
     243    if (fInited)    init();
     244
     245    HWND hwnd = (HWND)OSLibQueryProperty(hwndOS2, szPropOdinHandle);
     246    Win32BaseWindow *pWindow = GetWindowFromHandle(hwnd);
     247    if (pWindow)
     248    {
     249        if (pWindow->isFakeWindow())
     250            return (Win32FakeWindow*)pWindow;
     251        DebugInt3();
     252    }
     253    dprintf(("Win32FakeWindow::GetWindowFromOS2Handle(%x) -> null", hwndOS2));
     254    return NULL;
     255}
     256
     257
     258/**
     259 * Init the global(s).
     260 * It will make the name property unique among the odin instances.
     261 *
     262 * This will chagne szPropOdinHandle and fInited.
     263 */
     264void     Win32FakeWindow::init()
     265{
     266    if (fInited)
     267        return;
     268
     269    /*
     270     * Get the name of this dll.
     271     */
     272    extern int _System DosQueryModFromEIP(HMODULE *phMod, ULONG *pObjNum, ULONG BuffLen, PCHAR pBuff, ULONG *pOffset, ULONG Address);
     273    char        szModName[260];
     274    HMODULE     hmod;
     275    ULONG       iObj, offObj;
     276    USHORT      GetFS();
     277    int rc = DosQueryModFromEIP(&hmod, &iObj, sizeof(szModName), &szModName[0], &offObj, (ULONG)Win32FakeWindow::init);
     278    SetFS(rc);
     279    if (rc)
     280    {
     281        dprintf(("Win32FakeWindow::init: DosQueryModFromEIP failed!!!"));
     282        DebugInt3();
     283        return;
     284    }
     285    char *psz = strrchr(szModName, '\\');
     286    if (!psz)
     287        psz = szModName;
     288    if (strchr(szModName, '.'))
     289        *strchr(szModName, '.') = '\0';
     290
     291    fInited = 1;
     292    strcat(szPropOdinHandle, psz);
     293    dprintf(("Win32FakeWindow::init: szPropOdinHandle='%s'", szPropOdinHandle));
     294}
     295
  • trunk/src/user32/win32wfake.h

    r9941 r10031  
    1 /* $Id: win32wfake.h,v 1.2 2003-03-27 10:42:42 sandervl Exp $ */
     1/* $Id: win32wfake.h,v 1.3 2003-04-23 18:01:01 sandervl Exp $ */
    22/*
    33 * Win32 Fake Window Class for OS/2
     
    2626virtual  BOOL   isFakeWindow();
    2727
     28static Win32FakeWindow *GetWindowFromOS2Handle(HWND hwnd);
     29static void     init();
     30static char     szPropOdinHandle[64];
     31static BOOL     fInited;
     32
    2833protected:
    2934private:
Note: See TracChangeset for help on using the changeset viewer.