Changeset 8949 for trunk/src/user32/windowmsg.cpp
- Timestamp:
- Jul 31, 2002, 6:51:00 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/windowmsg.cpp
r8689 r8949 1 /* $Id: windowmsg.cpp,v 1.3 4 2002-06-15 17:17:17sandervl Exp $ */1 /* $Id: windowmsg.cpp,v 1.35 2002-07-31 16:51:00 sandervl Exp $ */ 2 2 /* 3 3 * Win32 window message APIs for OS/2 … … 829 829 MSG msg; 830 830 831 dprintf(("MsgWaitForMultipleObjects %x %x %d %d %x", nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask)); 832 // @@@PH this is a temporary bugfix for WINFILE.EXE 833 if (nCount == 0) 834 { 835 if(dwMilliseconds == 0) { 836 if(GetQueueStatus(dwWakeMask) == 0) { 837 return WAIT_TIMEOUT; 838 } 839 return WAIT_OBJECT_0; 840 } 841 //SvL: Check time, wait for any message, check msg type and determine if 842 // we have to return 843 //TODO: Timeout isn't handled correctly (can return too late) 831 //TODO: Functions such as GetMessage, PeekMessage and WaitMessage can mark messages as old 832 // MsgWaitForMultipleObjects shouldn't return until new input has arrived (MSDN) 833 // We are not 100% correct with this implementation. GetQueueStatus checks all messages 834 // in the queue. 835 // Very obscure behaviour, so it's unlikely any application depends on it 836 dprintf(("MsgWaitForMultipleObjects %x %x %d %d %x", nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask)); 837 if(fWaitAll) 838 { //wait for message arrival first 844 839 curtime = GetCurrentTime(); 845 840 endtime = curtime + dwMilliseconds; 846 841 while(curtime < endtime || dwMilliseconds == INFINITE) { 847 if(OSLibWinWaitMessage() == FALSE) { 848 dprintf(("OSLibWinWaitMessage returned FALSE!")); 849 return WAIT_ABANDONED; 850 } 851 if(GetQueueStatus(dwWakeMask) != 0) { 852 return WAIT_OBJECT_0; 853 } 854 //TODO: Ignoring all messages could be dangerous. But processing them, 855 //while the app doesn't expect any, isn't safe either. 856 if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) 857 { 858 if (msg.message == WM_QUIT) { 859 dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!")); 860 return WAIT_ABANDONED; 861 } 862 863 /* otherwise dispatch it */ 864 DispatchMessageA(&msg); 865 } 866 curtime = GetCurrentTime(); 867 } 868 return WAIT_TIMEOUT; 869 } 870 //Call handlemanager function as we need to translate handles (KERNEL32) 871 ret = HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask); 872 return ret; 873 } 842 if(OSLibWinWaitMessage() == FALSE) { 843 dprintf(("OSLibWinWaitMessage returned FALSE!")); 844 return WAIT_ABANDONED; 845 } 846 if(GetQueueStatus(dwWakeMask) != 0) { 847 break; 848 } 849 //TODO: Ignoring all messages could be dangerous. But processing them, 850 //while the app doesn't expect any, isn't safe either. 851 if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) 852 { 853 if (msg.message == WM_QUIT) { 854 dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!")); 855 return WAIT_ABANDONED; 856 } 857 858 /* otherwise dispatch it */ 859 DispatchMessageA(&msg); 860 } 861 curtime = GetCurrentTime(); 862 } 863 if(dwMilliseconds != INFINITE && curtime > endtime) { 864 dprintf(("No messages found in specified time")); 865 return WAIT_TIMEOUT; 866 } 867 //ok, the right message has arrived, now try to grab all objects 868 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, dwMilliseconds); 869 if(ret >= WAIT_OBJECT_0 + nCount) { 870 //failure 871 dprintf(("WaitForMultipleObjects failed with %d", ret)); 872 return ret; 873 } 874 return ret; 875 } 876 if(dwMilliseconds == 0) { 877 //TODO: what has a higher priority; message presence or signalled object? 878 if(GetQueueStatus(dwWakeMask) == 0) { 879 if(nCount) { 880 return WaitForMultipleObjects(nCount, pHandles, fWaitAll, dwMilliseconds); 881 } 882 return WAIT_TIMEOUT; 883 } 884 return WAIT_OBJECT_0 + nCount; //right message has arrived 885 } 886 //TODO: Timeout isn't handled correctly (can return too late) 887 curtime = GetCurrentTime(); 888 endtime = curtime + dwMilliseconds; 889 while(curtime < endtime || dwMilliseconds == INFINITE) { 890 //check queue status for presence of requested message types 891 if(GetQueueStatus(dwWakeMask) != 0) { 892 dprintf(("Found message(s) we were looking for. Return success")); 893 return WAIT_OBJECT_0 + nCount; //present, return success 894 } 895 //TODO: Ignoring all messages could be dangerous. But processing them, 896 //while the app doesn't expect any, isn't safe either. 897 if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) 898 { 899 if (msg.message == WM_QUIT) { 900 dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!")); 901 return WAIT_ABANDONED; 902 } 903 904 /* otherwise dispatch it */ 905 DispatchMessageA(&msg); 906 } 907 //check if any object is signalled (timeout 10ms) 908 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 10); 909 if(ret < WAIT_OBJECT_0 + nCount) { 910 //an object was signalled, return immediately 911 dprintf(("WaitForMultipleObjects success with %d", ret)); 912 return ret; 913 } 914 else 915 if(ret != WAIT_TIMEOUT) { 916 //failure, abort 917 dprintf(("WaitForMultipleObjects failed with %d", ret)); 918 return ret; 919 } 920 curtime = GetCurrentTime(); 921 } 922 return WAIT_TIMEOUT; 923 924 // //Call handlemanager function as we need to translate handles (KERNEL32) 925 // ret = HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask); 926 // return ret; 927 }
Note:
See TracChangeset
for help on using the changeset viewer.