- Timestamp:
- Jan 30, 2004, 11:10:07 PM (22 years ago)
- Location:
- trunk/src/user32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/oslibmsg.h
r10240 r10430 1 /* $Id: oslibmsg.h,v 1.2 3 2003-08-22 13:16:45 sandervlExp $ */1 /* $Id: oslibmsg.h,v 1.24 2004-01-30 22:10:06 bird Exp $ */ 2 2 /* 3 3 * Window message translation functions for OS/2 … … 59 59 //Direct posting of messages that must remain invisible to the win32 app 60 60 BOOL OSLibPostMessageDirect(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam); 61 BOOL OSLibForwardMessageToAttachedThread(/*TEB*/ void *pvTeb, MSG *pMsg, void *hmm); 61 62 62 63 #define WINWM_NULL 0x0000 -
trunk/src/user32/oslibmsgtranslate.cpp
r10288 r10430 1 /* $Id: oslibmsgtranslate.cpp,v 1.11 7 2003-10-22 15:56:38 sandervlExp $ */1 /* $Id: oslibmsgtranslate.cpp,v 1.118 2004-01-30 22:10:06 bird Exp $ */ 2 2 /* 3 3 * Window message translation functions for OS/2 … … 67 67 BOOL setThreadQueueExtraCharMessage(TEB* teb, MSG* pExtraMsg) 68 68 { 69 if ( teb->o.odin.tidAttachedInputThread 70 && OSLibForwardMessageToAttachedThread(teb, pExtraMsg, NULL)) 71 return TRUE; 72 69 73 // check if the single slot is occupied already 70 74 if (teb->o.odin.fTranslated == TRUE) { … … 165 169 BOOL fIsFrame = FALSE; 166 170 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 } 167 186 168 187 memset(winMsg, 0, sizeof(MSG)); … … 1203 1222 //****************************************************************************** 1204 1223 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 */ 1231 BOOL 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 */ 1247 BOOL 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 } -
trunk/src/user32/windowmsg.cpp
r10216 r10430 1 /* $Id: windowmsg.cpp,v 1.4 7 2003-08-08 13:30:22 sandervlExp $ */1 /* $Id: windowmsg.cpp,v 1.48 2004-01-30 22:10:07 bird Exp $ */ 2 2 /* 3 3 * Win32 window message APIs for OS/2 … … 40 40 ODINDEBUGCHANNEL(USER32-WINDOWMSG) 41 41 42 43 42 //****************************************************************************** 44 43 //****************************************************************************** … … 121 120 { 122 121 BOOL ret; 122 TEB *pTeb = GetThreadTEB(); 123 123 124 124 dprintf2(("GetMessageA %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax)); 125 ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax); 126 if(ret) dprintf2(("GetMessageA %x %x %x %x", hwnd, pMsg->message, pMsg->wParam, pMsg->lParam)); 125 do 126 { 127 ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax); 128 if(ret) dprintf2(("GetMessageA %x %x %x %x", hwnd, pMsg->message, pMsg->wParam, pMsg->lParam)); 129 } while ( pTeb->o.odin.tidAttachedInputThread 130 && OSLibForwardMessageToAttachedThread(pTeb, pMsg, NULL)); 127 131 HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg); 128 132 return ret; … … 133 137 { 134 138 BOOL ret; 139 TEB *pTeb = GetThreadTEB(); 135 140 136 141 dprintf2(("GetMessageW %x %x-%x", hwnd, uMsgFilterMin, uMsgFilterMax)); 137 ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, TRUE); 142 do 143 { 144 ret = OSLibWinGetMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, TRUE); 145 } while ( pTeb->o.odin.tidAttachedInputThread 146 && OSLibForwardMessageToAttachedThread(pTeb, pMsg, NULL)); 138 147 HOOK_CallHooksW(WH_GETMESSAGE, HC_ACTION, PM_REMOVE, (LPARAM)pMsg); 139 148 return ret; … … 145 154 { 146 155 BOOL fFoundMsg; 156 TEB *pTeb = GetThreadTEB(); 147 157 148 158 dprintf2(("PeekMessageA %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg)); 149 fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, 150 fuRemoveMsg, FALSE); 151 if(fFoundMsg) { 159 do 160 { 161 fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, FALSE); 162 if ( fFoundMsg 163 && pTeb->o.odin.tidAttachedInputThread 164 && OSLibForwardMessageToAttachedThread(pTeb, msg, NULL)); 165 { 166 if (!fuRemoveMsg) 167 OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, TRUE, FALSE); 168 continue; 169 } 170 } while (0); 171 172 if (fFoundMsg) { 152 173 dprintf2(("PeekMessageA %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam)); 153 174 HOOK_CallHooksA(WH_GETMESSAGE, HC_ACTION, fuRemoveMsg & PM_REMOVE, (LPARAM)msg ); … … 164 185 { 165 186 BOOL fFoundMsg; 187 TEB *pTeb = GetThreadTEB(); 166 188 167 189 dprintf2(("PeekMessageW %x %d-%d %d", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg)); 168 fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, 169 fuRemoveMsg, TRUE); 190 do 191 { 192 fFoundMsg = OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, TRUE); 193 if ( fFoundMsg 194 && pTeb->o.odin.tidAttachedInputThread 195 && OSLibForwardMessageToAttachedThread(pTeb, msg, NULL)); 196 { 197 if (!fuRemoveMsg) 198 OSLibWinPeekMsg(msg, hwndOwner, uMsgFilterMin, uMsgFilterMax, TRUE, TRUE); 199 continue; 200 } 201 } while (0); 202 170 203 if(fFoundMsg) { 171 204 dprintf2(("PeekMessageW %x %d-%d %d found message %x %d %x %x", hwndOwner, uMsgFilterMin, uMsgFilterMax, fuRemoveMsg, msg->hwnd, msg->message, msg->wParam, msg->lParam)); … … 277 310 } 278 311 //****************************************************************************** 312 313 /** 314 * Attach one threads input queue to another thread. 315 * 316 * @returns Success indicator. 317 * @param idAttach Thread ID of the thread to attach/detach the input 318 * of idAttachTo to. 319 * @param idAttachTo The Thread ID of the thread which input is to be taken 320 * over or reattached. 321 * @param fAttach If set attach the input queue of thread idAttachTo 322 * to idAttach. 323 * If clear detach the input queue of thread idAttach 324 * reattaching it to idAttachTo. 325 * @status partially implemented. 326 * @author knut st. osmundsen <bird-srcspam@anduin.net> 327 * @remark One cannot attach a threads input queue to it self. 328 * @todo Not sure if all this is 100% ok according to the windows reality. 329 * I'm sure some error cases aren't caught. 330 */ 331 BOOL WIN32API AttachThreadInput(DWORD idAttach, DWORD idAttachTo, BOOL fAttach) 332 { 333 dprintf(("USER32: AttachThreadInput\n")); 334 if (idAttach != idAttachTo) 335 { 336 /* pray noone frees the TEB while we're working on it... */ 337 TEB *pTeb = GetTEBFromThreadId(idAttach); 338 if (pTeb) 339 { 340 TEB *pTebTo = GetTEBFromThreadId(idAttachTo); 341 if (pTebTo) 342 { 343 if (fAttach) 344 { /* attach. */ 345 if (pTebTo->o.odin.tidAttachedInputThread) 346 { 347 dprintf(("USER32: AttachThreadInput: WARNING! %#x is already attached to %#x\n", idAttachTo, pTebTo->o.odin.tidAttachedInputThread)); 348 DebugInt3(); 349 } 350 pTebTo->o.odin.tidAttachedInputThread = idAttach; 351 dprintf(("USER32: AttachThreadInput: Attached input from %#x to %#x\n", idAttachTo, idAttach)); 352 } 353 else 354 { /* deattach - i.e. undo previous AttachThreadInput(,,TRUE). */ 355 if (pTebTo->o.odin.tidAttachedInputThread != idAttach) 356 { 357 dprintf(("USER32: AttachThreadInput: WARNING! %#x is not attached to %#x\n", idAttachTo, pTebTo->o.odin.tidAttachedInputThread)); 358 DebugInt3(); 359 } 360 pTebTo->o.odin.tidAttachedInputThread = 0; 361 dprintf(("USER32: AttachThreadInput: Detached input from %#x to %#x\n", idAttach, idAttachTo)); 362 } 363 return TRUE; 364 } 365 else 366 { 367 dprintf(("USER32: AttachThreadInput: Invalid tid=%#x\n", idAttachTo)); 368 SetLastError(ERROR_INVALID_PARAMETER); 369 } 370 } 371 else 372 { 373 dprintf(("USER32: AttachThreadInput: Invalid tid=%#x\n", idAttach)); 374 SetLastError(ERROR_INVALID_PARAMETER); 375 } 376 } 377 else 378 { 379 dprintf(("USER32: AttachThreadInput idAttach == idAttachTo (== %#x)\n", idAttach)); 380 SetLastError(ERROR_ACCESS_DENIED); 381 } 382 return FALSE; 383 } 384 279 385 //****************************************************************************** 280 386 /**********************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.