Ignore:
Timestamp:
Nov 21, 2000, 12:36:09 PM (25 years ago)
Author:
sandervl
Message:

Updates for TEB changes

File:
1 edited

Legend:

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

    r3525 r4658  
    1 /* $Id: oslibmsg.cpp,v 1.33 2000-05-12 18:09:40 sandervl Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.34 2000-11-21 11:36:08 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    7878   WM_CHAR,          WINWM_KEYLAST,
    7979
    80    WM_COMMAND,       WINWM_COMMAND,
    81    WM_SYSCOMMAND,    WINWM_SYSCOMMAND,
    8280   //
    8381   WM_TIMER,         WINWM_TIMER,
    84    WM_INITMENU,      WINWM_INITMENU,
     82
    8583   //
    8684   WM_MOUSEMOVE,     WINWM_MOUSEMOVE,
     
    9997#define MAX_MSGTRANSTAB (sizeof(MsgTransTab)/sizeof(MsgTransTab[0]))
    10098
    101 LRESULT WIN32API SendMessageA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
    102 
    10399//******************************************************************************
    104100//******************************************************************************
     
    134130    }
    135131
    136     return 0;
     132    //not found, probaby WIN32APP_POSTMSG
     133    return WIN32APP_POSTMSG;
    137134}
    138135//******************************************************************************
     
    149146LONG OSLibWinDispatchMsg(MSG *msg, BOOL isUnicode)
    150147{
    151  THDB *thdb;
     148 TEB  *teb;
    152149 QMSG  os2msg;
    153150 LONG  rc;
    154151
    155   thdb = GetThreadTHDB();
    156   if(thdb == NULL) {
     152  teb = GetThreadTEB();
     153  if(teb == NULL) {
    157154        DebugInt3();
    158155        return FALSE;
     
    162159  //  WinToOS2MsgTranslate(msg, &qmsg, isUnicode);
    163160
    164   if(!memcmp(msg, &thdb->winmsg, sizeof(MSG)) || msg->hwnd == 0) {
    165         memcpy(&os2msg, &thdb->os2msg, sizeof(QMSG));
    166         thdb->os2msg.time = -1;
    167         thdb->winmsg.time = -1;
     161  if(!memcmp(msg, &teb->o.odin.winmsg, sizeof(MSG)) || msg->hwnd == 0) {
     162        memcpy(&os2msg, &teb->o.odin.os2msg, sizeof(QMSG));
     163        teb->o.odin.os2msg.time = -1;
     164        teb->o.odin.winmsg.time = -1;
    168165        if(msg->hwnd) {
    169                 thdb->nrOfMsgs = 1;
    170                 thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
    171                 memcpy(&thdb->msg, msg, sizeof(MSG));
     166                teb->o.odin.nrOfMsgs = 1;
     167                teb->o.odin.msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
     168                memcpy(&teb->o.odin.msg, msg, sizeof(MSG));
    172169        }
    173170        if(os2msg.hwnd || os2msg.msg == WM_QUIT) {
    174                 memset(&thdb->os2msg, 0, sizeof(thdb->os2msg));
    175                 memset(&thdb->winmsg, 0, sizeof(thdb->winmsg));
    176                 return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
     171                memset(&teb->o.odin.os2msg, 0, sizeof(teb->o.odin.os2msg));
     172                memset(&teb->o.odin.winmsg, 0, sizeof(teb->o.odin.winmsg));
     173                return (LONG)WinDispatchMsg(teb->o.odin.hab, &os2msg);
    177174        }
    178175        //SvL: Don't dispatch messages sent by PostThreadMessage (correct??)
     
    192189{
    193190 BOOL rc, eaten;
    194  THDB *thdb;
     191 TEB  *teb;
    195192 QMSG  os2msg;
    196193 HWND  hwndOS2 = 0;
     194 ULONG filtermin, filtermax;
    197195
    198196  if(hwnd) {
     
    206204  }
    207205
    208   thdb = GetThreadTHDB();
    209   if(thdb == NULL) {
     206  teb = GetThreadTEB();
     207  if(teb == NULL) {
    210208        DebugInt3();
    211209        return TRUE;
    212210  }
    213211
    214   if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
     212  if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) {
    215213        if(uMsgFilterMin) {
    216             if(thdb->msgWCHAR.message < uMsgFilterMin)
     214            if(teb->o.odin.msgWCHAR.message < uMsgFilterMin)
    217215                goto continuegetmsg;
    218216        }
    219217        if(uMsgFilterMax) {
    220             if(thdb->msgWCHAR.message > uMsgFilterMax)
     218            if(teb->o.odin.msgWCHAR.message > uMsgFilterMax)
    221219                goto continuegetmsg;
    222220        }
    223         thdb->fTranslated = FALSE;
    224         memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
    225         thdb->os2msg.msg  = 0;
    226         thdb->os2msg.hwnd = 0;
     221        teb->o.odin.fTranslated = FALSE;
     222        memcpy(pMsg, &teb->o.odin.msgWCHAR, sizeof(MSG));
     223        teb->o.odin.os2msg.msg  = 0;
     224        teb->o.odin.os2msg.hwnd = 0;
    227225        return (pMsg->message != WINWM_QUIT);
    228226  }
     
    230228continuegetmsg:
    231229  if(hwnd) {
     230        filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
     231        filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
     232        if(filtermin > filtermax) {
     233                ULONG tmp = filtermin;
     234                filtermin = filtermax;
     235                filtermax = filtermin;
     236        }
    232237        do {
    233             WinWaitMsg(thdb->hab, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE));
    234             rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
     238                WinWaitMsg(teb->o.odin.hab, filtermin, filtermax);
     239                rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode);
    235240        }
    236241        while(rc == FALSE);
     
    240245  else
    241246  {
    242     do {
    243         eaten = FALSE;
    244         rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
    245         if (os2msg.msg == WM_TIMER)
    246             eaten = TIMER_HandleTimer(&os2msg);
    247     } while (eaten);
    248   }
    249 
    250   OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
    251   memcpy(&thdb->os2msg, &os2msg, sizeof(QMSG));
    252   memcpy(&thdb->winmsg, pMsg, sizeof(MSG));
     247        filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
     248        filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
     249        if(filtermin > filtermax) {
     250                ULONG tmp = filtermin;
     251                filtermin = filtermax;
     252                filtermax = filtermin;
     253        }
     254        do {
     255                eaten = FALSE;
     256                rc = WinGetMsg(teb->o.odin.hab, &os2msg, filtermin, filtermax, 0);
     257                if (os2msg.msg == WM_TIMER)
     258                    eaten = TIMER_HandleTimer(&os2msg);
     259        } while (eaten);
     260  }
     261
     262  OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
     263  memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
     264  memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
    253265
    254266  if(pMsg->message <= WINWM_KEYLAST && pMsg->message >= WINWM_KEYDOWN)
     
    275287{
    276288 BOOL  rc, eaten;
    277  THDB *thdb;
     289 TEB  *teb;
    278290 QMSG  os2msg;
    279291 HWND  hwndOS2 = 0;
     
    288300  }
    289301
    290   thdb = GetThreadTHDB();
    291   if(thdb == NULL) {
     302  teb = GetThreadTEB();
     303  if(teb == NULL) {
    292304        DebugInt3();
    293305        return FALSE;
    294306  }
    295307
    296   if(thdb->fTranslated && (!hwnd || hwnd == thdb->msgWCHAR.hwnd)) {
     308  if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) {
    297309        if(uMsgFilterMin) {
    298             if(thdb->msgWCHAR.message < uMsgFilterMin)
     310            if(teb->o.odin.msgWCHAR.message < uMsgFilterMin)
    299311                goto continuepeekmsg;
    300312        }
    301313        if(uMsgFilterMax) {
    302             if(thdb->msgWCHAR.message > uMsgFilterMax)
     314            if(teb->o.odin.msgWCHAR.message > uMsgFilterMax)
    303315                goto continuepeekmsg;
    304316        }
    305317
    306318        if(fRemove & PM_REMOVE_W) {
    307             thdb->fTranslated = FALSE;
    308             thdb->os2msg.msg  = 0;
    309             thdb->os2msg.hwnd = 0;
    310         }
    311         memcpy(pMsg, &thdb->msgWCHAR, sizeof(MSG));
     319            teb->o.odin.fTranslated = FALSE;
     320            teb->o.odin.os2msg.msg  = 0;
     321            teb->o.odin.os2msg.hwnd = 0;
     322        }
     323        memcpy(pMsg, &teb->o.odin.msgWCHAR, sizeof(MSG));
    312324        return TRUE;
    313325  }
     
    316328  do {
    317329        eaten = FALSE;
    318         rc = WinPeekMsg(thdb->hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
     330        rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, TranslateWinMsg(uMsgFilterMin, TRUE),
    319331                        TranslateWinMsg(uMsgFilterMax, FALSE), (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
    320332
     
    329341  }
    330342
    331   OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE);
     343  OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE);
    332344  //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message
    333345  if(fRemove & PM_REMOVE_W) {
    334         memcpy(&thdb->os2msg, &os2msg, sizeof(QMSG));
    335         memcpy(&thdb->winmsg, pMsg, sizeof(MSG));
     346        memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG));
     347        memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG));
    336348  }
    337349
     
    460472BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
    461473{
    462 // THDB *thdb = GetTHDBFromThreadId(threadid);
     474// TEB *teb = GetTEBFromThreadId(threadid);
    463475 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    464476
    465 //    if(thdb == NULL) {
     477//    if(teb == NULL) {
    466478//        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
    467479//        return FALSE;
Note: See TracChangeset for help on using the changeset viewer.