Moved idle event handling to the server.
[wine.git] / include / queue.h
blob4a1be22bbe79c229369529e6eb5ca3e3b48311f8
1 /*
2 * Message queues definitions
4 * Copyright 1993 Alexandre Julliard
5 */
7 #ifndef __WINE_QUEUE_H
8 #define __WINE_QUEUE_H
10 #include "windef.h"
11 #include "winbase.h"
12 #include "wingdi.h"
13 #include "winuser.h"
14 #include "thread.h"
17 /* Message as stored in the queue (contains the extraInfo field) */
18 typedef struct tagQMSG
20 int type;
21 MSG msg;
22 DWORD extraInfo; /* Only in 3.1 */
24 struct tagQMSG *nextMsg;
25 struct tagQMSG *prevMsg;
26 } QMSG;
28 #define QMSG_WIN16 0
29 #define QMSG_WIN32A 1
30 #define QMSG_WIN32W 2
31 #define QMSG_HARDWARE 3
34 typedef struct tagSMSG
36 struct tagSMSG *nextProcessing; /* next SMSG in the processing list */
37 struct tagSMSG *nextPending; /* next SMSG in the pending list */
38 struct tagSMSG *nextWaiting; /* next SMSG in the waiting list */
40 HQUEUE16 hSrcQueue; /* sending Queue, (NULL if it didn't wait) */
41 HQUEUE16 hDstQueue; /* destination Queue */
43 HWND hWnd; /* destinantion window */
44 UINT msg; /* message sent */
45 WPARAM wParam; /* wParam of the sent message */
46 LPARAM lParam; /* lParam of the sent message */
48 LRESULT lResult; /* result of SendMessage */
49 WORD flags; /* see below SMSG_XXXX */
50 } SMSG;
53 /* SMSG -> flags values */
54 /* set when lResult contains a good value */
55 #define SMSG_HAVE_RESULT 0x0001
56 /* protection for multiple call to ReplyMessage16() */
57 #define SMSG_ALREADY_REPLIED 0x0002
58 /* use with EARLY_REPLY for forcing the receiver to clean SMSG */
59 #define SMSG_RECEIVER_CLEANS 0x0010
60 /* used with EARLY_REPLY to indicate to sender, receiver is done with SMSG */
61 #define SMSG_RECEIVED 0x0020
62 /* set in ReceiveMessage() to indicate it's not an early reply */
63 #define SMSG_SENDING_REPLY 0x0040
64 /* set when ReplyMessage16() is called by the application */
65 #define SMSG_EARLY_REPLY 0x0080
66 /* set when sender is Win32 thread */
67 #define SMSG_WIN32 0x1000
68 /* set when sender is a unnicode thread */
69 #define SMSG_UNICODE 0x2000
71 /* Per-queue data for the message queue
72 * Note that we currently only store the current values for
73 * Active, Capture and Focus windows currently.
74 * It might be necessary to store a pointer to the system message queue
75 * as well since windows 9x maintains per thread system message queues
77 typedef struct tagPERQUEUEDATA
79 HWND hWndFocus; /* Focus window */
80 HWND hWndActive; /* Active window */
81 HWND hWndCapture; /* Capture window */
82 INT16 nCaptureHT; /* Capture info (hit-test) */
83 ULONG ulRefCount; /* Reference count */
84 CRITICAL_SECTION cSection; /* Critical section for thread safe access */
85 } PERQUEUEDATA;
87 /* Message queue */
88 typedef struct tagMESSAGEQUEUE
90 HQUEUE16 next; /* Next queue */
91 HQUEUE16 self; /* Handle to self (was: reserved) */
92 TEB* teb; /* Thread owning queue */
93 HANDLE server_queue; /* Handle to server-side queue */
94 CRITICAL_SECTION cSection; /* Queue access critical section */
96 DWORD magic; /* magic number should be QUEUE_MAGIC */
97 DWORD lockCount; /* reference counter */
98 WORD wWinVersion; /* Expected Windows version */
100 WORD msgCount; /* Number of waiting messages */
101 QMSG* firstMsg; /* First message in linked list */
102 QMSG* lastMsg; /* Last message in linked list */
104 WORD wPostQMsg; /* PostQuitMessage flag */
105 WORD wExitCode; /* PostQuitMessage exit code */
106 WORD wPaintCount; /* Number of WM_PAINT needed */
107 WORD wTimerCount; /* Number of timers for this task */
109 WORD changeBits; /* Changed wake-up bits */
110 WORD wakeBits; /* Queue wake-up bits */
111 WORD wakeMask; /* Queue wake-up mask */
113 DWORD GetMessageTimeVal; /* Value for GetMessageTime */
114 DWORD GetMessagePosVal; /* Value for GetMessagePos */
115 DWORD GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
117 SMSG* smWaiting; /* SendMessage waiting for reply */
118 SMSG* smProcessing; /* SendMessage currently being processed */
119 SMSG* smPending; /* SendMessage waiting to be received */
121 HANDLE16 hCurHook; /* Current hook */
122 HANDLE16 hooks[WH_NB_HOOKS]; /* Task hooks list */
124 PERQUEUEDATA *pQData; /* pointer to (shared) PERQUEUEDATA structure */
126 } MESSAGEQUEUE;
129 /* Extra (undocumented) queue wake bits - see "Undoc. Windows" */
130 #define QS_SMRESULT 0x8000 /* Queue has a SendMessage() result */
132 /* Types of SMSG stack */
133 #define SM_PROCESSING_LIST 1 /* list of SM currently being processed */
134 #define SM_PENDING_LIST 2 /* list of SM wating to be received */
135 #define SM_WAITING_LIST 3 /* list of SM waiting for reply */
137 #define QUEUE_MAGIC 0xD46E80AF
139 /* Per queue data management methods */
140 PERQUEUEDATA* PERQDATA_CreateInstance( void );
141 ULONG PERQDATA_Addref( PERQUEUEDATA* pQData );
142 ULONG PERQDATA_Release( PERQUEUEDATA* pQData );
143 HWND PERQDATA_GetFocusWnd( PERQUEUEDATA *pQData );
144 HWND PERQDATA_SetFocusWnd( PERQUEUEDATA *pQData, HWND hWndFocus );
145 HWND PERQDATA_GetActiveWnd( PERQUEUEDATA *pQData );
146 HWND PERQDATA_SetActiveWnd( PERQUEUEDATA *pQData, HWND hWndActive );
147 HWND PERQDATA_GetCaptureWnd( PERQUEUEDATA *pQData );
148 HWND PERQDATA_SetCaptureWnd( PERQUEUEDATA *pQData, HWND hWndCapture );
149 INT16 PERQDATA_GetCaptureInfo( PERQUEUEDATA *pQData );
150 INT16 PERQDATA_SetCaptureInfo( PERQUEUEDATA *pQData, INT16 nCaptureHT );
152 /* Message queue management methods */
153 extern MESSAGEQUEUE *QUEUE_Lock( HQUEUE16 hQueue );
154 extern void QUEUE_Unlock( MESSAGEQUEUE *queue );
155 extern void QUEUE_DumpQueue( HQUEUE16 hQueue );
156 extern void QUEUE_WalkQueues(void);
157 extern BOOL QUEUE_IsExitingQueue( HQUEUE16 hQueue );
158 extern void QUEUE_SetExitingQueue( HQUEUE16 hQueue );
159 extern MESSAGEQUEUE *QUEUE_GetSysQueue(void);
160 extern void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit );
161 extern void QUEUE_ClearWakeBit( MESSAGEQUEUE *queue, WORD bit );
162 extern void QUEUE_ReceiveMessage( MESSAGEQUEUE *queue );
163 extern int QUEUE_WaitBits( WORD bits, DWORD timeout );
164 extern void QUEUE_IncPaintCount( HQUEUE16 hQueue );
165 extern void QUEUE_DecPaintCount( HQUEUE16 hQueue );
166 extern void QUEUE_IncTimerCount( HQUEUE16 hQueue );
167 extern void QUEUE_DecTimerCount( HQUEUE16 hQueue );
168 extern BOOL QUEUE_CreateSysMsgQueue( int size );
169 extern BOOL QUEUE_DeleteMsgQueue( HQUEUE16 hQueue );
170 extern HTASK16 QUEUE_GetQueueTask( HQUEUE16 hQueue );
171 extern BOOL QUEUE_AddMsg( HQUEUE16 hQueue, int type, MSG * msg, DWORD extraInfo );
172 extern QMSG* QUEUE_FindMsg( MESSAGEQUEUE * msgQueue, HWND hwnd,
173 int first, int last );
174 extern void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, QMSG *qmsg );
175 extern SMSG *QUEUE_RemoveSMSG( MESSAGEQUEUE *queue, int list, SMSG *smsg );
176 extern BOOL QUEUE_AddSMSG( MESSAGEQUEUE *queue, int list, SMSG *smsg );
177 extern void hardware_event( UINT message, WPARAM wParam, LPARAM lParam,
178 int xPos, int yPos, DWORD time, DWORD extraInfo );
180 extern HQUEUE16 WINAPI InitThreadInput16( WORD unknown, WORD flags );
182 #endif /* __WINE_QUEUE_H */