-Fixed MESSAGE functions that were thunking down to 16 bits implementation.
[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 "wine/winuser16.h"
11 #include "windows.h"
12 #include "thread.h"
13
14
15   /* Message as stored in the queue (contains the extraInfo field) */
16 typedef struct tagQMSG
17 {
18     MSG32   msg;
19     DWORD   extraInfo;  /* Only in 3.1 */
20     
21     struct tagQMSG *nextMsg;
22     struct tagQMSG *prevMsg;
23 } QMSG;
24
25 typedef struct
26 {
27   LRESULT   lResult;
28   BOOL16    bPending;
29 } QSMCTRL;
30
31 /* Per-queue data for the message queue
32  * Note that we currently only store the current values for
33  * Active, Capture and Focus windows currently.
34  * It might be necessary to store a pointer to the system message queue
35  * as well since windows 9x maintains per thread system message queues
36  */
37 typedef struct tagPERQUEUEDATA      
38 {
39   HWND32    hWndFocus;              /* Focus window */
40   HWND32    hWndActive;             /* Active window */
41   HWND32    hWndCapture;            /* Capture window */
42   INT16     nCaptureHT;             /* Capture info (hit-test) */
43   ULONG     ulRefCount;             /* Reference count */
44   CRITICAL_SECTION cSection;        /* Critical section for thread safe access */
45 } PERQUEUEDATA;
46
47 /* Message queue */
48 typedef struct tagMESSAGEQUEUE
49 {
50   HQUEUE16  next;                   /* Next queue */
51   HQUEUE16  self;                   /* Handle to self (was: reserved) */
52   THDB*     thdb;                   /* Thread owning queue */
53   HANDLE32  hEvent;                 /* Event handle */
54   CRITICAL_SECTION cSection;        /* Queue access critical section */
55
56   DWORD     magic;                  /* magic number should be QUEUE_MAGIC */
57   DWORD     lockCount;              /* reference counter */
58   
59   WORD      flags;                  /* Queue flags */
60   WORD      wWinVersion;            /* Expected Windows version */
61   
62   WORD      msgCount;               /* Number of waiting messages */
63   QMSG*     firstMsg;               /* First message in linked list */
64   QMSG*     lastMsg;                /* Last message in linked list */
65   
66   WORD      wPostQMsg;              /* PostQuitMessage flag */
67   WORD      wExitCode;              /* PostQuitMessage exit code */
68   WORD      wPaintCount;            /* Number of WM_PAINT needed */
69   WORD      wTimerCount;            /* Number of timers for this task */
70
71   WORD      changeBits;             /* Changed wake-up bits */
72   WORD      wakeBits;               /* Queue wake-up bits */
73   WORD      wakeMask;               /* Queue wake-up mask */
74
75   DWORD     GetMessageTimeVal;      /* Value for GetMessageTime */
76   DWORD     GetMessagePosVal;       /* Value for GetMessagePos */
77   DWORD     GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
78   
79   HQUEUE16  InSendMessageHandle;    /* Queue of task that sent a message */
80   HTASK16   hSendingTask;           /* Handle of task that sent a message */
81   HTASK16   hPrevSendingTask;       /* Handle of previous sender */
82   
83   HWND32    hWnd32;                 /* Send message arguments */
84   UINT32    msg32;                  
85   WPARAM32  wParam32;               
86   LPARAM    lParam;                 
87   DWORD     SendMessageReturn;      /* Return value for SendMessage */
88
89   QSMCTRL*  smResultInit;           /* SendMesage result pointers */
90   QSMCTRL*  smResultCurrent;        
91   QSMCTRL*  smResult;               
92   
93   HANDLE16  hCurHook;               /* Current hook */
94   HANDLE16  hooks[WH_NB_HOOKS];     /* Task hooks list */
95
96   PERQUEUEDATA *pQData;             /* pointer to (shared) PERQUEUEDATA structure */
97   
98 } MESSAGEQUEUE;
99
100
101 /* Extra (undocumented) queue wake bits - see "Undoc. Windows" */
102 #define QS_SMRESULT      0x8000  /* Queue has a SendMessage() result */
103 #define QS_SMPARAMSFREE  0x4000  /* SendMessage() parameters are available */
104
105 /* Queue flags */
106 #define QUEUE_SM_WIN32     0x0002  /* Currently sent message is Win32 */
107 #define QUEUE_SM_UNICODE   0x0004  /* Currently sent message is Unicode */
108
109 #define QUEUE_MAGIC        0xD46E80AF
110
111 /* Per queue data management methods */
112 PERQUEUEDATA* PERQDATA_CreateInstance( );
113 ULONG PERQDATA_Addref( PERQUEUEDATA* pQData );
114 ULONG PERQDATA_Release( PERQUEUEDATA* pQData );
115 HWND32 PERQDATA_GetFocusWnd( PERQUEUEDATA *pQData );
116 HWND32 PERQDATA_SetFocusWnd( PERQUEUEDATA *pQData, HWND32 hWndFocus );
117 HWND32 PERQDATA_GetActiveWnd( PERQUEUEDATA *pQData );
118 HWND32 PERQDATA_SetActiveWnd( PERQUEUEDATA *pQData, HWND32 hWndActive );
119 HWND32 PERQDATA_GetCaptureWnd( PERQUEUEDATA *pQData );
120 HWND32 PERQDATA_SetCaptureWnd( PERQUEUEDATA *pQData, HWND32 hWndCapture );
121 INT16  PERQDATA_GetCaptureInfo( PERQUEUEDATA *pQData );
122 INT16 PERQDATA_SetCaptureInfo( PERQUEUEDATA *pQData, INT16 nCaptureHT );
123     
124 /* Message queue management methods */
125 extern MESSAGEQUEUE *QUEUE_Lock( HQUEUE16 hQueue );
126 extern void QUEUE_Unlock( MESSAGEQUEUE *queue );
127 extern void QUEUE_DumpQueue( HQUEUE16 hQueue );
128 extern void QUEUE_WalkQueues(void);
129 extern BOOL32 QUEUE_IsExitingQueue( HQUEUE16 hQueue );
130 extern void QUEUE_SetExitingQueue( HQUEUE16 hQueue );
131 extern MESSAGEQUEUE *QUEUE_GetSysQueue(void);
132 extern void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD bit );
133 extern void QUEUE_ClearWakeBit( MESSAGEQUEUE *queue, WORD bit );
134 extern void QUEUE_ReceiveMessage( MESSAGEQUEUE *queue );
135 extern void QUEUE_WaitBits( WORD bits );
136 extern void QUEUE_IncPaintCount( HQUEUE16 hQueue );
137 extern void QUEUE_DecPaintCount( HQUEUE16 hQueue );
138 extern void QUEUE_IncTimerCount( HQUEUE16 hQueue );
139 extern void QUEUE_DecTimerCount( HQUEUE16 hQueue );
140 extern BOOL32 QUEUE_CreateSysMsgQueue( int size );
141 extern BOOL32 QUEUE_DeleteMsgQueue( HQUEUE16 hQueue );
142 extern HTASK16 QUEUE_GetQueueTask( HQUEUE16 hQueue );
143 extern BOOL32 QUEUE_AddMsg( HQUEUE16 hQueue, MSG32 * msg, DWORD extraInfo );
144 extern QMSG* QUEUE_FindMsg( MESSAGEQUEUE * msgQueue, HWND32 hwnd,
145                           int first, int last );
146 extern void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, QMSG *qmsg );
147 extern void QUEUE_FlushMessages(HQUEUE16);
148 extern void hardware_event( WORD message, WORD wParam, LONG lParam,
149                             int xPos, int yPos, DWORD time, DWORD extraInfo );
150
151 extern HQUEUE16 WINAPI InitThreadInput( WORD unknown, WORD flags );
152
153 #endif  /* __WINE_QUEUE_H */