Ignore:
Timestamp:
Dec 24, 1999, 7:42:46 PM (26 years ago)
Author:
sandervl
Message:

Message handling rewrite

File:
1 edited

Legend:

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

    r2189 r2200  
    1 /* $Id: pmwindow.cpp,v 1.68 1999-12-22 18:09:31 cbratschi Exp $ */
     1/* $Id: pmwindow.cpp,v 1.69 1999-12-24 18:39:10 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    1717#include <os2wrap.h>
    1818#include <stdlib.h>
     19#include <string.h>
    1920#include "win32type.h"
    2021#include <winconst.h>
     
    4344ULONG ScreenBitsPerPel = 0;
    4445
    45 //Used for key translation while processing WM_CHAR message
    46 USHORT virtualKeyTable [66] = {
    47                0x00,    //   OS/2 VK         Win32 VK,    Entry 0 is not used
    48                0x01,    // VK_BUTTON1       VK_LBUTTON
    49                0x02,    // VK_BUTTON2       VK_RBUTTON
    50                0x04,    // VK_BUTTON3       VK_MBUTTON
    51                0x03,    // VK_BREAK         VK_CANCEL
    52                0x08,    // VK_BACKSPACE     VK_BACK
    53                0x09,    // VK_TAB           VK_TAB
    54                0x00,    // VK_BACKTAB       No equivalent!
    55                0x0A,    // VK_NEWLINE       0x0A (no VK_* def)
    56                0x10,    // VK_SHIFT         VK_SHIFT
    57                0x11,    // VK_CTRL          VK_CONTROL
    58                0x12,    // VK_ALT           VK_MENU, best match I guess
    59                0x12,    // VK_ALTGRAF       VK_MENU, best match I guess
    60                0x13,    // VK_PAUSE         VK_PAUSE
    61                0x14,    // VK_CAPSLOCK      VK_CAPITAL
    62                0x1B,    // VK_ESC           VK_ESCAPE
    63                0x20,    // VK_SPACE         VK_SPACE
    64                0x21,    // VK_PAGEUP        VK_PRIOR
    65                0x22,    // VK_PAGEDOWN      VK_NEXT
    66                0x23,    // VK_END           VK_END
    67                0x24,    // VK_HOME          VK_HOME
    68                0x25,    // VK_LEFT          VK_LEFT
    69                0x26,    // VK_UP            VK_UP
    70                0x27,    // VK_RIGHT         VK_RIGHT
    71                0x28,    // VK_DOWN          VK_DOWN
    72                0x2C,    // VK_PRINTSCRN     VK_SNAPSHOT
    73                0x2D,    // VK_INSERT        VK_INSERT
    74                0x2E,    // VK_DELETE        VK_DELETE
    75                0x91,    // VK_SCRLLOCK      VK_SCROLL
    76                0x90,    // VK_NUMLOCK       VK_NUMLOCK
    77                0x0D,    // VK_ENTER         VK_RETURN
    78                0x00,    // VK_SYSRQ         No equivalent!
    79                0x70,    // VK_F1            VK_F1
    80                0x71,    // VK_F2            VK_F2
    81                0x72,    // VK_F3            VK_F3
    82                0x73,    // VK_F4            VK_F4
    83                0x74,    // VK_F5            VK_F5
    84                0x75,    // VK_F6            VK_F6
    85                0x76,    // VK_F7            VK_F7
    86                0x77,    // VK_F8            VK_F8
    87                0x78,    // VK_F9            VK_F9
    88                0x79,    // VK_F10           VK_F10
    89                0x7A,    // VK_F11           VK_F11
    90                0x7B,    // VK_F12           VK_F12
    91                0x7C,    // VK_F13           VK_F13
    92                0x7D,    // VK_F14           VK_F14
    93                0x7E,    // VK_F15           VK_F15
    94                0x7F,    // VK_F16           VK_F16
    95                0x80,    // VK_F17           VK_F17
    96                0x81,    // VK_F18           VK_F18
    97                0x82,    // VK_F19           VK_F19
    98                0x83,    // VK_F20           VK_F20
    99                0x84,    // VK_F21           VK_F21
    100                0x85,    // VK_F22           VK_F22
    101                0x86,    // VK_F23           VK_F23
    102                0x87,    // VK_F24           VK_F24
    103                0x00,    // VK_ENDDRAG       No equivalent!
    104                0x0C,    // VK_CLEAR         VK_CLEAR
    105                0xF9,    // VK_EREOF         VK_EREOF
    106                0xFD,    // VK_PA1           VK_PA1
    107                0xF6,    // VK_ATTN          VK_ATTN
    108                0xF7,    // VK_CRSEL         VK_CRSEL
    109                0xF8,    // VK_EXSEL         VK_EXSEL
    110                0x00,    // VK_COPY          No equivalent!
    111                0x00,    // VK_BLK1          No equivalent!
    112                0x00};   // VK_BLK2          No equivalent!
    11346
    11447MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
     
    202135 OSLIBPOINT       point, ClientPoint;
    203136 Win32BaseWindow *win32wnd;
     137 THDB            *thdb;
    204138 APIRET           rc;
     139 MSG              winMsg, *pWinMsg;
    205140
    206141  //Restore our FS selector
    207142  SetWin32TIB();
    208143
     144  thdb = GetThreadTHDB();
    209145  win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    210146
    211   if(msg != WM_CREATE && win32wnd == NULL) {
    212         dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
    213         goto RunDefWndProc;
    214   }
     147  if(!thdb || (msg != WM_CREATE && win32wnd == NULL)) {
     148        dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     149        goto RunDefWndProc;
     150  }
     151
     152  if((thdb->msgstate & 1) == 0)
     153  {//message that was sent directly to our window proc handler; translate it here
     154        QMSG qmsg;
     155
     156        qmsg.msg  = msg;
     157        qmsg.hwnd = hwnd;
     158        qmsg.mp1  = mp1;
     159        qmsg.mp2  = mp2;
     160        qmsg.time = WinQueryMsgTime(thdb->hab);
     161        WinQueryMsgPos(thdb->hab, &qmsg.ptl);
     162        qmsg.reserved = 0;
     163
     164        if(OS2ToWinMsgTranslate((PVOID)thdb, &qmsg, &winMsg, FALSE, ODINMSG_NOEXTRAMSGS) == FALSE)
     165        {//message was not translated
     166            memset(&winMsg, 0, sizeof(MSG));
     167        }
     168        pWinMsg = &winMsg;
     169  }
     170  else {
     171        pWinMsg = &thdb->msg;
     172        thdb->msgstate++;
     173  }
     174
    215175  if(msg == WIN32APP_POSTMSG && (ULONG)mp1 == WIN32PM_MAGIC) {
    216176        //win32 app user message
     
    222182    case WM_CREATE:
    223183    {
    224      THDB *thdb = GetThreadTHDB();
    225 
    226         if(thdb == NULL || thdb->newWindow == 0)
     184
     185        if(thdb->newWindow == 0)
    227186            goto createfail;
    228187
     
    230189        dprintf(("OS2: WM_CREATE %x", hwnd));
    231190        win32wnd = (Win32BaseWindow *)thdb->newWindow;
     191        thdb->newWindow = 0;
    232192
    233193        if(win32wnd->MsgCreate(WinQueryWindow(hwnd, QW_PARENT), hwnd) == FALSE)
     
    250210    case WM_CLOSE:
    251211        dprintf(("OS2: WM_CLOSE %x", hwnd));
    252 //        win32wnd->RemoveFakeOpen32();
    253212        if(win32wnd->MsgClose()) {
    254213                goto RunDefWndProc;
     
    280239    case WM_ADJUSTWINDOWPOS:
    281240    {
    282       PSWP     pswp = (PSWP)mp1;
    283 
    284         dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     241//      PSWP     pswp = (PSWP)mp1;
     242
     243//        dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", hwnd, pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    285244        goto RunDefWndProc;
    286245    }
     
    341300#endif
    342301
    343 #if 1
    344302    case WM_WINDOWPOSCHANGED:
    345303    {
    346       PSWP      pswp  = (PSWP)mp1;
    347       SWP       swpOld = *(pswp + 1);
    348       WINDOWPOS wp;
    349       HWND      hParent = NULLHANDLE;
    350       LONG      yDelta = pswp->cy - swpOld.cy;
    351       LONG      xDelta = pswp->cx - swpOld.cx;
    352 
    353         dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    354 
    355         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto RunDefWndProc;
    356 
    357         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    358             if (win32wnd->isChild()) {
    359                 if(win32wnd->getParent()) {
    360                         hParent = win32wnd->getParent()->getOS2WindowHandle();
    361                 }
    362                 else    goto RunDefWndProc; //parent has just been destroyed
    363             }
    364         }
    365         OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, hParent, win32wnd->getOS2FrameWindowHandle());
    366 
    367         if (!win32wnd->CanReceiveSizeMsgs())    goto RunDefWndProc;
    368 
    369         dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
    370         win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
    371 
    372         wp.hwnd = win32wnd->getWindowHandle();
    373         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    374         {
    375            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    376            wp.hwndInsertAfter = wndAfter->getWindowHandle();
    377         }
    378 
    379         PRECT lpRect = win32wnd->getWindowRect();
    380         //SvL: Only send it when the client has changed & the frame hasn't
    381         //     If the frame size/position has changed, pmframe.cpp will send
    382         //     this message
    383         if(lpRect->right == wp.x+wp.cx && lpRect->bottom == wp.y+wp.cy) {
    384                 win32wnd->MsgPosChanged((LPARAM)&wp);
    385         }
    386         else    win32wnd->setWindowRect(wp.x, wp.y, wp.x+wp.cx, wp.y+wp.cy);
    387 
    388         goto RunDefWndProc;
    389     }
    390 #endif
     304        win32wnd->MsgPosChanged((LPARAM)&thdb->wp);
     305        goto RunDefWndProc;
     306    }
    391307
    392308    case WM_ACTIVATE:
     
    412328    }
    413329
    414     case WM_SIZE:
    415     {
    416         dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
    417         break;
    418     }
    419     case WM_MINMAXFRAME:
    420     {
    421         dprintf(("OS2: WM_MINMAXFRAME"));
    422         break;
    423     }
    424     case WM_OWNERPOSCHANGE:
    425     {
    426         dprintf(("OS2: WM_OWNERPOSCHANGE"));
    427         goto RunDefWndProc;
    428     }
    429 
    430     case WM_CALCVALIDRECTS:
    431     {
    432         dprintf(("OS2: WM_CALCVALIDRECTS"));
    433         goto RunDefWndProc;
    434     }
    435 
    436     case WM_FOCUSCHANGE:
    437         dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
    438         goto RunDefWndProc;
    439 
    440330    case WM_SETFOCUS:
    441331    {
     
    464354    //**************************************************************************
    465355    case WM_BUTTON1DOWN:
    466         dprintf(("OS2: WM_BUTTON1DOWN %x", hwnd));
    467         point.x = (*(POINTS *)&mp1).x;
    468         point.y = (*(POINTS *)&mp1).y;
    469         ClientPoint.x = point.x;
    470         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    471         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    472         if(win32wnd->MsgButton(BUTTON_LEFTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    473                 goto RunDefWndProc;
    474         }
    475         break;
    476 
    477356    case WM_BUTTON1UP:
    478         dprintf(("OS2: WM_BUTTON1UP %x", hwnd));
    479         point.x = (*(POINTS *)&mp1).x;
    480         point.y = (*(POINTS *)&mp1).y;
    481         ClientPoint.x = point.x;
    482         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    483         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    484         if(win32wnd->MsgButton(BUTTON_LEFTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    485                 goto RunDefWndProc;
    486         }
    487         break;
    488357    case WM_BUTTON1DBLCLK:
    489         point.x = (*(POINTS *)&mp1).x;
    490         point.y = (*(POINTS *)&mp1).y;
    491         ClientPoint.x = point.x;
    492         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    493         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    494         if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    495                 goto RunDefWndProc;
    496         }
    497         break;
    498358    case WM_BUTTON2DOWN:
    499         point.x = (*(POINTS *)&mp1).x;
    500         point.y = (*(POINTS *)&mp1).y;
    501         ClientPoint.x = point.x;
    502         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    503         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    504         if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    505                 goto RunDefWndProc;
    506         }
    507         break;
    508359    case WM_BUTTON2UP:
    509         point.x = (*(POINTS *)&mp1).x;
    510         point.y = (*(POINTS *)&mp1).y;
    511         ClientPoint.x = point.x;
    512         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    513         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    514         if(win32wnd->MsgButton(BUTTON_RIGHTUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    515                 goto RunDefWndProc;
    516         }
    517         break;
    518360    case WM_BUTTON2DBLCLK:
    519         point.x = (*(POINTS *)&mp1).x;
    520         point.y = (*(POINTS *)&mp1).y;
    521         ClientPoint.x = point.x;
    522         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    523         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    524         if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    525                 goto RunDefWndProc;
    526         }
    527         break;
    528361    case WM_BUTTON3DOWN:
    529         point.x = (*(POINTS *)&mp1).x;
    530         point.y = (*(POINTS *)&mp1).y;
    531         ClientPoint.x = point.x;
    532         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    533         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    534         if(win32wnd->MsgButton(BUTTON_MIDDLEDOWN, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    535                 goto RunDefWndProc;
    536         }
    537         break;
    538362    case WM_BUTTON3UP:
    539         point.x = (*(POINTS *)&mp1).x;
    540         point.y = (*(POINTS *)&mp1).y;
    541         ClientPoint.x = point.x;
    542         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    543         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    544         if(win32wnd->MsgButton(BUTTON_MIDDLEUP, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
    545                 goto RunDefWndProc;
    546         }
    547         break;
    548363    case WM_BUTTON3DBLCLK:
    549         point.x = (*(POINTS *)&mp1).x;
    550         point.y = (*(POINTS *)&mp1).y;
    551         ClientPoint.x = point.x;
    552         ClientPoint.y = MapOS2ToWin32Y(hwnd, 1, point.y);
    553         MapOS2ToWin32Point(OSLIB_HWND_DESKTOP, hwnd, &point);
    554         if(win32wnd->MsgButton(BUTTON_MIDDLEDBLCLICK, point.x, point.y, ClientPoint.x, ClientPoint.y)) {
     364        if(win32wnd->MsgButton(pWinMsg)) {
    555365                goto RunDefWndProc;
    556366        }
     
    570380    case WM_MOUSEMOVE:
    571381    {
    572         ULONG keystate = 0;
    573         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON1) & 0x8000)
    574             keystate |= WMMOVE_LBUTTON;
    575         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON2) & 0x8000)
    576             keystate |= WMMOVE_MBUTTON;
    577         if(WinGetKeyState(HWND_DESKTOP, VK_BUTTON3) & 0x8000)
    578             keystate |= WMMOVE_RBUTTON;
    579         if(WinGetKeyState(HWND_DESKTOP, VK_SHIFT) & 0x8000)
    580             keystate |= WMMOVE_SHIFT;
    581         if(WinGetKeyState(HWND_DESKTOP, VK_CTRL) & 0x8000)
    582             keystate |= WMMOVE_CTRL;
    583 
    584382        //OS/2 Window coordinates -> Win32 Window coordinates
    585         win32wnd->MsgMouseMove(keystate, SHORT1FROMMP(mp1), MapOS2ToWin32Y(win32wnd, SHORT2FROMMP(mp1)));
     383        win32wnd->MsgMouseMove(pWinMsg);
    586384        break;
    587385    }
    588386
    589387    case WM_CONTROL:
    590 
    591388    case WM_COMMAND:
    592         if(SHORT1FROMMP(mp2) == CMDSRC_MENU) {
    593             win32wnd->MsgCommand(CMD_MENU, SHORT1FROMMP(mp1), 0);
    594         }
    595         if(SHORT1FROMMP(mp2) == CMDSRC_ACCELERATOR) {
    596             win32wnd->MsgCommand(CMD_ACCELERATOR, SHORT1FROMMP(mp1), 0);
    597         }
     389        dprintf(("OS2: WM_COMMAND %x %x %x", hwnd, mp1, mp2));
     390        win32wnd->DispatchMsg(pWinMsg);
    598391        //todo controls + accelerators
    599392        break;
     
    601394    case WM_SYSCOMMAND:
    602395    {
    603       ULONG x = 0, y = 0;
    604       ULONG win32sc;
    605 
    606         if(SHORT2FROMMP(mp2) == TRUE) {//syscommand caused by mouse action
    607             POINTL pointl;
    608             WinQueryPointerPos(HWND_DESKTOP, &pointl);
    609             x = pointl.x;
    610             y = ScreenHeight - y;
    611         }
    612         switch(SHORT1FROMMP(mp1)) {
    613         case SC_MOVE:
    614             win32sc = SC_MOVE_W;
    615             break;
    616         case SC_CLOSE:
    617             win32sc = SC_CLOSE_W;
    618             break;
    619         case SC_MAXIMIZE:
    620             win32sc = SC_MAXIMIZE_W;
    621             break;
    622         case SC_MINIMIZE:
    623             win32sc = SC_MINIMIZE_W;
    624             break;
    625         case SC_NEXTFRAME:
    626         case SC_NEXTWINDOW:
    627             win32sc = SC_NEXTWINDOW_W;
    628             break;
    629         case SC_RESTORE:
    630             win32sc = SC_RESTORE_W;
    631             break;
    632         case SC_TASKMANAGER:
    633             win32sc = SC_TASKLIST_W;
    634             break;
    635         default:
     396        if(win32wnd->DispatchMsg(pWinMsg)) {
    636397            goto RunDefWndProc;
    637398        }
    638         dprintf(("WM_SYSCOMMAND %x %x (%d,%d)", hwnd, win32sc, x, y));
    639         if(win32wnd->MsgSysCommand(win32sc, x, y)) {
    640             goto RunDefWndProc;
    641         }
    642399        break;
    643400    }
    644401    case WM_CHAR:
    645402    {
    646         THDB *thdb;
    647         ULONG repeatCount=0, virtualKey=0, keyFlags=0, scanCode=0;
    648         ULONG flags = SHORT1FROMMP(mp1);
    649         BOOL keyWasPressed, fTranslated = FALSE, fRunDefWndProc = FALSE;
    650 
    651         char c;
    652 
    653         repeatCount = CHAR3FROMMP(mp1);
    654         scanCode = CHAR4FROMMP(mp1);
    655         keyWasPressed = ((SHORT1FROMMP (mp1) & KC_PREVDOWN) == KC_PREVDOWN);
    656 
    657         dprintf(("PM: WM_CHAR: %x %x %d %x", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), repeatCount, scanCode));
    658         dprintf(("PM: WM_CHAR: %x", flags));
    659 
    660         // vitali add begin
    661         if ( ( SHORT1FROMMP(mp2) & 0x0FF ) == 0x0E0 )
    662         {
    663             // an extended key ( arrows, ins, del and so on )
    664             // get "virtual" scancode from character code cause
    665             // for "regular" keys they are equal
    666             scanCode = ( SHORT1FROMMP(mp2) >> 8) & 0x0FF;
    667         }
    668         // vitali add end
    669 
    670         // both WM_KEYUP & WM_KEYDOWN want a virtual key, find the right Win32 virtual key
    671         // given the OS/2 virtual key and OS/2 character
    672 
    673         //if (((SHORT1FROMMP (mp1) & KC_CHAR) == KC_CHAR) ||
    674         //    ((SHORT1FROMMP (mp1) & KC_LONEKEY) == KC_LONEKEY))
    675         c = 0;
    676         if ((SHORT1FROMMP (mp1) & 0xFF) != 0)
    677         {
    678             c = SHORT1FROMMP (mp2);
    679             if ((c >= 'A') && (c <= 'Z')) {
    680                 virtualKey = c;
    681                 goto VirtualKeyFound;
    682             }
    683             if ((c >='a') && (c <= 'z')) {
    684                 virtualKey = c - 32;   // make it uppercase
    685                 goto VirtualKeyFound;
    686             }
    687             if ((c >= '0') && (c <= '9')) {
    688                 virtualKey = c;
    689                 goto VirtualKeyFound;
    690             }
    691         }
    692 
    693         // convert OS/2 virtual keys to Win32 virtual key
    694         if (SHORT2FROMMP (mp2) <= VK_BLK2)
    695             virtualKey = virtualKeyTable [SHORT2FROMMP (mp2)];
    696 
    697 VirtualKeyFound:
    698         dprintf (("VIRTUALKEYFOUND:(%x)", virtualKey));
    699 
    700         if(!(SHORT1FROMMP(mp1) & KC_ALT))
    701         {
    702             //
    703             // the Alt key is not pressed
    704             //
    705             if ((flags & KC_KEYUP) == KC_KEYUP) {
    706                 // send WM_KEYUP message
    707 
    708                 if(win32wnd->MsgKeyUp (repeatCount, scanCode, virtualKey)) {
    709                     fRunDefWndProc = TRUE;
    710                 }
    711             }
    712             else {
    713                 // send WM_KEYDOWN message
    714                 if (win32wnd->MsgKeyDown (repeatCount, scanCode,
    715                                           virtualKey, keyWasPressed))
    716                     fRunDefWndProc = TRUE;
    717             }
    718         }
    719         else {
    720             //
    721             // the Alt key is pressed
    722             //
    723             if ((flags & KC_KEYUP) == KC_KEYUP) {
    724                 // send WM_SYSKEYUP message
    725 
    726                 dprintf(("PMWINDOW_WM_SYSKEYUP: vkey:(%x)", virtualKey));
    727                 if(win32wnd->MsgSysKeyUp (repeatCount, scanCode, virtualKey)) {
    728                     fRunDefWndProc = TRUE;
    729                 }
    730             }
    731             else {
    732                 // send WM_SYSKEYDOWN message
    733                 dprintf(("PMWINDOW_WM_SYSKEYDOWN: vkey:(%x)", virtualKey));
    734                 if (win32wnd->MsgSysKeyDown (repeatCount, scanCode, virtualKey, keyWasPressed))
    735                     fRunDefWndProc = TRUE;
    736             }
    737         }
    738 
    739         thdb = GetThreadTHDB();
    740         if(thdb) {
    741             fTranslated = thdb->fMsgTranslated;
    742             thdb->fMsgTranslated = FALSE;  //reset flag
    743         }
    744         //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains
    745         //      the newly generated WM_CHAR message.
    746         if(fTranslated && !((flags & KC_KEYUP) == KC_KEYUP))
    747         {//TranslatedMessage was called before DispatchMessage, so send WM_CHAR messages
    748             ULONG keyflags = 0, vkey = 0;
    749             ULONG fl = SHORT1FROMMP(mp1);
    750             ULONG chCode = SHORT1FROMMP(mp2);
    751 
    752             if(!(fl & KC_CHAR)) {
    753 //SvL: Test
    754                 break;
    755 //                goto RunDefWndProc;
    756             }
    757             if(fl & KC_VIRTUALKEY) {
    758                 if(virtualKey)
    759                         vkey = virtualKey;
    760                 else    vkey = SHORT2FROMMP(mp2);
    761                 chCode = vkey;
    762             }
    763             if(fl & KC_KEYUP) {
    764                 keyflags |= KEY_UP;
    765             }
    766             if(fl & KC_ALT) {
    767                 keyflags |= KEY_ALTDOWN;
    768             }
    769             if(fl & KC_PREVDOWN) {
    770                 keyflags |= KEY_PREVDOWN;
    771             }
    772             if(fl & KC_DEADKEY) {
    773                 keyflags |= KEY_DEADKEY;
    774             }
    775             if(win32wnd->MsgChar(chCode, CHAR3FROMMP(mp1), CHAR4FROMMP(mp1), virtualKey, keyflags)) {
    776 //SvL: Test
    777 //                goto RunDefWndProc;
    778 
    779             }
    780         }
    781 //SvL: Test
    782 //        if(fRunDefWndProc) goto RunDefWndProc;
     403        win32wnd->DispatchMsg(pWinMsg);
    783404        break;
    784405    }
    785406
    786407    case WM_INITMENU:
    787         win32wnd->MsgInitMenu((HWND)mp2);
    788         break;
     408        win32wnd->MsgInitMenu(pWinMsg);
     409        break;
     410
     411    case WM_TIMER:
     412        win32wnd->DispatchMsg(pWinMsg);
     413        goto RunDefWndProc;
    789414
    790415    case WM_MENUSELECT:
    791416    case WM_MENUEND:
    792417    case WM_NEXTMENU:
    793         goto RunDefWndProc;
    794 
    795     case WM_TIMER:
    796         if (mp2)
    797         {
    798           BOOL sys;
    799           ULONG id;
    800 
    801           dprintf(("OS2: WM_TIMER %x %d", hwnd, mp1));
    802           if (TIMER_GetTimerInfo(hwnd,(ULONG)mp1,&sys,&id))
    803           {
    804             if (sys)
    805               win32wnd->MsgSysTimer(id);
    806             else
    807               win32wnd->MsgTimer(id);
    808           }
    809         }
    810418        goto RunDefWndProc;
    811419
     
    845453    }
    846454
    847     case WM_ERASEBACKGROUND:
    848     {
    849         dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
    850 #if 1
    851         break;
    852 #else
    853 
    854         if (WinQueryUpdateRect (hwnd, NULL) && !win32wnd->isSupressErase()) {
    855             BOOL erased = sendEraseBkgnd (win32wnd);
    856             win32wnd->setEraseBkgnd (!erased, !erased);
    857         }
    858 
    859         break;
    860 #endif
    861     }
    862 
    863455    case WM_PAINT:
    864     {
    865         dprintf(("OS2: WM_PAINT %x", hwnd));
    866 
    867 #if 0
    868         if (WinQueryUpdateRect (hwnd, NULL)) {
    869             if (!win32wnd->isSupressErase() && win32wnd->isEraseBkgnd()) {
    870                 BOOL erased = sendEraseBkgnd (win32wnd);
    871                 win32wnd->setEraseBkgnd (!erased, !erased);
    872             }
    873         }
    874 
    875         win32wnd->setSupressErase (FALSE);
    876 #endif
    877 
    878         win32wnd->MsgPaint(0, 0);
    879 
    880         //validate the update region, WM_PAINT has no return value
    881         goto RunDefWndProc;
    882     }
     456        win32wnd->DispatchMsg(pWinMsg);
     457        goto RunDefWndProc;
    883458
    884459    case WM_HITTEST:
    885       // Only send this message if the window is enabled
    886       if (WinIsWindowEnabled(hwnd))
    887       {
    888         OSLIBPOINT pt;
    889         dprintf(("USER32: WM_HITTEST (%d,%d)",(*(POINTS *)&mp1).x,(*(POINTS *)&mp1).y));
    890         pt.x = (*(POINTS *)&mp1).x;
    891         pt.y = (*(POINTS *)&mp1).y;
    892         MapOS2ToWin32Point( OSLIB_HWND_DESKTOP, hwnd, &pt);
    893         if(win32wnd->MsgHitTest(pt.x, pt.y))
     460        // Only send this message if the window is enabled
     461        if (WinIsWindowEnabled(hwnd))
    894462        {
    895           goto RunDefWndProc;
    896         }
    897       } else goto RunDefWndProc;
    898       break;
     463                if(win32wnd->MsgHitTest(pWinMsg)) {
     464                    goto RunDefWndProc;
     465                }
     466        }
     467        else    goto RunDefWndProc;
    899468
    900469    case WM_CONTEXTMENU:
    901       {
    902         POINTL pt;
    903 
    904         dprintf(("OS2: WM_CONTEXTMENU %x", hwnd));
    905         pt.x = (*(POINTS *)&mp1).x;
    906         pt.y = (*(POINTS *)&mp1).y;
    907         WinMapWindowPoints(hwnd,HWND_DESKTOP,&pt,1);
    908         pt.y = WinQuerySysValue(HWND_DESKTOP,SV_CYSCREEN)-pt.y-1;
    909         win32wnd->MsgContextMenu(pt.x,pt.y);
     470    {
     471        win32wnd->DispatchMsg(pWinMsg);
    910472
    911473        RestoreOS2TIB();
    912474        return (MRESULT)TRUE;
    913       }
     475    }
     476
     477    case WM_ERASEBACKGROUND:
     478    {
     479        dprintf(("OS2: WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
     480        break;
     481    }
     482
     483    case WM_SIZE:
     484    {
     485        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
     486        break;
     487    }
     488    case WM_MINMAXFRAME:
     489    {
     490        dprintf(("OS2: WM_MINMAXFRAME"));
     491        break;
     492    }
     493    case WM_OWNERPOSCHANGE:
     494    {
     495        dprintf(("OS2: WM_OWNERPOSCHANGE"));
     496        goto RunDefWndProc;
     497    }
     498
     499    case WM_CALCVALIDRECTS:
     500    {
     501        dprintf(("OS2: WM_CALCVALIDRECTS"));
     502        goto RunDefWndProc;
     503    }
     504
     505    case WM_FOCUSCHANGE:
     506        dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
     507        goto RunDefWndProc;
    914508
    915509    case WM_SYSCOLORCHANGE:
     
    934528    case WM_SEMANTICEVENT:
    935529    default:
    936 //        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     530        //dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    937531        RestoreOS2TIB();
    938532        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
Note: See TracChangeset for help on using the changeset viewer.