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