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