fix stupied Ret uninitialized in IntChangeDisplaySettings for DGB=0 build
[reactos.git] / reactos / subsys / win32k / include / msgqueue.h
1 #ifndef _WIN32K_MSGQUEUE_H
2 #define _WIN32K_MSGQUEUE_H
3
4 #include <internal/ex.h>
5 #include <windows.h>
6 #include "caret.h"
7 #include "hook.h"
8
9 #define MSQ_HUNG 5000
10
11 typedef struct _USER_MESSAGE
12 {
13 LIST_ENTRY ListEntry;
14 BOOLEAN FreeLParam;
15 MSG Msg;
16 } USER_MESSAGE, *PUSER_MESSAGE;
17
18 struct _USER_MESSAGE_QUEUE;
19
20 typedef struct _USER_SENT_MESSAGE
21 {
22 LIST_ENTRY ListEntry;
23 MSG Msg;
24 PKEVENT CompletionEvent;
25 LRESULT* Result;
26 struct _USER_MESSAGE_QUEUE* SenderQueue;
27 SENDASYNCPROC CompletionCallback;
28 ULONG_PTR CompletionCallbackContext;
29 /* entry in the dispatching list of the sender's message queue */
30 LIST_ENTRY DispatchingListEntry;
31 BOOL HookMessage;
32 } USER_SENT_MESSAGE, *PUSER_SENT_MESSAGE;
33
34 typedef struct _USER_SENT_MESSAGE_NOTIFY
35 {
36 SENDASYNCPROC CompletionCallback;
37 ULONG_PTR CompletionCallbackContext;
38 LRESULT Result;
39 HWND hWnd;
40 UINT Msg;
41 LIST_ENTRY ListEntry;
42 } USER_SENT_MESSAGE_NOTIFY, *PUSER_SENT_MESSAGE_NOTIFY;
43
44 typedef struct _TIMER_ENTRY{
45 LIST_ENTRY ListEntry;
46 LARGE_INTEGER ExpiryTime;
47 HWND Wnd;
48 UINT_PTR IDEvent;
49 UINT Period;
50 TIMERPROC TimerFunc;
51 UINT Msg;
52 } TIMER_ENTRY, *PTIMER_ENTRY;
53
54 typedef struct _USER_MESSAGE_QUEUE
55 {
56 /* Reference counter, only access this variable with interlocked functions! */
57 LONG References;
58
59 /* Owner of the message queue */
60 struct _ETHREAD *Thread;
61 /* Queue of messages sent to the queue. */
62 LIST_ENTRY SentMessagesListHead;
63 /* Queue of messages posted to the queue. */
64 LIST_ENTRY PostedMessagesListHead;
65 /* Queue of sent-message notifies for the queue. */
66 LIST_ENTRY NotifyMessagesListHead;
67 /* Queue for hardware messages for the queue. */
68 LIST_ENTRY HardwareMessagesListHead;
69 /* List of timers, sorted on expiry time (earliest first) */
70 LIST_ENTRY TimerListHead;
71 /* Lock for the hardware message list. */
72 KMUTEX HardwareLock;
73 /* Lock for the queue. */
74 FAST_MUTEX Lock;
75 /* Pointer to the current WM_MOUSEMOVE message */
76 PUSER_MESSAGE MouseMoveMsg;
77 /* True if a WM_QUIT message is pending. */
78 BOOLEAN QuitPosted;
79 /* The quit exit code. */
80 ULONG QuitExitCode;
81 /* Set if there are new messages specified by WakeMask in any of the queues. */
82 PKEVENT NewMessages;
83 /* Handle for the above event (in the context of the process owning the queue). */
84 HANDLE NewMessagesHandle;
85 /* Last time PeekMessage() was called. */
86 ULONG LastMsgRead;
87 /* Current window with focus (ie. receives keyboard input) for this queue. */
88 HWND FocusWindow;
89 /* True if a window needs painting. */
90 BOOLEAN PaintPosted;
91 /* Count of paints pending. */
92 ULONG PaintCount;
93 /* Current active window for this queue. */
94 HWND ActiveWindow;
95 /* Current capture window for this queue. */
96 HWND CaptureWindow;
97 /* Current move/size window for this queue */
98 HWND MoveSize;
99 /* Current menu owner window for this queue */
100 HWND MenuOwner;
101 /* Identifes the menu state */
102 BYTE MenuState;
103 /* Caret information for this queue */
104 PTHRDCARETINFO CaretInfo;
105
106 /* Window hooks */
107 PHOOKTABLE Hooks;
108
109 /* queue state tracking */
110 WORD WakeMask;
111 WORD QueueBits;
112 WORD ChangedBits;
113
114 /* extra message information */
115 LPARAM ExtraInfo;
116
117 /* messages that are currently dispatched by other threads */
118 LIST_ENTRY DispatchingMessagesHead;
119 /* messages that are currently dispatched by this message queue, required for cleanup */
120 LIST_ENTRY LocalDispatchingMessagesHead;
121
122 /* Desktop that the message queue is attached to */
123 struct _DESKTOP_OBJECT *Desktop;
124 } USER_MESSAGE_QUEUE, *PUSER_MESSAGE_QUEUE;
125
126 BOOL FASTCALL
127 MsqIsHung(PUSER_MESSAGE_QUEUE MessageQueue);
128 NTSTATUS FASTCALL
129 MsqSendMessage(PUSER_MESSAGE_QUEUE MessageQueue,
130 HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam,
131 UINT uTimeout, BOOL Block, BOOL HookMessage,
132 ULONG_PTR *uResult);
133 PUSER_MESSAGE FASTCALL
134 MsqCreateMessage(LPMSG Msg, BOOLEAN FreeLParam);
135 VOID FASTCALL
136 MsqDestroyMessage(PUSER_MESSAGE Message);
137 VOID FASTCALL
138 MsqPostMessage(PUSER_MESSAGE_QUEUE MessageQueue,
139 MSG* Msg, BOOLEAN FreeLParam, DWORD MessageBits);
140 VOID FASTCALL
141 MsqPostQuitMessage(PUSER_MESSAGE_QUEUE MessageQueue, ULONG ExitCode);
142 BOOLEAN STDCALL
143 MsqFindMessage(IN PUSER_MESSAGE_QUEUE MessageQueue,
144 IN BOOLEAN Hardware,
145 IN BOOLEAN Remove,
146 IN HWND Wnd,
147 IN UINT MsgFilterLow,
148 IN UINT MsgFilterHigh,
149 OUT PUSER_MESSAGE* Message);
150 BOOLEAN FASTCALL
151 MsqInitializeMessageQueue(struct _ETHREAD *Thread, PUSER_MESSAGE_QUEUE MessageQueue);
152 VOID FASTCALL
153 MsqCleanupMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
154 PUSER_MESSAGE_QUEUE FASTCALL
155 MsqCreateMessageQueue(struct _ETHREAD *Thread);
156 VOID FASTCALL
157 MsqDestroyMessageQueue(PUSER_MESSAGE_QUEUE MessageQueue);
158 PUSER_MESSAGE_QUEUE FASTCALL
159 MsqGetHardwareMessageQueue(VOID);
160 NTSTATUS FASTCALL
161 MsqInitializeImpl(VOID);
162 BOOLEAN FASTCALL
163 MsqDispatchOneSentMessage(PUSER_MESSAGE_QUEUE MessageQueue);
164 NTSTATUS FASTCALL
165 MsqWaitForNewMessages(PUSER_MESSAGE_QUEUE MessageQueue, HWND WndFilter,
166 UINT MsgFilterMin, UINT MsgFilterMax);
167 VOID FASTCALL
168 MsqSendNotifyMessage(PUSER_MESSAGE_QUEUE MessageQueue,
169 PUSER_SENT_MESSAGE_NOTIFY NotifyMessage);
170 VOID FASTCALL
171 MsqIncPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
172 VOID FASTCALL
173 MsqDecPaintCountQueue(PUSER_MESSAGE_QUEUE Queue);
174 LRESULT FASTCALL
175 IntSendMessage(HWND hWnd,
176 UINT Msg,
177 WPARAM wParam,
178 LPARAM lParam);
179 LRESULT FASTCALL
180 IntPostOrSendMessage(HWND hWnd,
181 UINT Msg,
182 WPARAM wParam,
183 LPARAM lParam);
184 LRESULT FASTCALL
185 IntSendMessageTimeout(HWND hWnd,
186 UINT Msg,
187 WPARAM wParam,
188 LPARAM lParam,
189 UINT uFlags,
190 UINT uTimeout,
191 ULONG_PTR *uResult);
192 LRESULT FASTCALL
193 IntDispatchMessage(MSG* Msg);
194 BOOL FASTCALL
195 IntTranslateKbdMessage(LPMSG lpMsg, HKL dwhkl);
196
197 VOID FASTCALL
198 MsqPostKeyboardMessage(UINT uMsg, WPARAM wParam, LPARAM lParam);
199 VOID FASTCALL
200 MsqPostHotKeyMessage(PVOID Thread, HWND hWnd, WPARAM wParam, LPARAM lParam);
201 VOID FASTCALL
202 MsqInsertSystemMessage(MSG* Msg);
203 BOOL FASTCALL
204 MsqIsDblClk(LPMSG Msg, BOOL Remove);
205 HWND FASTCALL
206 MsqSetStateWindow(PUSER_MESSAGE_QUEUE MessageQueue, ULONG Type, HWND hWnd);
207
208 inline BOOL MsqIsSignaled( PUSER_MESSAGE_QUEUE queue );
209 inline VOID MsqSetQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits );
210 inline VOID MsqClearQueueBits( PUSER_MESSAGE_QUEUE queue, WORD bits );
211 BOOL STDCALL IntInitMessagePumpHook();
212 BOOL STDCALL IntUninitMessagePumpHook();
213 #define MAKE_LONG(x, y) ((((y) & 0xFFFF) << 16) | ((x) & 0xFFFF))
214
215 PHOOKTABLE FASTCALL MsqGetHooks(PUSER_MESSAGE_QUEUE Queue);
216 VOID FASTCALL MsqSetHooks(PUSER_MESSAGE_QUEUE Queue, PHOOKTABLE Hooks);
217
218 LPARAM FASTCALL MsqSetMessageExtraInfo(LPARAM lParam);
219 LPARAM FASTCALL MsqGetMessageExtraInfo(VOID);
220 VOID STDCALL MsqRemoveWindowMessagesFromQueue(PVOID pWindow); /* F*(&$ headers, will be gone in the rewrite! */
221
222 #define IntLockMessageQueue(MsgQueue) \
223 ExAcquireFastMutex(&(MsgQueue)->Lock)
224
225 #define IntUnLockMessageQueue(MsgQueue) \
226 ExReleaseFastMutex(&(MsgQueue)->Lock)
227
228 #define IntLockHardwareMessageQueue(MsgQueue) \
229 KeWaitForMutexObject(&(MsgQueue)->HardwareLock, UserRequest, KernelMode, FALSE, NULL)
230
231 #define IntUnLockHardwareMessageQueue(MsgQueue) \
232 KeReleaseMutex(&(MsgQueue)->HardwareLock, FALSE)
233
234 #define IntReferenceMessageQueue(MsgQueue) \
235 InterlockedIncrement(&(MsgQueue)->References)
236
237 #define IntDereferenceMessageQueue(MsgQueue) \
238 do { \
239 if(InterlockedDecrement(&(MsgQueue)->References) == 0) \
240 { \
241 DPRINT("Free message queue 0x%x\n", (MsgQueue)); \
242 if ((MsgQueue)->NewMessagesHandle != NULL) \
243 ZwClose((MsgQueue)->NewMessagesHandle); \
244 ExFreePool((MsgQueue)); \
245 } \
246 } while(0)
247
248 #define IS_BTN_MESSAGE(message,code) \
249 ((message) == WM_LBUTTON##code || \
250 (message) == WM_MBUTTON##code || \
251 (message) == WM_RBUTTON##code || \
252 (message) == WM_XBUTTON##code || \
253 (message) == WM_NCLBUTTON##code || \
254 (message) == WM_NCMBUTTON##code || \
255 (message) == WM_NCRBUTTON##code || \
256 (message) == WM_NCXBUTTON##code )
257
258 HANDLE FASTCALL
259 IntMsqSetWakeMask(DWORD WakeMask);
260
261 BOOL FASTCALL
262 IntMsqClearWakeMask(VOID);
263
264 BOOLEAN FASTCALL
265 MsqSetTimer(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd,
266 UINT_PTR IDEvent, UINT Period, TIMERPROC TimerFunc,
267 UINT Msg);
268 BOOLEAN FASTCALL
269 MsqKillTimer(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd,
270 UINT_PTR IDEvent, UINT Msg);
271 BOOLEAN FASTCALL
272 MsqGetTimerMessage(PUSER_MESSAGE_QUEUE MessageQueue,
273 HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
274 MSG *Msg, BOOLEAN Restart);
275 BOOLEAN FASTCALL
276 MsqGetFirstTimerExpiry(PUSER_MESSAGE_QUEUE MessageQueue,
277 HWND WndFilter, UINT MsgFilterMin, UINT MsgFilterMax,
278 PLARGE_INTEGER FirstTimerExpiry);
279 VOID FASTCALL
280 MsqRemoveTimersWindow(PUSER_MESSAGE_QUEUE MessageQueue, HWND Wnd);
281
282 #endif /* _WIN32K_MSGQUEUE_H */
283
284 /* EOF */