Fix the VarXxxFromCy conversions.
[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 /* Per-queue data for the message queue
35  * Note that we currently only store the current values for
36  * Active, Capture and Focus windows currently.
37  * It might be necessary to store a pointer to the system message queue
38  * as well since windows 9x maintains per thread system message queues
39  */
40 typedef struct tagPERQUEUEDATA      
41 {
42   HWND    hWndFocus;              /* Focus window */
43   HWND    hWndActive;             /* Active window */
44   HWND    hWndCapture;            /* Capture window */
45   INT16     nCaptureHT;             /* Capture info (hit-test) */
46   ULONG     ulRefCount;             /* Reference count */
47   CRITICAL_SECTION cSection;        /* Critical section for thread safe access */
48 } PERQUEUEDATA;
49
50 /* Message queue */
51 typedef struct tagMESSAGEQUEUE
52 {
53   HQUEUE16  self;                   /* Handle to self (was: reserved) */
54   TEB*      teb;                    /* Thread owning queue */
55   HANDLE    server_queue;           /* Handle to server-side queue */
56   CRITICAL_SECTION cSection;        /* Queue access critical section */
57
58   DWORD     magic;                  /* magic number should be QUEUE_MAGIC */
59   DWORD     lockCount;              /* reference counter */
60   
61   QMSG*     firstMsg;               /* First message in linked list */
62   QMSG*     lastMsg;                /* Last message in linked list */
63   
64   WORD      wPostQMsg;              /* PostQuitMessage flag */
65   WORD      wExitCode;              /* PostQuitMessage exit code */
66   WORD      wPaintCount;            /* Number of WM_PAINT needed */
67
68   DWORD     GetMessageTimeVal;      /* Value for GetMessageTime */
69   DWORD     GetMessagePosVal;       /* Value for GetMessagePos */
70   DWORD     GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
71
72   HANDLE16  hCurHook;               /* Current hook */
73   HANDLE16  hooks[WH_NB_HOOKS];     /* Task hooks list */
74
75   PERQUEUEDATA *pQData;             /* pointer to (shared) PERQUEUEDATA structure */
76   
77 } MESSAGEQUEUE;
78
79
80 #define QUEUE_MAGIC        0xD46E80AF
81
82 /* Per queue data management methods */
83 PERQUEUEDATA* PERQDATA_CreateInstance( void );
84 ULONG PERQDATA_Addref( PERQUEUEDATA* pQData );
85 ULONG PERQDATA_Release( PERQUEUEDATA* pQData );
86 HWND PERQDATA_GetFocusWnd( PERQUEUEDATA *pQData );
87 HWND PERQDATA_SetFocusWnd( PERQUEUEDATA *pQData, HWND hWndFocus );
88 HWND PERQDATA_GetActiveWnd( PERQUEUEDATA *pQData );
89 HWND PERQDATA_SetActiveWnd( PERQUEUEDATA *pQData, HWND hWndActive );
90 HWND PERQDATA_GetCaptureWnd( PERQUEUEDATA *pQData );
91 HWND PERQDATA_SetCaptureWnd( PERQUEUEDATA *pQData, HWND hWndCapture );
92 INT16  PERQDATA_GetCaptureInfo( PERQUEUEDATA *pQData );
93 INT16 PERQDATA_SetCaptureInfo( PERQUEUEDATA *pQData, INT16 nCaptureHT );
94     
95 /* Message queue management methods */
96 extern MESSAGEQUEUE *QUEUE_Lock( HQUEUE16 hQueue );
97 extern void QUEUE_Unlock( MESSAGEQUEUE *queue );
98 extern void QUEUE_DumpQueue( HQUEUE16 hQueue );
99 extern BOOL QUEUE_IsExitingQueue( HQUEUE16 hQueue );
100 extern void QUEUE_SetExitingQueue( HQUEUE16 hQueue );
101 extern MESSAGEQUEUE *QUEUE_GetSysQueue(void);
102 extern void QUEUE_SetWakeBit( MESSAGEQUEUE *queue, WORD set, WORD clear );
103 extern void QUEUE_ClearWakeBit( MESSAGEQUEUE *queue, WORD bit );
104 extern WORD QUEUE_TestWakeBit( MESSAGEQUEUE *queue, WORD bit );
105 extern int QUEUE_WaitBits( WORD bits, DWORD timeout );
106 extern void QUEUE_IncPaintCount( HQUEUE16 hQueue );
107 extern void QUEUE_DecPaintCount( HQUEUE16 hQueue );
108 extern BOOL QUEUE_CreateSysMsgQueue( int size );
109 extern BOOL QUEUE_DeleteMsgQueue( HQUEUE16 hQueue );
110 extern HTASK16 QUEUE_GetQueueTask( HQUEUE16 hQueue );
111 extern BOOL QUEUE_FindMsg( HWND hwnd, UINT first, UINT last, BOOL remove,
112                            BOOL sent_only, QMSG *msg );
113 extern void QUEUE_RemoveMsg( MESSAGEQUEUE * msgQueue, QMSG *qmsg );
114 extern void QUEUE_CleanupWindow( HWND hwnd );
115 extern void hardware_event( UINT message, WPARAM wParam, LPARAM lParam,
116                             int xPos, int yPos, DWORD time, DWORD extraInfo );
117
118 extern HQUEUE16 WINAPI InitThreadInput16( WORD unknown, WORD flags );
119
120 #endif  /* __WINE_QUEUE_H */