Changeset 2312


Ignore:
Timestamp:
Jan 3, 2000, 10:37:17 PM (25 years ago)
Author:
sandervl
Message:

PostThreadMessage bugfix

Location:
trunk/src/user32
Files:
5 edited

Legend:

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

    r2290 r2312  
    1 /* $Id: oslibmsg.cpp,v 1.6 2000-01-01 14:57:18 cbratschi Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.7 2000-01-03 21:37:17 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    178178            thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
    179179            memcpy(&thdb->msg, msg, sizeof(MSG));
    180         }
    181         return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
     180            return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
     181        }
     182        //SvL: TODO; What to do if messages posted by PostThreadMessage are
     183        //     dispatched? Wine doesn't appear to do this.
     184        //     If we call WinDispatchMsg, every window created by the thread
     185        //     receives this message. Does this also happen in NT?
     186        return 0;
    182187  }
    183188  else {//is this allowed?
     
    193198 BOOL rc, eaten;
    194199 THDB *thdb;
     200 QMSG  os2msg;
    195201
    196202  thdb = GetThreadTHDB();
     
    223229        }
    224230        while(rc == FALSE);
     231
     232        return rc;
    225233  }
    226234  else
     
    228236    do {
    229237        eaten = FALSE;
    230         rc = WinGetMsg(thdb->hab, MsgThreadPtr, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
    231         if (MsgThreadPtr->msg == WM_TIMER)
    232             eaten = TIMER_HandleTimer (MsgThreadPtr);
     238        rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
     239        if (os2msg.msg == WM_TIMER)
     240            eaten = TIMER_HandleTimer(&os2msg);
    233241    } while (eaten);
    234242  }
    235   OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode, MSG_REMOVE);
     243  if(rc) {
     244        OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
     245        memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
     246  }
    236247  return rc;
    237248}
     
    393404}
    394405//******************************************************************************
     406BOOL    _System _O32_PostThreadMessage( DWORD, UINT, WPARAM, LPARAM );
     407
     408inline BOOL O32_PostThreadMessage(DWORD a, UINT b, WPARAM c, LPARAM d)
     409{
     410 BOOL yyrc;
     411 USHORT sel = RestoreOS2FS();
     412
     413    yyrc = _O32_PostThreadMessage(a, b, c, d);
     414    SetFS(sel);
     415
     416    return yyrc;
     417}
    395418//******************************************************************************
    396419BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
    397420{
    398  THDB *thdb = GetTHDBFromThreadId(threadid);
     421// THDB *thdb = GetTHDBFromThreadId(threadid);
    399422 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    400423
    401     if(thdb == NULL) {
    402         dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
    403         return FALSE;
    404     }
     424//    if(thdb == NULL) {
     425//        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
     426//        return FALSE;
     427//    }
    405428    dprintf(("PostThreadMessageA %x %x %x %x", threadid, msg, wParam, lParam));
    406429    packet->Msg = msg;
    407430    packet->wParam = wParam;
    408431    packet->lParam = lParam;
    409     return WinPostQueueMsg(thdb->hmq, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
    410 }
    411 //******************************************************************************
    412 //******************************************************************************
    413 
     432    return _O32_PostThreadMessage(threadid, WIN32APP_POSTMSG-OPEN32_MSGDIFF, ((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (LPARAM)packet);
     433}
     434//******************************************************************************
     435//******************************************************************************
     436
  • TabularUnified trunk/src/user32/new/win32wbase.h

    r2294 r2312  
    1 /* $Id: win32wbase.h,v 1.15 2000-01-02 20:20:03 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.16 2000-01-03 21:37:17 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    3939} CUSTOMWNDDATA;
    4040
    41 #define WIN32APP_USERMSGBASE      0x1000
    42 #define WIN32APP_POSTMSG          0x1000
     41//PostThreadMessage is done through Open32; which means the message id will be translated
     42//(0xc00 added)
     43#define OPEN32_MSGDIFF            0xC00
     44#define WIN32APP_POSTMSG          (0x1000+OPEN32_MSGDIFF)
     45
    4346#define WIN32MSG_MAGICA           0x12345678
    4447#define WIN32MSG_MAGICW           0x12345679
  • TabularUnified trunk/src/user32/oslibmsg.cpp

    r2257 r2312  
    1 /* $Id: oslibmsg.cpp,v 1.19 1999-12-29 22:54:00 cbratschi Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.20 2000-01-03 21:37:16 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    178178            thdb->msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg
    179179            memcpy(&thdb->msg, msg, sizeof(MSG));
    180         }
    181         return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
     180            return (LONG)WinDispatchMsg(thdb->hab, &os2msg);
     181        }
     182        //SvL: TODO; What to do if messages posted by PostThreadMessage are
     183        //     dispatched? Wine doesn't appear to do this.
     184        //     If we call WinDispatchMsg, every window created by the thread
     185        //     receives this message. Does this also happen in NT?
     186        return 0;
    182187  }
    183188  else {//is this allowed?
     
    193198 BOOL rc, eaten;
    194199 THDB *thdb;
     200 QMSG  os2msg;
    195201
    196202  thdb = GetThreadTHDB();
     
    223229        }
    224230        while(rc == FALSE);
     231
     232        return rc;
    225233  }
    226234  else
     
    228236    do {
    229237        eaten = FALSE;
    230         rc = WinGetMsg(thdb->hab, MsgThreadPtr, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
    231         if (MsgThreadPtr->msg == WM_TIMER)
    232             eaten = TIMER_HandleTimer (MsgThreadPtr);
     238        rc = WinGetMsg(thdb->hab, &os2msg, TranslateWinMsg(uMsgFilterMin, TRUE), TranslateWinMsg(uMsgFilterMax, FALSE), 0);
     239        if (os2msg.msg == WM_TIMER)
     240            eaten = TIMER_HandleTimer(&os2msg);
    233241    } while (eaten);
    234242  }
    235   OS2ToWinMsgTranslate((PVOID)thdb, MsgThreadPtr, pMsg, isUnicode, MSG_REMOVE);
     243  if(rc) {
     244        OS2ToWinMsgTranslate((PVOID)thdb, &os2msg, pMsg, isUnicode, MSG_REMOVE);
     245        memcpy(MsgThreadPtr, &os2msg, sizeof(QMSG));
     246  }
    236247  return rc;
    237248}
     
    393404}
    394405//******************************************************************************
     406BOOL    _System _O32_PostThreadMessage( DWORD, UINT, WPARAM, LPARAM );
     407
     408inline BOOL O32_PostThreadMessage(DWORD a, UINT b, WPARAM c, LPARAM d)
     409{
     410 BOOL yyrc;
     411 USHORT sel = RestoreOS2FS();
     412
     413    yyrc = _O32_PostThreadMessage(a, b, c, d);
     414    SetFS(sel);
     415
     416    return yyrc;
     417}
    395418//******************************************************************************
    396419BOOL OSLibPostThreadMessage(ULONG threadid, UINT msg, WPARAM wParam, LPARAM lParam, BOOL fUnicode)
    397420{
    398  THDB *thdb = GetTHDBFromThreadId(threadid);
     421// THDB *thdb = GetTHDBFromThreadId(threadid);
    399422 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET));
    400423
    401     if(thdb == NULL) {
    402         dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
    403         return FALSE;
    404     }
     424//    if(thdb == NULL) {
     425//        dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid));
     426//        return FALSE;
     427//    }
    405428    dprintf(("PostThreadMessageA %x %x %x %x", threadid, msg, wParam, lParam));
    406429    packet->Msg = msg;
    407430    packet->wParam = wParam;
    408431    packet->lParam = lParam;
    409     return WinPostQueueMsg(thdb->hmq, WIN32APP_POSTMSG, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);
    410 }
    411 //******************************************************************************
    412 //******************************************************************************
    413 
     432    return _O32_PostThreadMessage(threadid, WIN32APP_POSTMSG-OPEN32_MSGDIFF, ((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (LPARAM)packet);
     433}
     434//******************************************************************************
     435//******************************************************************************
     436
  • TabularUnified trunk/src/user32/oslibmsgtranslate.cpp

    r2257 r2312  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.6 1999-12-29 22:54:01 cbratschi Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.7 2000-01-03 21:37:16 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    132132            winMsg->wParam  = packet->wParam;
    133133            winMsg->lParam  = packet->lParam;
    134             if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
     134            if(fMsgRemoved == MSG_REMOVE)
     135                free(packet); //free the shared memory here
    135136            break;
    136137        }
  • TabularUnified trunk/src/user32/win32wbase.h

    r2295 r2312  
    1 /* $Id: win32wbase.h,v 1.65 2000-01-02 20:30:22 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.66 2000-01-03 21:37:17 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    3939} CUSTOMWNDDATA;
    4040
    41 #define WIN32APP_USERMSGBASE      0x1000
    42 #define WIN32APP_POSTMSG          0x1000
     41//PostThreadMessage is done through Open32; which means the message id will be translated
     42//(0xc00 added)
     43#define OPEN32_MSGDIFF            0xC00
     44#define WIN32APP_POSTMSG          (0x1000+OPEN32_MSGDIFF)
     45
    4346#define WIN32MSG_MAGICA           0x12345678
    4447#define WIN32MSG_MAGICW           0x12345679
Note: See TracChangeset for help on using the changeset viewer.