Ignore:
Timestamp:
Jan 30, 2004, 11:10:07 PM (22 years ago)
Author:
bird
Message:

#682: Drag & Drop - AttachThreadInput().

File:
1 edited

Legend:

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

    r10288 r10430  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.117 2003-10-22 15:56:38 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.118 2004-01-30 22:10:06 bird Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    6767BOOL setThreadQueueExtraCharMessage(TEB* teb, MSG* pExtraMsg)
    6868{
     69  if (   teb->o.odin.tidAttachedInputThread
     70      && OSLibForwardMessageToAttachedThread(teb, pExtraMsg, NULL))
     71      return TRUE;
     72
    6973  // check if the single slot is occupied already
    7074  if (teb->o.odin.fTranslated == TRUE) {
     
    165169  BOOL             fIsFrame = FALSE;
    166170  int i;
     171
     172    /*
     173     * Forwarded input (AttachThreadInput()).
     174     */
     175    if (    os2Msg->hwnd == NULLHANDLE
     176        &&  os2Msg->msg == WIN32APP_FORWARDEDPOSTMSG
     177        &&  os2Msg->mp2 == (MPARAM)WIN32APP_FORWARDEDPOSTMSG_MAGIC
     178        &&  os2Msg->mp1 != NULL)
     179    {
     180        *winMsg = *(MSG*)os2Msg->mp1;
     181        if (fMsgRemoved)
     182            _sfree(os2Msg->mp1);
     183        dprintf(("OS2ToWinMsgTranslate: Received forwarded messaged %x\n", os2Msg->msg));
     184        return TRUE;
     185    }
    167186
    168187    memset(winMsg, 0, sizeof(MSG));
     
    12031222//******************************************************************************
    12041223
     1224/**
     1225 * Checks if the message is one that should be forwarded.
     1226 *
     1227 * @returns True if the message should be forwarded.
     1228 * @returns False if the message doesn't fall in to that group.
     1229 * @param   pMsg    Message to examin.
     1230 */
     1231BOOL OSLibForwardableMessage(const MSG *pMsg)
     1232{
     1233    return (    (pMsg->message >= WINWM_KEYFIRST   && pMsg->message <= WINWM_KEYLAST)
     1234            ||  (pMsg->message >= WINWM_MOUSEFIRST && pMsg->message <= WINWM_MOUSELAST) );
     1235}
     1236
     1237/**
     1238 * Forwards this message to the attached thread if it's in the group of messages
     1239 * which is supposed to be forwarded.
     1240 *
     1241 * @returns True if forwarded.
     1242 * @returns False if not forwarded.
     1243 * @param   pTeb    Pointer to the TEB of the current thread.
     1244 * @param   pMsg    Message to forward.
     1245 * @author  knut st. osmundsen <bird-srcspam@anduin.net>
     1246 */
     1247BOOL OSLibForwardMessageToAttachedThread(void *pvTeb, MSG *pMsg, void *hmm)
     1248{
     1249    TEB *pTeb = (TEB *)pvTeb;
     1250    dprintf(("OSLibForwardMessageToAttachedThread: %p %p (msg=%x)\n", pvTeb, pMsg, pMsg->message));
     1251    if (!OSLibForwardableMessage(pMsg))
     1252        return FALSE;
     1253
     1254    /*
     1255     * Find the actual receiver thread.
     1256     */
     1257    int c = 100;
     1258    TEB *pTebTo = pTeb;
     1259    do
     1260    {
     1261        pTebTo = GetTEBFromThreadId(pTebTo->o.odin.tidAttachedInputThread);
     1262    } while (c-- > 0 && !pTebTo && pTebTo->o.odin.tidAttachedInputThread);
     1263    if (!c || !pTebTo)
     1264    {
     1265        if (c)  dprintf(("OSLibForwardMessageToAttachedThread: The receiver thread is dead or non existing.\n"));
     1266        else    dprintf(("OSLibForwardMessageToAttachedThread: threads are attached in looooop.\n"));
     1267        return FALSE; /* hmm.... */
     1268    }
     1269    dprintf(("OSLibForwardMessageToAttachedThread: Forwarding message %#x to %#x\n",
     1270             pMsg->message, pTeb->o.odin.tidAttachedInputThread));
     1271
     1272    /*
     1273     * Pack down the message into shared memory.
     1274     */
     1275    MSG *pMsgCopy = (MSG *)_smalloc(sizeof(MSG));
     1276    if (!pMsgCopy)
     1277        return FALSE;
     1278    *pMsgCopy = *pMsg;
     1279
     1280    /*
     1281     * Figure out how we should send the message.
     1282     */
     1283    if (WinInSendMsg(pTebTo->o.odin.hab))
     1284    {
     1285#if 0
     1286        /*
     1287         * Hmm what do we do here....
     1288         */
     1289        MRESULT rc = WinSendQueueMsg(pTebTo->o.odin.hmq, /*special! */, pMsgCopy, /*magic*/ );
     1290        /* if (hmmSendMsgResult)
     1291            *hmmSendMsgResult = (???)rc; */
     1292#else
     1293        dprintf(("OSLibForwardMessage: ERROR! %x in sendmsg!!!\n", pMsg->message));
     1294        DebugInt3();
     1295
     1296        _sfree(pMsgCopy);
     1297        return FALSE;
     1298#endif
     1299    }
     1300    else
     1301    {
     1302        if (!WinPostQueueMsg(pTebTo->o.odin.hmq, WIN32APP_FORWARDEDPOSTMSG, pMsgCopy, (MPARAM)WIN32APP_FORWARDEDPOSTMSG_MAGIC))
     1303        {
     1304            dprintf(("OSLibForwardMessage: Failed to post queue message to hmq=%#x\n", pTebTo->o.odin.hmq));
     1305            _sfree(pMsgCopy);
     1306        }
     1307    }
     1308
     1309    return TRUE;
     1310}
Note: See TracChangeset for help on using the changeset viewer.