Added unicode MDI client window proc.
[wine] / include / queue.h
1 /*
2  * Message queues definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  */
6
7 #ifndef __WINE_QUEUE_H
8 #define __WINE_QUEUE_H
9
10 #include "windef.h"
11 #include "winbase.h"
12 #include "wingdi.h"
13 #include "winuser.h"
14 #include "thread.h"
15
16
17   /* Message as stored in the queue (contains the extraInfo field) */
18 typedef struct tagQMSG
19 {
20     int   type;
21     MSG   msg;
22     DWORD extraInfo;  /* Only in 3.1 */
23     
24     struct tagQMSG *nextMsg;
25     struct tagQMSG *prevMsg;
26 } QMSG;
27
28 #define QMSG_WIN16    0
29 #define QMSG_WIN32A   1
30 #define QMSG_WIN32W   2
31 #define QMSG_HARDWARE 3
32
33
34 typedef struct tagSMSG
35 {
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 */
39     
40     HQUEUE16       hSrcQueue;       /* sending Queue, (NULL if it didn't wait) */
41     HQUEUE16       hDstQueue;       /* destination Queue */
42
43     HWND         hWnd;            /* destination window */
44     UINT         msg;             /* message sent */
45     WPARAM       wParam;          /* wParam of the sent message */
46     LPARAM         lParam;          /* lParam of the sent message */
47
48     LRESULT        lResult;         /* result of SendMessage */
49     WORD           flags;           /* see below SMSG_XXXX */
50 } SMSG;
51
52
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 unicode thread */
69 #define SMSG_UNICODE                0x2000
70
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
76  */
77 typedef struct tagPERQUEUEDATA      
78 {
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;
86
87 /* Message queue */
88 typedef struct tagMESSAGEQUEUE
89 {
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 */
95
96   DWORD     magic;                  /* magic number should be QUEUE_MAGIC */
97   DWORD     lockCount;              /* reference counter */
98   
99   WORD      msgCount;               /* Number of waiting messages */
100   QMSG*     firstMsg;               /* First message in linked list */
101   QMSG*     lastMsg;                /* Last message in linked list */
102   
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 */
107
108   WORD      changeBits;             /* Changed wake-up bits */
109   WORD      wakeBits;               /* Queue wake-up bits */
110   WORD      wakeMask;               /* Queue wake-up mask */
111
112   DWORD     GetMessageTimeVal;      /* Value for GetMessageTime */
113   DWORD     GetMessagePosVal;       /* Value for GetMessagePos */
114   DWORD     GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
115   
116   SMSG*     smWaiting;              /* SendMessage waiting for reply */
117   SMSG*     smProcessing;           /* SendMessage currently being processed */
118   SMSG*     smPending;              /* SendMessage waiting to be received */
119   
120   HANDLE16  hCurHook;               /* Current hook */
121   HANDLE16  hooks[WH_NB_HOOKS];     /* Task hooks list */
122
123   PERQUEUEDATA *pQData;             /* pointer to (shared) PERQUEUEDATA structure */
124   
125 } MESSAGEQUEUE;
126
127
128 /* Extra (undocumented) queue wake bits - see "Undoc. Windows" */
129 #define QS_SMRESULT      0x8000  /* Queue has a SendMessage() result */
130
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 */
135
136 #define QUEUE_MAGIC        0xD46E80AF
137
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 );
150     
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 WORD QUEUE_TestWakeBit( MESSAGEQUEUE *queue, WORD bit );
162 extern BOOL 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 );
179
180 extern HQUEUE16 WINAPI InitThreadInput16( WORD unknown, WORD flags );
181
182 #endif  /* __WINE_QUEUE_H */