Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
5.1 KiB

  1. /****************************** Module Header ******************************\
  2. * Module Name: input.c
  3. *
  4. * Copyright (c) 1985 - 1999, Microsoft Corporation
  5. *
  6. * This module contains common input functions.
  7. *
  8. * History:
  9. * 09-12-95 JerrySh Created.
  10. \***************************************************************************/
  11. /***************************************************************************\
  12. * CheckMsgRange
  13. *
  14. * Checks to see if a message range is within a message filter
  15. *
  16. * History:
  17. * 11-13-90 DavidPe Created.
  18. * 11-Oct-1993 mikeke Macroized
  19. \***************************************************************************/
  20. #define CheckMsgRange(wMsgRangeMin, wMsgRangeMax, wMsgFilterMin, wMsgFilterMax) \
  21. ( ((wMsgFilterMin) > (wMsgFilterMax)) \
  22. ? ( ((wMsgRangeMax) > (wMsgFilterMax)) \
  23. &&((wMsgRangeMin) < (wMsgFilterMin))) \
  24. : ( ((wMsgRangeMax) >= (wMsgFilterMin)) \
  25. &&((wMsgRangeMin) <= (wMsgFilterMax))) \
  26. )
  27. /***************************************************************************\
  28. * CalcWakeMask
  29. *
  30. * Calculates which wakebits to check for based on the message
  31. * range specified by wMsgFilterMin/Max. This basically means
  32. * if the filter range didn't input WM_KEYUP and WM_KEYDOWN,
  33. * QS_KEY wouldn't be included.
  34. *
  35. * History:
  36. * 10-28-90 DavidPe Created.
  37. \***************************************************************************/
  38. UINT CalcWakeMask(
  39. UINT wMsgFilterMin,
  40. UINT wMsgFilterMax,
  41. UINT fsWakeMaskFilter)
  42. {
  43. UINT fsWakeMask;
  44. /*
  45. * New for NT5: wake mask filter.
  46. * In addition to the message filter, the application can also provide
  47. * a wake mask directly.
  48. * If none is provided, default to NT4 mask (plus QS_SENDMESSAGE).
  49. */
  50. if (fsWakeMaskFilter == 0) {
  51. fsWakeMask = (QS_ALLINPUT | QS_EVENT | QS_ALLPOSTMESSAGE);
  52. } else {
  53. /*
  54. * If the caller wants input, we force all input events. The
  55. * same goes for posted messages. We do this to keep NT4
  56. * compatibility as much as possible.
  57. */
  58. if (fsWakeMaskFilter & QS_INPUT) {
  59. fsWakeMaskFilter |= (QS_INPUT | QS_EVENT);
  60. }
  61. if (fsWakeMaskFilter & (QS_POSTMESSAGE | QS_TIMER | QS_HOTKEY)) {
  62. fsWakeMaskFilter |= (QS_POSTMESSAGE | QS_TIMER | QS_HOTKEY);
  63. }
  64. fsWakeMask = fsWakeMaskFilter;
  65. }
  66. #ifndef _USERK_
  67. /*
  68. * The client PeekMessage in client\cltxt.h didn't used to
  69. * call CalcWakeMask if wMsgFilterMax was 0. We call it now
  70. * to take care of fsWakeMaskFilter but still bail before
  71. * messing with the message filter.
  72. */
  73. if (wMsgFilterMax == 0) {
  74. return fsWakeMask;
  75. }
  76. #endif
  77. /*
  78. * Message filter.
  79. * If the filter doesn't match certain ranges, we take out bits one by one.
  80. * First check for a 0, 0 filter which means we want all input.
  81. */
  82. if (wMsgFilterMin == 0 && wMsgFilterMax == ((UINT)-1)) {
  83. return fsWakeMask;
  84. }
  85. /*
  86. * We're not looking at all posted messages.
  87. */
  88. fsWakeMask &= ~QS_ALLPOSTMESSAGE;
  89. /*
  90. * Check for mouse move messages.
  91. */
  92. if ((CheckMsgFilter(WM_NCMOUSEMOVE, wMsgFilterMin, wMsgFilterMax) == FALSE) &&
  93. (CheckMsgFilter(WM_MOUSEMOVE, wMsgFilterMin, wMsgFilterMax) == FALSE)) {
  94. fsWakeMask &= ~QS_MOUSEMOVE;
  95. }
  96. /*
  97. * First check to see if mouse buttons messages are in the filter range.
  98. */
  99. if ((CheckMsgRange(WM_NCLBUTTONDOWN, WM_NCMBUTTONDBLCLK, wMsgFilterMin,
  100. wMsgFilterMax) == FALSE) && (CheckMsgRange(WM_MOUSEFIRST + 1,
  101. WM_MOUSELAST, wMsgFilterMin, wMsgFilterMax) == FALSE)) {
  102. fsWakeMask &= ~QS_MOUSEBUTTON;
  103. }
  104. /*
  105. * Check for key messages.
  106. */
  107. if (CheckMsgRange(WM_KEYFIRST, WM_KEYLAST, wMsgFilterMin, wMsgFilterMax) == FALSE) {
  108. fsWakeMask &= ~QS_KEY;
  109. }
  110. #ifdef GENERIC_INPUT
  111. /*
  112. * Check for raw input messages
  113. */
  114. if (CheckMsgRange(WM_INPUT, WM_INPUT, wMsgFilterMin, wMsgFilterMax) == FALSE) {
  115. fsWakeMask &= ~QS_RAWINPUT;
  116. }
  117. #endif
  118. /*
  119. * Check for paint messages.
  120. */
  121. if (CheckMsgFilter(WM_PAINT, wMsgFilterMin, wMsgFilterMax) == FALSE) {
  122. fsWakeMask &= ~QS_PAINT;
  123. }
  124. /*
  125. * Check for timer messages.
  126. */
  127. if ((CheckMsgFilter(WM_TIMER, wMsgFilterMin, wMsgFilterMax) == FALSE) &&
  128. (CheckMsgFilter(WM_SYSTIMER,
  129. wMsgFilterMin, wMsgFilterMax) == FALSE)) {
  130. fsWakeMask &= ~QS_TIMER;
  131. }
  132. /*
  133. * Check also for WM_QUEUESYNC which maps to all input bits.
  134. * This was added for CBT/EXCEL processing. Without it, a
  135. * xxxPeekMessage(.... WM_QUEUESYNC, WM_QUEUESYNC, FALSE) would
  136. * not see the message. (bobgu 4/7/87)
  137. * Since the user can provide a wake mask now (fsWakeMaskFilter),
  138. * we also add QS_EVENT in this case (it was always set on NT4).
  139. */
  140. if (wMsgFilterMin == WM_QUEUESYNC) {
  141. fsWakeMask |= (QS_INPUT | QS_EVENT);
  142. }
  143. return fsWakeMask;
  144. }