- Timestamp:
- Apr 11, 2003, 4:22:06 PM (22 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/wprocess.cpp
r9971 r10012 1 /* $Id: wprocess.cpp,v 1.18 6 2003-04-02 11:03:33 sandervl Exp $ */1 /* $Id: wprocess.cpp,v 1.187 2003-04-11 14:21:53 sandervl Exp $ */ 2 2 3 3 /* … … 373 373 if(winteb->o.odin.hPostMsgEvent) { 374 374 CloseHandle(winteb->o.odin.hPostMsgEvent); 375 } 376 377 // free shared memory for WM_COPYDATA 378 if (winteb->o.odin.pWM_COPYDATA) 379 { 380 dprintf(("DestroyTEB: freeing WM_COPYDATA: %#p", winteb->o.odin.pWM_COPYDATA)); 381 _sfree(winteb->o.odin.pWM_COPYDATA); 375 382 } 376 383 … … 2005 2012 2006 2013 //Only use WGSS to launch the app if it's not PE or PE & win32k loaded 2007 if(!fPEExe || (fPEExe && fWin32k)) 2014 if(!fPEExe || (fPEExe && fWin32k)) 2008 2015 { 2009 2016 if(O32_CreateProcess(szAppName, lpCommandLine, lpProcessAttributes, … … 2031 2038 lpProcessInfo->dwThreadId = MAKE_THREADID(lpProcessInfo->dwProcessId, lpProcessInfo->dwThreadId); 2032 2039 } 2033 2040 2034 2041 if(cmdline) 2035 2042 free(cmdline); 2036 2043 return(TRUE); 2037 2044 } 2038 2045 2039 2046 // verify why O32_CreateProcess actually failed. 2040 2047 // If GetLastError() == 191 (ERROR_INVALID_EXE_SIGNATURE) -
trunk/src/user32/oslibmsg.cpp
r9950 r10012 1 /* $Id: oslibmsg.cpp,v 1.6 7 2003-03-28 11:49:01sandervl Exp $ */1 /* $Id: oslibmsg.cpp,v 1.68 2003-04-11 14:22:05 sandervl Exp $ */ 2 2 /* 3 3 * Window message translation functions for OS/2 … … 53 53 #include "user32api.h" 54 54 55 #define DBG_LOCALLOG 55 #define DBG_LOCALLOG DBG_oslibmsg 56 56 #include "dbglocal.h" 57 57 … … 210 210 teb->o.odin.winmsg.time = -1; 211 211 if(msg->hwnd) { 212 213 214 212 teb->o.odin.nrOfMsgs = 1; 213 teb->o.odin.msgstate++; //odd -> next call to our PM window handler should dispatch the translated msg 214 memcpy(&teb->o.odin.msg, msg, sizeof(MSG)); 215 215 } 216 216 if(os2msg.hwnd || os2msg.msg == WM_QUIT) { 217 218 219 217 memset(&teb->o.odin.os2msg, 0, sizeof(teb->o.odin.os2msg)); 218 memset(&teb->o.odin.winmsg, 0, sizeof(teb->o.odin.winmsg)); 219 return (LONG)WinDispatchMsg(teb->o.odin.hab, &os2msg); 220 220 } 221 221 //SvL: Don't dispatch messages sent by PostThreadMessage (correct??) … … 241 241 242 242 if(hwnd) { 243 244 245 246 247 248 249 243 hwndOS2 = Win32ToOS2Handle(hwnd); 244 if(hwndOS2 == NULL) { 245 memset(pMsg, 0, sizeof(MSG)); 246 dprintf(("GetMsg: window %x NOT FOUND!", hwnd)); 247 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 248 return TRUE; 249 } 250 250 } 251 251 … … 253 253 if(teb == NULL) { 254 254 DebugInt3(); 255 256 } 257 258 if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) 255 return TRUE; 256 } 257 258 if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) 259 259 { 260 260 dprintf(("Return queued WM_CHAR message hwnd=%x msg=%d wParam=%x lParam=%x", teb->o.odin.msgWCHAR.hwnd, teb->o.odin.msgWCHAR.message, teb->o.odin.msgWCHAR.wParam, teb->o.odin.msgWCHAR.lParam)); … … 277 277 teb->o.odin.os2msg.msg = 0; 278 278 teb->o.odin.os2msg.hwnd = 0; 279 279 280 280 if(!IsWindow(pMsg->hwnd)) { 281 281 //could be a queued char message for a window that was just destroyed … … 306 306 continuegetmsg: 307 307 if(hwnd) { 308 309 310 311 312 313 314 308 filtermin = TranslateWinMsg(uMsgFilterMin, TRUE); 309 filtermax = TranslateWinMsg(uMsgFilterMax, FALSE); 310 if(filtermin > filtermax) { 311 ULONG tmp = filtermin; 312 filtermin = filtermax; 313 filtermax = filtermin; 314 } 315 315 do { 316 317 316 WinWaitMsg(teb->o.odin.hab, filtermin, filtermax); 317 rc = OSLibWinPeekMsg(pMsg, hwnd, uMsgFilterMin, uMsgFilterMax, PM_REMOVE_W, isUnicode); 318 318 } 319 319 while(rc == FALSE); … … 323 323 else 324 324 { 325 326 327 328 329 330 331 332 333 334 335 336 325 filtermin = TranslateWinMsg(uMsgFilterMin, TRUE); 326 filtermax = TranslateWinMsg(uMsgFilterMax, FALSE); 327 if(filtermin > filtermax) { 328 ULONG tmp = filtermin; 329 filtermin = filtermax; 330 filtermax = filtermin; 331 } 332 do { 333 eaten = FALSE; 334 rc = WinGetMsg(teb->o.odin.hab, &os2msg, 0, filtermin, filtermax); 335 if (os2msg.msg == WM_TIMER) 336 eaten = TIMER_HandleTimer(&os2msg); 337 337 if (os2msg.msg == WM_QUIT && ((ULONG)os2msg.mp2 != 0) ) { 338 338 // Don't return FALSE when the window list sends us … … 342 342 // in this case. When the app calls PostQuitMessage (mp2 == 0), 343 343 // then we handle it the normal way 344 rc = 1; 344 rc = 1; 345 345 } 346 } 346 } 347 347 while (eaten); 348 348 } … … 356 356 memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG)); 357 357 memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG)); 358 358 359 359 // send keyboard messages to the registered hooks 360 360 switch (pMsg->message) … … 375 375 376 376 //****************************************************************************** 377 //PeekMessage retrieves only messages associated with the window identified by the 378 //hwnd parameter or any of its children as specified by the IsChild function, and within 379 //the range of message values given by the uMsgFilterMin and uMsgFilterMax 380 //parameters. If hwnd is NULL, PeekMessage retrieves messages for any window that 381 //belongs to the current thread making the call. (PeekMessage does not retrieve 382 //messages for windows that belong to other threads.) If hwnd is -1, PeekMessage only 383 //returns messages with a hwnd value of NULL, as posted by the PostAppMessage 384 //function. If uMsgFilterMin and uMsgFilterMax are both zero, PeekMessage returns all 385 //available messages (no range filtering is performed). 377 //PeekMessage retrieves only messages associated with the window identified by the 378 //hwnd parameter or any of its children as specified by the IsChild function, and within 379 //the range of message values given by the uMsgFilterMin and uMsgFilterMax 380 //parameters. If hwnd is NULL, PeekMessage retrieves messages for any window that 381 //belongs to the current thread making the call. (PeekMessage does not retrieve 382 //messages for windows that belong to other threads.) If hwnd is -1, PeekMessage only 383 //returns messages with a hwnd value of NULL, as posted by the PostAppMessage 384 //function. If uMsgFilterMin and uMsgFilterMax are both zero, PeekMessage returns all 385 //available messages (no range filtering is performed). 386 386 //TODO: Not working as specified right now! 387 387 //****************************************************************************** … … 401 401 } 402 402 if(hwnd && hwnd != -1) { 403 404 405 406 407 408 403 hwndOS2 = Win32ToOS2Handle(hwnd); 404 if(hwndOS2 == NULL) { 405 dprintf(("PeekMsg: window %x NOT FOUND!", hwnd)); 406 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); 407 return FALSE; 408 } 409 409 } 410 410 … … 415 415 } 416 416 417 if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) 417 if(teb->o.odin.fTranslated && (!hwnd || hwnd == teb->o.odin.msgWCHAR.hwnd)) 418 418 { 419 419 dprintf(("Return queued WM_CHAR message hwnd=%x msg=%d wParam=%x lParam=%x", teb->o.odin.msgWCHAR.hwnd, teb->o.odin.msgWCHAR.message, teb->o.odin.msgWCHAR.wParam, teb->o.odin.msgWCHAR.lParam)); … … 447 447 goto continuepeekmsg; 448 448 } 449 449 450 450 // @@@PH verify this 451 451 // if this is a keyup or keydown message, we've got to … … 466 466 } 467 467 } 468 468 469 469 return TRUE; 470 470 } 471 471 472 472 continuepeekmsg: 473 if(uMsgFilterMin && uMsgFilterMax) 473 if(uMsgFilterMin && uMsgFilterMax) 474 474 { //we can't use the PM message filter (since the message nrs aren't similar), so we must 475 475 //filter each message seperately … … 485 485 eaten = FALSE; 486 486 487 rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, ulPMFilter, ulPMFilter, 487 rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, ulPMFilter, ulPMFilter, 488 488 (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE); 489 489 //Sadly indeed WinPeekMsg sometimes does not filter well! 490 490 if (rc && (os2msg.msg != ulPMFilter)) {// drop this message 491 491 dprintf(("WARNING: WinPeekMsg returns %x even though we filter for %x", os2msg.msg, ulPMFilter)); 492 rc = 0; 492 rc = 0; 493 493 } 494 494 if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) { … … 518 518 return FALSE; 519 519 } 520 520 521 521 // @@@PH 522 522 // warning - OS2ToWinMsgTranslate might insert additional messages 523 523 // into the queue 524 if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE) == FALSE) 524 if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, (fRemove & PM_REMOVE_W) ? MSG_REMOVE : MSG_NOREMOVE) == FALSE) 525 525 { 526 526 //unused PM message; dispatch immediately and grab next one … … 535 535 //TODO: This is not safe! There's no guarantee this message will be dispatched and it might overwrite a previous message 536 536 if(fRemove & PM_REMOVE_W) { 537 538 537 memcpy(&teb->o.odin.os2msg, &os2msg, sizeof(QMSG)); 538 memcpy(&teb->o.odin.winmsg, pMsg, sizeof(MSG)); 539 539 } 540 540 … … 627 627 return (BOOL)WinReplyMsg( NULLHANDLE, NULLHANDLE, HMQ_CURRENT, (MRESULT)result); 628 628 } 629 //****************************************************************************** 630 //****************************************************************************** 629 630 //****************************************************************************** 631 632 /** 633 * Send and Post message helper for packing down interprocess and interthread messages. 634 * 635 * @returns Pointer to packet on success. (shared memory) 636 * @returns NULL on failure with SendMessage return code suggestion in *pRc if pRc is set. 637 * @param hwndOdin Odin window handle. (NULL allowed) 638 * @param hwndOS2 OS/2 window handle. 639 * @param msg Message id. 640 * @param wParam Message param. 641 * @param lParam Message param. 642 * @param fUnicode Unicode or ansi indicator. 643 * @param pRc Where to store SendMessage return code. Optional. 644 * @author knut st. osmundsen<bird@anduin.net> 645 */ 646 void * OSLibPackMessage(HWND hwndOdin, HWND hwndOS2, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode, PULONG pRc) 647 { 648 POSTMSG_PACKET * pMsgPacket; 649 650 /* 651 * Pack message by id. 652 */ 653 switch (msg) 654 { 655 /* 656 * lParam = PCOPYDATASTRUCT. 657 * Must move this to shared memory together with any 658 * data it's pointing at. 659 * 660 * We put everything into the package that might ease cleanup... 661 * WARNING! Currently there are cleanup hacks which works with acrobat. 662 */ 663 case WINWM_COPYDATA: 664 { 665 PCOPYDATASTRUCT_W pOrg = (PCOPYDATASTRUCT_W)lParam; 666 dprintf(("user32::oslibmsg::OSLibPackMessage - WM_COPYDATA: lParam=%#x dwData=%#x cbData=%d lpData=%#x", 667 pOrg, pOrg ? pOrg->dwData : -1, pOrg ? pOrg->cbData : -1, pOrg ? pOrg->lpData : (LPVOID)-1)); 668 669 /* 670 * Calc packet size. 671 */ 672 unsigned cb = sizeof(POSTMSG_PACKET); 673 if (pOrg) 674 { 675 cb += sizeof(COPYDATASTRUCT_W); 676 if (pOrg->lpData && pOrg->cbData) 677 cb += 16 + pOrg->cbData; //add 16 Bytes for safty and alignment. 678 } 679 680 /* 681 * Allocate packet. 682 */ 683 pMsgPacket = (POSTMSG_PACKET *)_smalloc(cb); 684 if (!pMsgPacket) 685 { 686 dprintf(("user32::oslibmsg::OSLibPackMessage - WM_COPYDATA: failed to allocate %d shared bytes for packing", cb)); 687 DebugInt3(); 688 if (pRc) 689 *pRc = FALSE; 690 //@todo figure out which error to set. This is plain guesswork! 691 SetLastError(ERROR_NOT_ENOUGH_MEMORY_W); 692 break; 693 } 694 695 /* 696 * Initialize packet. 697 */ 698 PCOPYDATASTRUCT_W pNew = (PCOPYDATASTRUCT_W)(pMsgPacket + 1); 699 pMsgPacket->wParam = wParam; 700 pMsgPacket->lParam = (LPARAM)pNew; 701 *pNew = *pOrg; 702 if (pNew->cbData && pNew->lpData) 703 { 704 pNew->lpData = (LPVOID)(((unsigned)(pNew + 1) + 15) & ~15); //16byte align for safty. 705 //@todo what about a safe_memcpy? 706 memcpy(pNew->lpData, pOrg->lpData, pNew->cbData); 707 } 708 709 /* done! */ 710 dprintf(("user32::oslibmsg::OSLibPackMessage - WM_COPYDATA: Packed down %d bytes at %#x (pMsgPacket)", 711 cb, pMsgPacket)); 712 break; 713 } 714 715 716 /* 717 * Default packing 718 */ 719 default: 720 { 721 pMsgPacket = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 722 if (!pMsgPacket) 723 { 724 dprintf(("user32::oslibmsg::OSLibPackMessage - allocated packet structure is NULL")); 725 if (pRc) 726 { // Can't find any better return code than 0 :/ 727 *pRc = 0; 728 } 729 DebugInt3(); 730 break; 731 } 732 pMsgPacket->wParam = wParam; 733 pMsgPacket->lParam = lParam; 734 } 735 736 } 737 738 return pMsgPacket; 739 } 740 741 742 /** 743 * Send an inter thread/proces message. 744 * 745 * @returns 746 * @param hwnd OS/2 hwnd. 747 * @param msg Odin message id. 748 * @param wParam Message param. 749 * @param lParam Message param. 750 * @param fUnicode Unicode indicator. 751 */ 631 752 ULONG OSLibSendMessage(HWND hwnd, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode) 632 753 { 633 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 634 635 if(NULL == packet) 636 { 637 dprintf(("user32::oslibmsg::OSLibSendMessage - allocated packet structure is NULL")); 638 639 // PH: we cannot provide a correct returncode :( 640 DebugInt3(); 641 return 0; 642 } 643 644 packet->wParam = wParam; 645 packet->lParam = lParam; 646 647 return (ULONG)WinSendMsg(hwnd, WIN32APP_POSTMSG+msg, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet); 648 } 754 ULONG rc; /* return code on packing failure */ 755 void * pvMsgPacket; /* packed message (shared memory) */ 756 757 /* 758 * Call message packer. 759 */ 760 pvMsgPacket = OSLibPackMessage(NULLHANDLE, hwnd, msg, wParam, lParam, fUnicode, &rc); 761 if (!pvMsgPacket) 762 { 763 dprintf(("user32::oslibmsg::OSLibSendMessage - Failed to pack message !!")); 764 DebugInt3(); 765 return rc; 766 } 767 768 return (ULONG)WinSendMsg(hwnd, WIN32APP_POSTMSG+msg, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), pvMsgPacket); 769 } 770 649 771 //****************************************************************************** 650 772 //****************************************************************************** 651 773 ULONG OSLibWinBroadcastMsg(ULONG msg, ULONG wParam, ULONG lParam, BOOL fSend) 652 774 { 775 #ifdef DEBUG 776 if (msg == WINWM_COPYDATA) 777 { 778 dprintf(("user32::oslibmsg::OSLibWinBroadcastMsg - WM_COPYDATA will not work outside this process !!!")); 779 DebugInt3(); 780 } 781 #endif 653 782 return WinBroadcastMsg(HWND_DESKTOP, WIN32APP_POSTMSG+msg, (MPARAM)wParam, (MPARAM)lParam, 654 783 (fSend) ? BMSG_SEND : BMSG_POST); 655 784 } 656 //****************************************************************************** 657 //****************************************************************************** 785 786 787 /** 788 * Post a message. 789 * 790 * @returns Success indicator. 791 * 792 * @param hwndWin32 Odin window handle. 793 * @param hwndOS2 OS/2 window handle 794 * @param msg Odin message id. 795 * @param wParam Message param. 796 * @param lParam Message param. 797 * @param fUnicode Unicode indicator. 798 */ 658 799 BOOL OSLibPostMessage(HWND hwndWin32, HWND hwndOS2, ULONG msg, ULONG wParam, ULONG lParam, BOOL fUnicode) 659 800 { 660 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 661 BOOL ret; 662 663 if (NULL == packet) 664 { 665 dprintf(("user32::oslibmsg::OSLibPostMessage - allocated packet structure is NULL")); 666 667 // PH: we can provide a correct returncode 668 DebugInt3(); 801 void * pvMsgPacket; /* packed message (shared memory) */ 802 803 /* 804 * Call message packer. 805 */ 806 pvMsgPacket = OSLibPackMessage(hwndWin32, hwndOS2, msg, wParam, lParam, fUnicode, NULL); 807 if (!pvMsgPacket) 808 { 809 dprintf(("user32::oslibmsg::OSLibPostMessage - Failed to pack message !!")); 810 DebugInt3(); 669 811 return FALSE; 670 812 } 813 814 /* 815 * Post the message. 816 * Signal the receiver for if it's doing MsgWaitForMultipleObjects() at the time. 817 */ 671 818 TEB *teb = GetTEBFromThreadId(GetWindowThreadProcessId(hwndWin32, NULL)); 672 673 packet->wParam = wParam;674 packet->lParam = lParam;675 ret = WinPostMsg(hwndOS2, WIN32APP_POSTMSG+msg, (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), (MPARAM)packet);676 677 if(teb && (teb->o.odin.dwWakeMask & QS_POSTMESSAGE_W)){819 BOOL ret = WinPostMsg(hwndOS2, 820 WIN32APP_POSTMSG+msg, 821 (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), 822 pvMsgPacket); 823 if (teb && (teb->o.odin.dwWakeMask & QS_POSTMESSAGE_W)) 824 { 678 825 //thread is blocked in MsgWaitForMultipleObjects waiting for 679 826 //posted messages … … 697 844 POSTMSG_PACKET *packet = (POSTMSG_PACKET *)_smalloc(sizeof(POSTMSG_PACKET)); 698 845 BOOL ret; 699 700 if (NULL == packet)846 847 if (NULL == packet) 701 848 { 702 849 dprintf(("user32::oslibmsg::OSLibPostMessage - allocated packet structure is NULL")); 703 850 704 DebugInt3(); 851 DebugInt3(); 705 852 // PH: we can provide a correct returncode 706 853 return FALSE; 707 854 } 708 855 709 856 if(teb == NULL) { 710 857 dprintf(("OSLibPostThreadMessage: thread %x not found!", threadid)); … … 715 862 packet->lParam = lParam; 716 863 717 ret = WinPostQueueMsg((HMQ)teb->o.odin.hmq, WIN32APP_POSTMSG+msg, 718 (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), 864 ret = WinPostQueueMsg((HMQ)teb->o.odin.hmq, WIN32APP_POSTMSG+msg, 865 (MPARAM)((fUnicode) ? WIN32MSG_MAGICW : WIN32MSG_MAGICA), 719 866 (MPARAM)packet); 720 867 -
trunk/src/user32/oslibmsg.h
r9598 r10012 1 /* $Id: oslibmsg.h,v 1. 19 2003-01-03 16:35:54sandervl Exp $ */1 /* $Id: oslibmsg.h,v 1.20 2003-04-11 14:22:05 sandervl Exp $ */ 2 2 /* 3 3 * Window message translation functions for OS/2 … … 14 14 15 15 16 typedef struct tagCOPYDATASTRUCT_W 17 { 18 DWORD dwData; 19 DWORD cbData; 20 LPVOID lpData; 21 } COPYDATASTRUCT_W, *PCOPYDATASTRUCT_W, *LPCOPYDATASTRUCT_W; 22 23 16 24 #ifdef __cplusplus 17 25 18 26 ULONG TranslateWinMsg(ULONG msg); 19 27 20 #define MSG_NOREMOVE 21 #define MSG_REMOVE 28 #define MSG_NOREMOVE 0 29 #define MSG_REMOVE 1 22 30 23 31 #ifdef OS2DEF_INCLUDED … … 27 35 #endif 28 36 29 BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, 37 BOOL OSLibWinGetMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, 30 38 UINT uMsgFilterMax, BOOL isUnicode = FALSE); 31 BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, 39 BOOL OSLibWinPeekMsg(LPMSG pMsg, HWND hwnd, UINT uMsgFilterMin, 32 40 UINT uMsgFilterMax, DWORD fRemove, BOOL isUnicode = FALSE); 33 41 void OSLibWinPostQuitMessage(ULONG nExitCode); -
trunk/src/user32/oslibmsgtranslate.cpp
r9950 r10012 1 /* $Id: oslibmsgtranslate.cpp,v 1.10 7 2003-03-28 11:49:01sandervl Exp $ */1 /* $Id: oslibmsgtranslate.cpp,v 1.108 2003-04-11 14:22:06 sandervl Exp $ */ 2 2 /* 3 3 * Window message translation functions for OS/2 … … 52 52 //PF Correction is different for different mouse drivers. For now no correction 53 53 //is ok because lots of Odin controls rely on minimum delta. However in future 54 //we will possibly detect mouse driver and use correction if speed will be 54 //we will possibly detect mouse driver and use correction if speed will be 55 55 //too high or too low. 56 56 57 57 //****************************************************************************** 58 58 //****************************************************************************** … … 90 90 ret = pmScan; 91 91 } 92 92 93 93 KeyTranslatePMScanToWinVKey(ret, FALSE, (PBYTE)&winKey, NULL, NULL); 94 94 return winKey; … … 127 127 } 128 128 //****************************************************************************** 129 130 131 /** 132 * Inter process/thread packet cleanup. 133 * See OSLibPackMessage() for details on the packing. 134 * 135 * @param pTeb Pointer to the thread environment block for the current thread. 136 * @param pPacket Pointer to the packet in question. 137 * @param pWinMsg Pointer to the window message corresponding to the packet. 138 */ 139 inline void OSLibCleanupPacket(TEB *pTeb, POSTMSG_PACKET *pPacket, MSG *pWinMsg) 140 { 141 switch (pWinMsg->message) 142 { 143 /* 144 * Place this in the TEB freeing any previous WM_COPYDATA packet. 145 * Note! Nested WM_COPYDATA isn't working. 146 */ 147 case WINWM_COPYDATA: 148 { 149 dprintf(("OSLibCleanupPacket: WM_COPYDATA: old %#p new %#p", pTeb->o.odin.pWM_COPYDATA, pPacket)); 150 if (pTeb->o.odin.pWM_COPYDATA) 151 _sfree(pTeb->o.odin.pWM_COPYDATA); 152 pTeb->o.odin.pWM_COPYDATA = pPacket; 153 break; 154 } 155 156 /* 157 * Default packing - free the shared memory here. 158 */ 159 default: 160 _sfree(pPacket); 161 break; 162 } 163 } 164 129 165 //****************************************************************************** 130 166 BOOL OS2ToWinMsgTranslate(void *pTeb, QMSG *os2Msg, MSG *winMsg, BOOL isUnicode, BOOL fMsgRemoved) … … 167 203 winMsg->wParam = packet->wParam; 168 204 winMsg->lParam = packet->lParam; 169 if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here 205 if (fMsgRemoved == MSG_REMOVE) 206 OSLibCleanupPacket(teb, packet, winMsg); 170 207 if(win32wnd) RELEASE_WNDOBJ(win32wnd); 171 208 return TRUE; … … 407 444 (winMsg->message == WINWM_NCMBUTTONDOWN)) 408 445 { 409 if(fGenerateDoubleClick && doubleClickMsg.message == winMsg->message && 446 if(fGenerateDoubleClick && doubleClickMsg.message == winMsg->message && 410 447 winMsg->time - doubleClickMsg.time < GetDoubleClickTime() && 411 448 (abs(winMsg->pt.x - doubleClickMsg.pt.x) < GetSystemMetrics(SM_CXDOUBLECLK_W)/2) && 412 (abs(winMsg->pt.y - doubleClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK_W)/2)) 449 (abs(winMsg->pt.y - doubleClickMsg.pt.y) < GetSystemMetrics(SM_CYDOUBLECLK_W)/2)) 413 450 { 414 451 dprintf(("single -> double click")); … … 440 477 } 441 478 else msg = winMsg->message; 442 479 443 480 if(msg == WINWM_LBUTTONDBLCLK) { 444 481 msg = WINWM_LBUTTONDOWN; … … 589 626 //FALSE -> keyboard operation = user pressed Alt-F4 -> close app 590 627 //TRUE -> user clicked on close button -> close window 591 if(SHORT2FROMMP(os2Msg->mp2) == FALSE) 628 if(SHORT2FROMMP(os2Msg->mp2) == FALSE) 592 629 { 593 630 HWND hwnd = win32wnd->GetTopParent(); … … 655 692 // NO BREAK! FALLTHRU CASE! 656 693 } 657 694 658 695 case WM_CHAR_SPECIAL: 659 696 { … … 665 702 // NO BREAK! FALLTHRU CASE! 666 703 } 667 704 668 705 case WM_CHAR: 669 706 { … … 674 711 ULONG flags = SHORT1FROMMP(os2Msg->mp1); 675 712 BOOL keyWasPressed; 676 BOOL numPressed = (BOOL)(WinGetKeyState(HWND_DESKTOP,VK_NUMLOCK) & 1); 713 BOOL numPressed = (BOOL)(WinGetKeyState(HWND_DESKTOP,VK_NUMLOCK) & 1); 677 714 char c; 678 715 USHORT usPMScanCode = CHAR4FROMMP(os2Msg->mp1); … … 693 730 694 731 KeyTranslatePMScanToWinVKey(usPMScanCode, 695 FALSE, 732 FALSE, 696 733 &bWinVKey, 697 734 &wWinScan, … … 700 737 winMsg->lParam = repeatCount & 0x0FFFF; // bit 0-15, repeatcount 701 738 winMsg->lParam |= (wWinScan & 0x1FF) << 16; // bit 16-23, scancode + bit 15 extended 702 739 703 740 // Set the extended bit when appropriate 704 741 if (fWinExtended) 705 742 winMsg->lParam = winMsg->lParam | WIN_KEY_EXTENDED; 706 743 707 744 //PF When we press shift we enable non-numeric functions of Numpad 708 745 if ((!numPressed || (flags & KC_SHIFT)) && (scanCode >= PMSCAN_PAD7) && (scanCode <= PMSCAN_PADPERIOD)) 709 746 winMsg->wParam = ConvertNumPadKey(scanCode); … … 728 765 winMsg->lParam = 0x01460001; 729 766 } 730 767 731 768 if (!(flags & KC_ALT)) 732 769 { … … 745 782 // held ALT-key when current key is released 746 783 // generates additional flag 0x2000000 747 // Note: PM seems to do this differently, 784 // Note: PM seems to do this differently, 748 785 // KC_ALT is already reset 749 786 } … … 756 793 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP 757 794 } 758 else 795 else 759 796 { // send WM_KEYDOWN message 760 797 winMsg->message = WINWM_KEYDOWN; … … 762 799 if (keyWasPressed) 763 800 winMsg->lParam |= WIN_KEY_PREVSTATE; // bit 30, previous state, 1 means key was pressed 764 801 765 802 //Shift-Enter and possibly others need to have special handling 766 803 if (flags & KC_SHIFT) 767 804 { 768 805 if(fMsgRemoved && !(teb->o.odin.fTranslated)) 769 { 806 { 770 807 dprintf(("PM: KC_SHIFT: %x",winMsg->wParam)); 771 808 if (winMsg->wParam == VK_RETURN_W) … … 773 810 MSG extramsg; 774 811 memcpy(&extramsg, winMsg, sizeof(MSG)); 775 812 776 813 //After SetFocus(0), all keystrokes are converted in WM_SYS* 777 814 extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR; … … 791 828 MSG extramsg; 792 829 memcpy(&extramsg, winMsg, sizeof(MSG)); 793 830 794 831 //After SetFocus(0), all keystrokes are converted in WM_SYS* 795 832 extramsg.message = (fIgnoreKeystrokes) ? WINWM_SYSCHAR : WINWM_CHAR; … … 802 839 // if right alt is down, then we need to set the alt down bit too 803 840 // except for the fake Ctrl WM_CHAR sent for AltGr emulation 804 if (os2Msg->msg != WM_CHAR_SPECIAL_ALTGRCONTROL && 805 (WinGetKeyState(HWND_DESKTOP, VK_ALTGRAF) & 0x8000)) 841 if (os2Msg->msg != WM_CHAR_SPECIAL_ALTGRCONTROL && 842 (WinGetKeyState(HWND_DESKTOP, VK_ALTGRAF) & 0x8000)) 806 843 { 807 winMsg->lParam |= WIN_KEY_ALTHELD; 844 winMsg->lParam |= WIN_KEY_ALTHELD; 808 845 } 809 846 } 810 else 847 else 811 848 { 812 849 // … … 817 854 //@@PF Note that without pmkbdhook there will not be correct message for Alt-Enter 818 855 winMsg->message = WINWM_SYSKEYUP; 819 winMsg->lParam |= WIN_KEY_PREVSTATE; 856 winMsg->lParam |= WIN_KEY_PREVSTATE; 820 857 // No ALTHELD for Alt itself ;) 821 winMsg->lParam |= WIN_KEY_ALTHELD; 822 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP 858 winMsg->lParam |= WIN_KEY_ALTHELD; 859 winMsg->lParam |= 1 << 31; // bit 31, transition state, always 1 for WM_KEYUP 823 860 } 824 else 861 else 825 862 { 826 863 // send WM_SYSKEYDOWN message … … 838 875 // AltGr needs special handling 839 876 // 840 // AltGr -> WM_KEYDOWN (VK_CONTROL), WM_KEYDOWN (VK_MENU) 877 // AltGr -> WM_KEYDOWN (VK_CONTROL), WM_KEYDOWN (VK_MENU) 841 878 // WM_SYSKEYUP (VK_CONTROL) 842 879 // WM_KEYUP (VK_MENU) 843 880 // 844 // Ctrl+AltGr -> WM_KEYDOWN (VK_CONTROL), WM_KEYUP (VK_CONTROL) 845 // WM_KEYDOWN (VK_MENU) 881 // Ctrl+AltGr -> WM_KEYDOWN (VK_CONTROL), WM_KEYUP (VK_CONTROL) 882 // WM_KEYDOWN (VK_MENU) 846 883 // WM_KEYUP (VK_MENU) 847 // WM_KEYUP (VK_CONTROL) 884 // WM_KEYUP (VK_CONTROL) 848 885 // 849 // AltGr+Ctrl -> WM_KEYDOWN (VK_CONTROL), WM_KEYDOWN (VK_MENU) 850 // WM_KEYDOWN (VK_CONTROL) 851 // WM_SYSKEYUP (VK_CONTROL) 852 // WM_SYSKEYUP (VK_CONTROL) 886 // AltGr+Ctrl -> WM_KEYDOWN (VK_CONTROL), WM_KEYDOWN (VK_MENU) 887 // WM_KEYDOWN (VK_CONTROL) 888 // WM_SYSKEYUP (VK_CONTROL) 889 // WM_SYSKEYUP (VK_CONTROL) 853 890 // WM_KEYUP (VK_MENU) 854 891 // … … 861 898 // endif 862 899 // Send WM_KEYDOWN (VK_MENU) 863 // 864 if(winMsg->wParam == VK_MENU_W && (winMsg->lParam & WIN_KEY_EXTENDED)) 900 // 901 if(winMsg->wParam == VK_MENU_W && (winMsg->lParam & WIN_KEY_EXTENDED)) 865 902 {//AltGr 866 if(GetKeyState(VK_CONTROL_W) & 0x8000) 903 if(GetKeyState(VK_CONTROL_W) & 0x8000) 867 904 {//Ctrl key pressed, send WM_KEYUP 868 905 869 906 } 870 907 } … … 876 913 winMsg->message = WINWM_SYSKEYDOWN; 877 914 } 878 else 915 else 879 916 if(winMsg->message == WINWM_KEYUP) { 880 917 winMsg->message = WINWM_SYSKEYUP; … … 971 1008 if (os2Msg->msg == WM_VSCROLL) 972 1009 { 973 1010 POINT CursorPoint; 974 1011 winMsg->message = WINWM_MOUSEWHEEL; 975 1012 if (OSLibWinQueryPointerPos(&CursorPoint)) 976 1013 mapScreenPoint((OSLIBPOINT*)&CursorPoint); 977 1014 978 1015 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEDOWN) 979 winMsg->wParam = MAKELONG(GetMouseKeyState(), -WHEEL_DELTA/OS2_WHEEL_CORRECTION); 1016 winMsg->wParam = MAKELONG(GetMouseKeyState(), -WHEEL_DELTA/OS2_WHEEL_CORRECTION); 980 1017 else 981 1018 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEUP) 982 winMsg->wParam = MAKELONG(GetMouseKeyState(), WHEEL_DELTA/OS2_WHEEL_CORRECTION); 1019 winMsg->wParam = MAKELONG(GetMouseKeyState(), WHEEL_DELTA/OS2_WHEEL_CORRECTION); 983 1020 else 984 winMsg->wParam = MAKELONG(GetMouseKeyState(), 0); 985 986 winMsg->lParam = MAKELONG(CursorPoint.x, CursorPoint.y); 987 988 dprintf(("WM_MOUSEWHEEL message delta %d at (%d,%d)",HIWORD(winMsg->wParam),CursorPoint.x, CursorPoint.y)); 1021 winMsg->wParam = MAKELONG(GetMouseKeyState(), 0); 1022 1023 winMsg->lParam = MAKELONG(CursorPoint.x, CursorPoint.y); 1024 1025 dprintf(("WM_MOUSEWHEEL message delta %d at (%d,%d)",HIWORD(winMsg->wParam),CursorPoint.x, CursorPoint.y)); 989 1026 if (fMsgRemoved == MSG_REMOVE) 990 1027 { 991 992 993 994 995 996 hook.mouseData = MAKELONG(GetMouseKeyState(), -WHEEL_DELTA/OS2_WHEEL_CORRECTION); 997 998 999 hook.mouseData = MAKELONG(GetMouseKeyState(), WHEEL_DELTA/OS2_WHEEL_CORRECTION); 1000 1001 1002 1003 1004 1005 1006 1007 1028 MSLLHOOKSTRUCT hook; 1029 1030 hook.pt.x = os2Msg->ptl.x & 0xFFFF; 1031 hook.pt.y = mapScreenY(os2Msg->ptl.y); 1032 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEDOWN) 1033 hook.mouseData = MAKELONG(GetMouseKeyState(), -WHEEL_DELTA/OS2_WHEEL_CORRECTION); 1034 else 1035 if (SHORT2FROMMP(os2Msg->mp2) == SB_LINEUP) 1036 hook.mouseData = MAKELONG(GetMouseKeyState(), WHEEL_DELTA/OS2_WHEEL_CORRECTION); 1037 else goto dummymessage; // IBM driver produces other messages as well sometimes 1038 1039 hook.flags = LLMHF_INJECTED; 1040 hook.time = winMsg->time; 1041 hook.dwExtraInfo = 0; 1042 if(HOOK_CallHooksW( WH_MOUSE_LL, HC_ACTION, WINWM_MOUSEWHEEL, (LPARAM)&hook)) 1043 goto dummymessage; //hook swallowed message 1044 } 1008 1045 break; 1009 } 1046 } 1010 1047 goto dummymessage; //eat this message 1011 1048 break; … … 1054 1091 TEB *teb; 1055 1092 MSG extramsg; 1056 BOOL numPressed = (BOOL)(WinGetKeyState(HWND_DESKTOP,VK_NUMLOCK) & 1); 1093 BOOL numPressed = (BOOL)(WinGetKeyState(HWND_DESKTOP,VK_NUMLOCK) & 1); 1057 1094 teb = GetThreadTEB(); 1058 1095 if(!teb) … … 1061 1098 UCHAR ucPMScanCode = CHAR4FROMMP(teb->o.odin.os2msg.mp1); 1062 1099 ULONG fl = SHORT1FROMMP(teb->o.odin.os2msg.mp1); 1063 1064 1100 1101 1065 1102 //NOTE: These actually need to be posted so that the next message retrieved by GetMessage contains 1066 1103 // the newly generated WM_CHAR message. 1067 1104 if(!teb->o.odin.fTranslated && 1068 teb->o.odin.os2msg.msg == WM_CHAR && 1105 teb->o.odin.os2msg.msg == WM_CHAR && 1069 1106 !((SHORT1FROMMP(teb->o.odin.os2msg.mp1) & KC_KEYUP) == KC_KEYUP)) 1070 1107 { … … 1083 1120 break; 1084 1121 } 1085 1122 1086 1123 // PF With NumLock off do not generate any WM_CHAR messages at all 1087 1124 // PADMINUS,PADPLUS fall in range of PAD7..PADPERIOD but they should generate WM_CHAR … … 1089 1126 if (!numPressed && (ucPMScanCode != PMSCAN_PADMINUS) && (ucPMScanCode != PMSCAN_PADPLUS) && 1090 1127 (ucPMScanCode >= PMSCAN_PAD7) && (ucPMScanCode <= PMSCAN_PADPERIOD)) 1091 return FALSE; 1092 1093 if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN) 1128 return FALSE; 1129 1130 if(!(fl & KC_CHAR) && msg->message < WINWM_SYSKEYDOWN) 1094 1131 { 1095 1132 return FALSE; … … 1103 1140 if(msg->wParam) 1104 1141 { 1105 if ((msg->wParam >= VK_NUMPAD0_W) && 1142 if ((msg->wParam >= VK_NUMPAD0_W) && 1106 1143 (msg->wParam <= VK_NUMPAD9_W)) 1107 1144 extramsg.wParam = msg->wParam - 0x30; … … 1114 1151 extramsg.wParam = msg->wParam; 1115 1152 } 1116 else 1153 else 1117 1154 extramsg.wParam = SHORT2FROMMP(teb->o.odin.os2msg.mp2); 1118 1155 } … … 1120 1157 1121 1158 //After SetFocus(0), all keystrokes are converted in WM_SYS* 1122 if(msg->message >= WINWM_SYSKEYDOWN || fIgnoreKeystrokes) 1159 if(msg->message >= WINWM_SYSKEYDOWN || fIgnoreKeystrokes) 1123 1160 extramsg.message = WINWM_SYSCHAR; 1124 else 1161 else 1125 1162 extramsg.message = WINWM_CHAR; 1126 1163
Note:
See TracChangeset
for help on using the changeset viewer.