9 #define MSQ_SENTNOWAIT 0x80000000
13 typedef enum _QS_ROS_TYPES
21 }QS_ROS_TYPES
,*PQS_ROS_TYPES
;
23 typedef struct _USER_MESSAGE
28 } USER_MESSAGE
, *PUSER_MESSAGE
;
30 struct _USER_MESSAGE_QUEUE
;
32 typedef struct _USER_SENT_MESSAGE
36 DWORD QS_Flags
; // Original QS bits used to create this message.
37 PKEVENT CompletionEvent
;
40 struct _USER_MESSAGE_QUEUE
* SenderQueue
;
41 struct _USER_MESSAGE_QUEUE
* CallBackSenderQueue
;
42 SENDASYNCPROC CompletionCallback
;
43 ULONG_PTR CompletionCallbackContext
;
44 /* entry in the dispatching list of the sender's message queue */
45 LIST_ENTRY DispatchingListEntry
;
48 } USER_SENT_MESSAGE
, *PUSER_SENT_MESSAGE
;
50 typedef struct _USER_MESSAGE_QUEUE
52 /* Reference counter, only access this variable with interlocked functions! */
55 /* Owner of the message queue */
56 struct _ETHREAD
*Thread
;
57 /* Queue of messages sent to the queue. */
58 LIST_ENTRY SentMessagesListHead
;
59 /* Queue of messages posted to the queue. */
60 LIST_ENTRY PostedMessagesListHead
;
61 /* Queue for hardware messages for the queue. */
62 LIST_ENTRY HardwareMessagesListHead
;
63 /* Lock for the hardware message list. */
65 /* True if a WM_MOUSEMOVE is pending */
67 /* Current WM_MOUSEMOVE message */
69 /* Last click message for translating double clicks */
71 /* True if a WM_QUIT message is pending. */
73 /* The quit exit code. */
75 /* Set if there are new messages specified by WakeMask in any of the queues. */
77 /* Handle for the above event (in the context of the process owning the queue). */
78 HANDLE NewMessagesHandle
;
79 /* Last time PeekMessage() was called. */
81 /* Current window with focus (ie. receives keyboard input) for this queue. */
83 /* Current active window for this queue. */
85 /* Current capture window for this queue. */
87 /* Current move/size window for this queue */
89 /* Current menu owner window for this queue */
91 /* Identifes the menu state */
93 /* Caret information for this queue */
94 PTHRDCARETINFO CaretInfo
;
96 /* queue state tracking */
97 // Send list QS_SENDMESSAGE
98 // Post list QS_POSTMESSAGE|QS_HOTKEY|QS_PAINT|QS_TIMER|QS_KEY
99 // Hard list QS_MOUSE|QS_KEY only
100 // Accounting of queue bit sets, the rest are flags. QS_TIMER QS_PAINT counts are handled in thread information.
101 DWORD nCntsQBits
[QSIDCOUNTS
]; // QS_KEY QS_MOUSEMOVE QS_MOUSEBUTTON QS_POSTMESSAGE QS_SENDMESSAGE QS_HOTKEY
103 /* extra message information */
106 /* messages that are currently dispatched by other threads */
107 LIST_ENTRY DispatchingMessagesHead
;
108 /* messages that are currently dispatched by this message queue, required for cleanup */
109 LIST_ENTRY LocalDispatchingMessagesHead
;
111 /* Desktop that the message queue is attached to */
112 struct _DESKTOP
*Desktop
;
113 } USER_MESSAGE_QUEUE
, *PUSER_MESSAGE_QUEUE
;
116 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue
);
118 co_MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
119 HWND Wnd
, UINT Msg
, WPARAM wParam
, LPARAM lParam
,
120 UINT uTimeout
, BOOL Block
, INT HookMessage
,
122 PUSER_MESSAGE FASTCALL
123 MsqCreateMessage(LPMSG Msg
);
125 MsqDestroyMessage(PUSER_MESSAGE Message
);
127 MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue
,
128 MSG
* Msg
, BOOLEAN HardwareMessage
, DWORD MessageBits
);
130 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG ExitCode
);
132 MsqPeekMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
135 IN UINT MsgFilterLow
,
136 IN UINT MsgFilterHigh
,
140 co_MsqPeekHardwareMessage(IN PUSER_MESSAGE_QUEUE MessageQueue
,
143 IN UINT MsgFilterLow
,
144 IN UINT MsgFilterHigh
,
148 co_MsqPeekMouseMove(IN PUSER_MESSAGE_QUEUE MessageQueue
,
151 IN UINT MsgFilterLow
,
152 IN UINT MsgFilterHigh
,
155 MsqInitializeMessageQueue(struct _ETHREAD
*Thread
, PUSER_MESSAGE_QUEUE MessageQueue
);
157 MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
158 PUSER_MESSAGE_QUEUE FASTCALL
159 MsqCreateMessageQueue(struct _ETHREAD
*Thread
);
161 MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue
);
162 PUSER_MESSAGE_QUEUE FASTCALL
163 MsqGetHardwareMessageQueue(VOID
);
167 MsqInitializeImpl(VOID
);
169 co_MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue
);
171 co_MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue
, PWND WndFilter
,
172 UINT MsgFilterMin
, UINT MsgFilterMax
);
174 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
176 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue
);
178 co_IntSendMessage(HWND hWnd
,
183 co_IntPostOrSendMessage(HWND hWnd
,
188 co_IntSendMessageTimeout(HWND hWnd
,
196 BOOL FASTCALL
UserSendNotifyMessage( HWND hWnd
,UINT Msg
,WPARAM wParam
,LPARAM lParam
);
197 LRESULT FASTCALL
co_IntSendMessageNoWait(HWND hWnd
,
202 co_IntSendMessageWithCallBack(HWND hWnd
,
206 SENDASYNCPROC CompletionCallback
,
207 ULONG_PTR CompletionCallbackContext
,
211 IntDispatchMessage(MSG
* Msg
);
213 IntTranslateKbdMessage(LPMSG lpMsg
, UINT flags
);
216 co_MsqPostKeyboardMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
218 MsqPostHotKeyMessage(PVOID Thread
, HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
220 co_MsqInsertMouseMessage(MSG
* Msg
);
222 MsqIsClkLck(LPMSG Msg
, BOOL Remove
);
224 MsqIsDblClk(LPMSG Msg
, BOOL Remove
);
226 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG Type
, HWND hWnd
);
228 __inline BOOL
MsqIsSignaled( PUSER_MESSAGE_QUEUE queue
);
229 __inline VOID
MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
230 BOOL APIENTRY
IntInitMessagePumpHook();
231 BOOL APIENTRY
IntUninitMessagePumpHook();
232 #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
234 LPARAM FASTCALL
MsqSetMessageExtraInfo(LPARAM lParam
);
235 LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID
);
236 VOID APIENTRY
MsqRemoveWindowMessagesFromQueue(PVOID pWindow
); /* F*(&$ headers, will be gone in the rewrite! */
238 #define IntLockHardwareMessageQueue(MsgQueue) \
239 KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
241 #define IntUnLockHardwareMessageQueue(MsgQueue) \
242 KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
244 #define IntReferenceMessageQueue(MsgQueue) \
245 InterlockedIncrement(&(MsgQueue)->References)
247 #define IntDereferenceMessageQueue(MsgQueue) \
249 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
251 DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
252 if ((MsgQueue)->NewMessages != NULL) \
253 ObDereferenceObject((MsgQueue)->NewMessages); \
254 if ((MsgQueue)->NewMessagesHandle != NULL) \
255 ZwClose((MsgQueue)->NewMessagesHandle); \
256 ExFreePoolWithTag((MsgQueue), USERTAG_Q); \
260 #define IS_BTN_MESSAGE(message,code) \
261 ((message) == WM_LBUTTON##code || \
262 (message) == WM_MBUTTON##code || \
263 (message) == WM_RBUTTON##code || \
264 (message) == WM_XBUTTON##code || \
265 (message) == WM_NCLBUTTON##code || \
266 (message) == WM_NCMBUTTON##code || \
267 (message) == WM_NCRBUTTON##code || \
268 (message) == WM_NCXBUTTON##code )
270 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
271 #define WM_NCMOUSELAST (WM_NCMOUSEFIRST+(WM_MOUSELAST-WM_MOUSEFIRST))
273 #define IS_MOUSE_MESSAGE(message) \
274 ((message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST) || \
275 (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST))
277 #define IS_KBD_MESSAGE(message) \
278 (message == WM_KEYDOWN || message == WM_KEYUP)
281 IntMsqSetWakeMask(DWORD WakeMask
);
284 IntMsqClearWakeMask(VOID
);
287 MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount
)
289 return (LONG
)(TickCount
->QuadPart
* (KeQueryTimeIncrement() / 10000));
292 VOID FASTCALL
IdlePing(VOID
);
293 VOID FASTCALL
IdlePong(VOID
);
294 BOOL FASTCALL
co_MsqReplyMessage(LRESULT
);
295 UINT FASTCALL
GetWakeMask(UINT
, UINT
);
296 VOID FASTCALL
MsqWakeQueue(PUSER_MESSAGE_QUEUE
,DWORD
,BOOL
);
297 VOID FASTCALL
ClearMsgBitsMask(PUSER_MESSAGE_QUEUE
,UINT
);