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_IntSendMessageTimeout(HWND hWnd
,
190 BOOL FASTCALL
UserSendNotifyMessage( HWND hWnd
,UINT Msg
,WPARAM wParam
,LPARAM lParam
);
191 LRESULT FASTCALL
co_IntSendMessageNoWait(HWND hWnd
,
196 co_IntSendMessageWithCallBack(HWND hWnd
,
200 SENDASYNCPROC CompletionCallback
,
201 ULONG_PTR CompletionCallbackContext
,
205 IntDispatchMessage(MSG
* Msg
);
207 IntTranslateKbdMessage(LPMSG lpMsg
, UINT flags
);
210 co_MsqPostKeyboardMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
);
212 MsqPostHotKeyMessage(PVOID Thread
, HWND hWnd
, WPARAM wParam
, LPARAM lParam
);
214 co_MsqInsertMouseMessage(MSG
* Msg
);
216 MsqIsClkLck(LPMSG Msg
, BOOL Remove
);
218 MsqIsDblClk(LPMSG Msg
, BOOL Remove
);
220 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue
, ULONG Type
, HWND hWnd
);
222 __inline BOOL
MsqIsSignaled( PUSER_MESSAGE_QUEUE queue
);
223 __inline VOID
MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue
, WORD bits
);
224 BOOL APIENTRY
IntInitMessagePumpHook();
225 BOOL APIENTRY
IntUninitMessagePumpHook();
226 #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
228 LPARAM FASTCALL
MsqSetMessageExtraInfo(LPARAM lParam
);
229 LPARAM FASTCALL
MsqGetMessageExtraInfo(VOID
);
230 VOID APIENTRY
MsqRemoveWindowMessagesFromQueue(PVOID pWindow
); /* F*(&$ headers, will be gone in the rewrite! */
232 #define IntLockHardwareMessageQueue(MsgQueue) \
233 KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
235 #define IntUnLockHardwareMessageQueue(MsgQueue) \
236 KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
238 #define IntReferenceMessageQueue(MsgQueue) \
239 InterlockedIncrement(&(MsgQueue)->References)
241 #define IntDereferenceMessageQueue(MsgQueue) \
243 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
245 DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
246 if ((MsgQueue)->NewMessages != NULL) \
247 ObDereferenceObject((MsgQueue)->NewMessages); \
248 if ((MsgQueue)->NewMessagesHandle != NULL) \
249 ZwClose((MsgQueue)->NewMessagesHandle); \
250 ExFreePoolWithTag((MsgQueue), USERTAG_Q); \
254 #define IS_BTN_MESSAGE(message,code) \
255 ((message) == WM_LBUTTON##code || \
256 (message) == WM_MBUTTON##code || \
257 (message) == WM_RBUTTON##code || \
258 (message) == WM_XBUTTON##code || \
259 (message) == WM_NCLBUTTON##code || \
260 (message) == WM_NCMBUTTON##code || \
261 (message) == WM_NCRBUTTON##code || \
262 (message) == WM_NCXBUTTON##code )
264 #define WM_NCMOUSEFIRST WM_NCMOUSEMOVE
265 #define WM_NCMOUSELAST (WM_NCMOUSEFIRST+(WM_MOUSELAST-WM_MOUSEFIRST))
267 #define IS_MOUSE_MESSAGE(message) \
268 ((message >= WM_NCMOUSEFIRST && message <= WM_NCMOUSELAST) || \
269 (message >= WM_MOUSEFIRST && message <= WM_MOUSELAST))
271 #define IS_KBD_MESSAGE(message) \
272 (message == WM_KEYDOWN || message == WM_KEYUP)
275 IntMsqSetWakeMask(DWORD WakeMask
);
278 IntMsqClearWakeMask(VOID
);
281 MsqCalculateMessageTime(IN PLARGE_INTEGER TickCount
)
283 return (LONG
)(TickCount
->QuadPart
* (KeQueryTimeIncrement() / 10000));
286 VOID FASTCALL
IdlePing(VOID
);
287 VOID FASTCALL
IdlePong(VOID
);
288 BOOL FASTCALL
co_MsqReplyMessage(LRESULT
);
289 UINT FASTCALL
GetWakeMask(UINT
, UINT
);
290 VOID FASTCALL
MsqWakeQueue(PUSER_MESSAGE_QUEUE
,DWORD
,BOOL
);
291 VOID FASTCALL
ClearMsgBitsMask(PUSER_MESSAGE_QUEUE
,UINT
);