Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

input.c

Go to the documentation of this file.
00001 /****************************** Module Header ******************************\ 00002 * Module Name: input.c 00003 * 00004 * Copyright (c) 1985 - 1999, Microsoft Corporation 00005 * 00006 * This module contains common input functions. 00007 * 00008 * History: 00009 * 09-12-95 JerrySh Created. 00010 \***************************************************************************/ 00011 00012 00013 /***************************************************************************\ 00014 * CheckMsgRange 00015 * 00016 * Checks to see if a message range is within a message filter 00017 * 00018 * History: 00019 * 11-13-90 DavidPe Created. 00020 * 11-Oct-1993 mikeke Macroized 00021 \***************************************************************************/ 00022 00023 #define CheckMsgRange(wMsgRangeMin, wMsgRangeMax, wMsgFilterMin, wMsgFilterMax) \ 00024 ( ((wMsgFilterMin) > (wMsgFilterMax)) \ 00025 ? ( ((wMsgRangeMax) > (wMsgFilterMax)) \ 00026 &&((wMsgRangeMin) < (wMsgFilterMin))) \ 00027 : ( ((wMsgRangeMax) >= (wMsgFilterMin)) \ 00028 &&((wMsgRangeMin) <= (wMsgFilterMax))) \ 00029 ) 00030 00031 /***************************************************************************\ 00032 * CalcWakeMask 00033 * 00034 * Calculates which wakebits to check for based on the message 00035 * range specified by wMsgFilterMin/Max. This basically means 00036 * if the filter range didn't input WM_KEYUP and WM_KEYDOWN, 00037 * QS_KEY wouldn't be included. 00038 * 00039 * History: 00040 * 10-28-90 DavidPe Created. 00041 \***************************************************************************/ 00042 00043 UINT CalcWakeMask( 00044 UINT wMsgFilterMin, 00045 UINT wMsgFilterMax, 00046 UINT fsWakeMaskFilter) 00047 { 00048 UINT fsWakeMask; 00049 00050 /* 00051 * New for NT5: wake mask filter. 00052 * In addition to the message filter, the application can also provide 00053 * a wake mask directly. 00054 * If none is provided, default to NT4 mask (plus QS_SENDMESSAGE). 00055 */ 00056 if (fsWakeMaskFilter == 0) { 00057 fsWakeMask = (QS_ALLINPUT | QS_EVENT | QS_ALLPOSTMESSAGE); 00058 } else { 00059 /* 00060 * If the caller wants input, we force all input events. The 00061 * same goes for posted messages. We do this to keep NT4 00062 * compatibility as much as possible. 00063 */ 00064 if (fsWakeMaskFilter & QS_INPUT) { 00065 fsWakeMaskFilter |= (QS_INPUT | QS_EVENT); 00066 } 00067 if (fsWakeMaskFilter & (QS_POSTMESSAGE | QS_TIMER | QS_HOTKEY)) { 00068 fsWakeMaskFilter |= (QS_POSTMESSAGE | QS_TIMER | QS_HOTKEY); 00069 } 00070 fsWakeMask = fsWakeMaskFilter; 00071 } 00072 00073 #ifndef _USERK_ 00074 /* 00075 * The client PeekMessage in client\cltxt.h didn't used to 00076 * call CalcWakeMask if wMsgFilterMax was 0. We call it now 00077 * to take care of fsWakeMaskFilter but still bail before 00078 * messing with the message filter. 00079 */ 00080 if (wMsgFilterMax == 0) { 00081 return fsWakeMask; 00082 } 00083 #endif 00084 00085 /* 00086 * Message filter. 00087 * If the filter doesn't match certain ranges, we take out bits one by one. 00088 * First check for a 0, 0 filter which means we want all input. 00089 */ 00090 if (wMsgFilterMin == 0 && wMsgFilterMax == ((UINT)-1)) { 00091 return fsWakeMask; 00092 } 00093 00094 /* 00095 * We're not looking at all posted messages. 00096 */ 00097 fsWakeMask &= ~QS_ALLPOSTMESSAGE; 00098 00099 /* 00100 * Check for mouse move messages. 00101 */ 00102 if ((CheckMsgFilter(WM_NCMOUSEMOVE, wMsgFilterMin, wMsgFilterMax) == FALSE) && 00103 (CheckMsgFilter(WM_MOUSEMOVE, wMsgFilterMin, wMsgFilterMax) == FALSE)) { 00104 fsWakeMask &= ~QS_MOUSEMOVE; 00105 } 00106 00107 /* 00108 * First check to see if mouse buttons messages are in the filter range. 00109 */ 00110 if ((CheckMsgRange(WM_NCLBUTTONDOWN, WM_NCMBUTTONDBLCLK, wMsgFilterMin, 00111 wMsgFilterMax) == FALSE) && (CheckMsgRange(WM_MOUSEFIRST + 1, 00112 WM_MOUSELAST, wMsgFilterMin, wMsgFilterMax) == FALSE)) { 00113 fsWakeMask &= ~QS_MOUSEBUTTON; 00114 } 00115 00116 /* 00117 * Check for key messages. 00118 */ 00119 if (CheckMsgRange(WM_KEYFIRST, WM_KEYLAST, 00120 wMsgFilterMin, wMsgFilterMax) == FALSE) { 00121 fsWakeMask &= ~QS_KEY; 00122 } 00123 00124 /* 00125 * Check for paint messages. 00126 */ 00127 if (CheckMsgFilter(WM_PAINT, wMsgFilterMin, wMsgFilterMax) == FALSE) { 00128 fsWakeMask &= ~QS_PAINT; 00129 } 00130 00131 /* 00132 * Check for timer messages. 00133 */ 00134 if ((CheckMsgFilter(WM_TIMER, wMsgFilterMin, wMsgFilterMax) == FALSE) && 00135 (CheckMsgFilter(WM_SYSTIMER, 00136 wMsgFilterMin, wMsgFilterMax) == FALSE)) { 00137 fsWakeMask &= ~QS_TIMER; 00138 } 00139 00140 /* 00141 * Check also for WM_QUEUESYNC which maps to all input bits. 00142 * This was added for CBT/EXCEL processing. Without it, a 00143 * xxxPeekMessage(.... WM_QUEUESYNC, WM_QUEUESYNC, FALSE) would 00144 * not see the message. (bobgu 4/7/87) 00145 * Since the user can provide a wake mask now (fsWakeMaskFilter), 00146 * we also add QS_EVENT in this case (it was always set on NT4). 00147 */ 00148 if (wMsgFilterMin == WM_QUEUESYNC) { 00149 fsWakeMask |= (QS_INPUT | QS_EVENT); 00150 } 00151 00152 return fsWakeMask; 00153 } 00154

Generated on Sat May 15 19:40:24 2004 for test by doxygen 1.3.7