Changeset 8954 for trunk/src/user32/windowmsg.cpp
- Timestamp:
- Aug 1, 2002, 6:05:51 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/windowmsg.cpp
r8949 r8954 1 /* $Id: windowmsg.cpp,v 1.3 5 2002-07-31 16:51:00sandervl Exp $ */1 /* $Id: windowmsg.cpp,v 1.36 2002-08-01 16:05:51 sandervl Exp $ */ 2 2 /* 3 3 * Win32 window message APIs for OS/2 … … 20 20 #include <os2sel.h> 21 21 22 #include <string.h> 22 23 #include <os2win.h> 23 24 #include <misc.h> … … 26 27 #include <heapstring.h> 27 28 #include <handlemanager.h> 29 #include <wprocess.h> 28 30 #include "oslibutil.h" 29 31 #include "oslibwin.h" … … 834 836 // in the queue. 835 837 // Very obscure behaviour, so it's unlikely any application depends on it 838 839 //4 cases: 840 //1: Wait for all -> check for message arrival, call WaitForMultipleObjects 841 //2: Timeout = 0 ms -> check for message arrival, call WaitForMultipleObjects with timeout 0 842 //3: nCount = 0 -> check for message arrival 843 //4: rest -> check for either message arrival or signalled object 844 836 845 dprintf(("MsgWaitForMultipleObjects %x %x %d %d %x", nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask)); 837 if(fWaitAll) 846 if(fWaitAll) //case 1 838 847 { //wait for message arrival first 839 848 curtime = GetCurrentTime(); … … 874 883 return ret; 875 884 } 876 if(dwMilliseconds == 0) { 885 if(dwMilliseconds == 0) { //case 2 877 886 //TODO: what has a higher priority; message presence or signalled object? 878 887 if(GetQueueStatus(dwWakeMask) == 0) { … … 884 893 return WAIT_OBJECT_0 + nCount; //right message has arrived 885 894 } 895 if(nCount == 0) //case 3 896 { 897 //SvL: Check time, wait for any message, check msg type and determine if 898 // we have to return 899 //TODO: Timeout isn't handled correctly (can return too late) 900 curtime = GetCurrentTime(); 901 endtime = curtime + dwMilliseconds; 902 while(curtime < endtime || dwMilliseconds == INFINITE) { 903 if(OSLibWinWaitMessage() == FALSE) { 904 dprintf(("OSLibWinWaitMessage returned FALSE!")); 905 return WAIT_ABANDONED; 906 } 907 if(GetQueueStatus(dwWakeMask) != 0) { 908 return WAIT_OBJECT_0; 909 } 910 //TODO: Ignoring all messages could be dangerous. But processing them, 911 //while the app doesn't expect any, isn't safe either. 912 if(PeekMessageA(&msg, NULL, 0, 0, PM_REMOVE)) 913 { 914 if (msg.message == WM_QUIT) { 915 dprintf(("ERROR: MsgWaitForMultipleObjects call abandoned because WM_QUIT msg was received!!")); 916 return WAIT_ABANDONED; 917 } 918 919 /* otherwise dispatch it */ 920 DispatchMessageA(&msg); 921 } 922 curtime = GetCurrentTime(); 923 } 924 return WAIT_TIMEOUT; 925 } 926 927 //Case 4: 928 #if 1 929 //Note: The WGSS implementation of this function is flawed. Returns 930 // when a message is sent to the msg queue, regardless of dwWakeMask 931 TEB *teb = GetTEBFromThreadId(GetCurrentThreadId()); 932 if(teb == NULL) { 933 DebugInt3(); 934 return WAIT_ABANDONED; 935 } 936 if(dwWakeMask & QS_POSTMESSAGE) { 937 if(GetQueueStatus(dwWakeMask) != 0) { 938 return WAIT_OBJECT_0+nCount; 939 } 940 941 HANDLE *pHandlesTmp = (HANDLE *)alloca((nCount+1)*sizeof(HANDLE)); 942 if(pHandlesTmp == NULL || !teb->o.odin.hPostMsgEvent) { 943 DebugInt3(); 944 return WAIT_ABANDONED; 945 } 946 memcpy(pHandlesTmp, pHandles, nCount*sizeof(HANDLE)); 947 pHandlesTmp[nCount] = teb->o.odin.hPostMsgEvent; 948 teb->o.odin.dwWakeMask = dwWakeMask; 949 950 ResetEvent(teb->o.odin.hPostMsgEvent); 951 ret = HMMsgWaitForMultipleObjects(nCount+1,pHandlesTmp,fWaitAll,dwMilliseconds,dwWakeMask); 952 //nCount + 2 -> message event -> return nCount + 1 953 teb->o.odin.dwWakeMask = 0; 954 return (ret == nCount + 2) ? (nCount + 1) : ret; 955 } 956 //Call handlemanager function as we need to translate handles (KERNEL32) 957 ret = HMMsgWaitForMultipleObjects(nCount,pHandles,fWaitAll,dwMilliseconds,dwWakeMask); 958 return ret; 959 #else 960 //This method has a high latency (too high for some apps) 886 961 //TODO: Timeout isn't handled correctly (can return too late) 887 962 curtime = GetCurrentTime(); … … 906 981 } 907 982 //check if any object is signalled (timeout 10ms) 908 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 10);983 ret = WaitForMultipleObjects(nCount, pHandles, fWaitAll, 4); 909 984 if(ret < WAIT_OBJECT_0 + nCount) { 910 985 //an object was signalled, return immediately … … 921 996 } 922 997 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 } 998 #endif 999 }
Note:
See TracChangeset
for help on using the changeset viewer.