user32: Release uniscribe data on Edit control destruction (valgrind).
[wine] / dlls / user32 / user_private.h
1 /*
2  * USER private definitions
3  *
4  * Copyright 1993 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_USER_PRIVATE_H
22 #define __WINE_USER_PRIVATE_H
23
24 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "winuser.h"
29 #include "winreg.h"
30 #include "winternl.h"
31
32 #define GET_WORD(ptr)  (*(const WORD *)(ptr))
33 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
34
35 #define WM_SYSTIMER         0x0118
36 #define WM_POPUPSYSTEMMENU  0x0313
37
38 /* internal messages codes */
39 enum wine_internal_message
40 {
41     WM_WINE_DESTROYWINDOW = 0x80000000,
42     WM_WINE_SETWINDOWPOS,
43     WM_WINE_SHOWWINDOW,
44     WM_WINE_SETPARENT,
45     WM_WINE_SETWINDOWLONG,
46     WM_WINE_ENABLEWINDOW,
47     WM_WINE_SETACTIVEWINDOW,
48     WM_WINE_KEYBOARD_LL_HOOK,
49     WM_WINE_MOUSE_LL_HOOK,
50     WM_WINE_CLIPCURSOR,
51     WM_WINE_FIRST_DRIVER_MSG = 0x80001000,  /* range of messages reserved for the USER driver */
52     WM_WINE_LAST_DRIVER_MSG = 0x80001fff
53 };
54
55 typedef struct tagUSER_DRIVER {
56     /* keyboard functions */
57     HKL    (CDECL *pActivateKeyboardLayout)(HKL, UINT);
58     void   (CDECL *pBeep)(void);
59     SHORT  (CDECL *pGetAsyncKeyState)(INT);
60     INT    (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT);
61     HKL    (CDECL *pGetKeyboardLayout)(DWORD);
62     BOOL   (CDECL *pGetKeyboardLayoutName)(LPWSTR);
63     HKL    (CDECL *pLoadKeyboardLayout)(LPCWSTR, UINT);
64     UINT   (CDECL *pMapVirtualKeyEx)(UINT, UINT, HKL);
65     BOOL   (CDECL *pRegisterHotKey)(HWND, UINT, UINT);
66     INT    (CDECL *pToUnicodeEx)(UINT, UINT, const BYTE *, LPWSTR, int, UINT, HKL);
67     BOOL   (CDECL *pUnloadKeyboardLayout)(HKL);
68     void   (CDECL *pUnregisterHotKey)(HWND, UINT, UINT);
69     SHORT  (CDECL *pVkKeyScanEx)(WCHAR, HKL);
70     /* cursor/icon functions */
71     void   (CDECL *pCreateCursorIcon)(HCURSOR);
72     void   (CDECL *pDestroyCursorIcon)(HCURSOR);
73     void   (CDECL *pSetCursor)(HCURSOR);
74     BOOL   (CDECL *pGetCursorPos)(LPPOINT);
75     BOOL   (CDECL *pSetCursorPos)(INT,INT);
76     BOOL   (CDECL *pClipCursor)(LPCRECT);
77     /* screen saver functions */
78     BOOL   (CDECL *pGetScreenSaveActive)(void);
79     void   (CDECL *pSetScreenSaveActive)(BOOL);
80     /* clipboard functions */
81     INT    (CDECL *pAcquireClipboard)(HWND);                     /* Acquire selection */
82     BOOL   (CDECL *pCountClipboardFormats)(void);                /* Count available clipboard formats */
83     void   (CDECL *pEmptyClipboard)(BOOL);                       /* Empty clipboard data */
84     void   (CDECL *pEndClipboardUpdate)(void);                   /* End clipboard update */
85     UINT   (CDECL *pEnumClipboardFormats)(UINT);                 /* Enumerate clipboard formats */
86     HANDLE (CDECL *pGetClipboardData)(UINT);                     /* Get specified selection data */
87     BOOL   (CDECL *pIsClipboardFormatAvailable)(UINT);           /* Check if specified format is available */
88     BOOL   (CDECL *pSetClipboardData)(UINT, HANDLE, BOOL);       /* Set specified selection data */
89     /* display modes */
90     LONG   (CDECL *pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
91     BOOL   (CDECL *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
92     BOOL   (CDECL *pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
93     BOOL   (CDECL *pGetMonitorInfo)(HMONITOR,MONITORINFO*);
94     /* windowing functions */
95     BOOL   (CDECL *pCreateDesktopWindow)(HWND);
96     BOOL   (CDECL *pCreateWindow)(HWND);
97     void   (CDECL *pDestroyWindow)(HWND);
98     void   (CDECL *pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD);
99     DWORD  (CDECL *pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
100     void   (CDECL *pReleaseDC)(HWND,HDC);
101     BOOL   (CDECL *pScrollDC)(HDC, INT, INT, const RECT *, const RECT *, HRGN, LPRECT);
102     void   (CDECL *pSetCapture)(HWND,UINT);
103     void   (CDECL *pSetFocus)(HWND);
104     void   (CDECL *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
105     void   (CDECL *pSetParent)(HWND,HWND,HWND);
106     int    (CDECL *pSetWindowRgn)(HWND,HRGN,BOOL);
107     void   (CDECL *pSetWindowIcon)(HWND,UINT,HICON);
108     void   (CDECL *pSetWindowStyle)(HWND,INT,STYLESTRUCT*);
109     void   (CDECL *pSetWindowText)(HWND,LPCWSTR);
110     UINT   (CDECL *pShowWindow)(HWND,INT,RECT*,UINT);
111     LRESULT (CDECL *pSysCommand)(HWND,WPARAM,LPARAM);
112     LRESULT (CDECL *pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
113     void   (CDECL *pWindowPosChanging)(HWND,HWND,UINT,const RECT *,const RECT *,RECT *);
114     void   (CDECL *pWindowPosChanged)(HWND,HWND,UINT,const RECT *,const RECT *,const RECT *,const RECT *);
115 } USER_DRIVER;
116
117 extern const USER_DRIVER *USER_Driver DECLSPEC_HIDDEN;
118
119 extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
120
121 struct received_message_info;
122
123 enum user_obj_type
124 {
125     USER_WINDOW = 1,  /* window */
126     USER_MENU,        /* menu */
127     USER_ACCEL,       /* accelerator */
128     USER_ICON,        /* icon or cursor */
129     USER_DWP          /* DeferWindowPos structure */
130 };
131
132 struct user_object
133 {
134     HANDLE             handle;
135     enum user_obj_type type;
136 };
137
138 #define OBJ_OTHER_PROCESS ((void *)1)  /* returned by get_user_handle_ptr on unknown handles */
139
140 HANDLE alloc_user_handle( struct user_object *ptr, enum user_obj_type type ) DECLSPEC_HIDDEN;
141 void *get_user_handle_ptr( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
142 void release_user_handle_ptr( void *ptr ) DECLSPEC_HIDDEN;
143 void *free_user_handle( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
144
145 /* type of message-sending functions that need special WM_CHAR handling */
146 enum wm_char_mapping
147 {
148     WMCHAR_MAP_POSTMESSAGE,
149     WMCHAR_MAP_SENDMESSAGE,
150     WMCHAR_MAP_SENDMESSAGETIMEOUT,
151     WMCHAR_MAP_RECVMESSAGE,
152     WMCHAR_MAP_DISPATCHMESSAGE,
153     WMCHAR_MAP_CALLWINDOWPROC,
154     WMCHAR_MAP_COUNT,
155     WMCHAR_MAP_NOMAPPING = WMCHAR_MAP_COUNT
156 };
157
158 /* data to store state for A/W mappings of WM_CHAR */
159 struct wm_char_mapping_data
160 {
161     BYTE lead_byte[WMCHAR_MAP_COUNT];
162     MSG  get_msg;
163 };
164
165 /* this is the structure stored in TEB->Win32ClientInfo */
166 /* no attempt is made to keep the layout compatible with the Windows one */
167 struct user_thread_info
168 {
169     HANDLE                        server_queue;           /* Handle to server-side queue */
170     DWORD                         recursion_count;        /* SendMessage recursion counter */
171     BOOL                          hook_unicode;           /* Is current hook unicode? */
172     HHOOK                         hook;                   /* Current hook */
173     struct received_message_info *receive_info;           /* Message being currently received */
174     struct wm_char_mapping_data  *wmchar_data;            /* Data for WM_CHAR mappings */
175     DWORD                         GetMessageTimeVal;      /* Value for GetMessageTime */
176     DWORD                         GetMessagePosVal;       /* Value for GetMessagePos */
177     ULONG_PTR                     GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
178     UINT                          active_hooks;           /* Bitmap of active hooks */
179     UINT                          key_state_time;         /* Time of last key state refresh */
180     BYTE                         *key_state;              /* Cache of global key state */
181     HWND                          top_window;             /* Desktop window */
182     HWND                          msg_window;             /* HWND_MESSAGE parent window */
183
184     ULONG                         pad[9];                 /* Available for more data */
185 };
186
187 struct hook_extra_info
188 {
189     HHOOK handle;
190     LPARAM lparam;
191 };
192
193 static inline struct user_thread_info *get_user_thread_info(void)
194 {
195     return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
196 }
197
198 /* check if hwnd is a broadcast magic handle */
199 static inline BOOL is_broadcast( HWND hwnd )
200 {
201     return (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST);
202 }
203
204 extern HMODULE user32_module DECLSPEC_HIDDEN;
205 extern HBRUSH SYSCOLOR_55AABrush DECLSPEC_HIDDEN;
206
207 struct dce;
208 struct tagWND;
209
210 extern BOOL CLIPBOARD_ReleaseOwner(void) DECLSPEC_HIDDEN;
211 extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN;
212 extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) DECLSPEC_HIDDEN;
213 extern void free_dce( struct dce *dce, HWND hwnd ) DECLSPEC_HIDDEN;
214 extern void invalidate_dce( struct tagWND *win, const RECT *rect ) DECLSPEC_HIDDEN;
215 extern void erase_now( HWND hwnd, UINT rdw_flags ) DECLSPEC_HIDDEN;
216 extern void *get_hook_proc( void *proc, const WCHAR *module ) DECLSPEC_HIDDEN;
217 extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
218 extern BOOL map_wparam_AtoW( UINT message, WPARAM *wparam, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
219 extern NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags ) DECLSPEC_HIDDEN;
220 extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
221                                                UINT msg, WPARAM wparam, LPARAM lparam,
222                                                UINT flags, UINT timeout, PDWORD_PTR res_ptr ) DECLSPEC_HIDDEN;
223 extern HPEN SYSCOLOR_GetPen( INT index ) DECLSPEC_HIDDEN;
224 extern void SYSPARAMS_Init(void) DECLSPEC_HIDDEN;
225 extern void USER_CheckNotLock(void) DECLSPEC_HIDDEN;
226 extern BOOL USER_IsExitingThread( DWORD tid ) DECLSPEC_HIDDEN;
227
228 extern BOOL USER_SetWindowPos( WINDOWPOS * winpos ) DECLSPEC_HIDDEN;
229
230 typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
231                                        LRESULT *result, void *arg );
232
233 extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
234 extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode ) DECLSPEC_HIDDEN;
235 extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val ) DECLSPEC_HIDDEN;
236
237 extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
238                                      WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg,
239                                      enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
240
241 extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
242 extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
243 extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
244                                  LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
245
246 /* message spy definitions */
247
248 #define SPY_DISPATCHMESSAGE       0x0100
249 #define SPY_SENDMESSAGE           0x0101
250 #define SPY_DEFWNDPROC            0x0102
251
252 #define SPY_RESULT_OK             0x0001
253 #define SPY_RESULT_DEFWND         0x0002
254
255 extern const char *SPY_GetClassLongOffsetName( INT offset ) DECLSPEC_HIDDEN;
256 extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ) DECLSPEC_HIDDEN;
257 extern const char *SPY_GetVKeyName(WPARAM wParam) DECLSPEC_HIDDEN;
258 extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
259 extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg,
260                              LRESULT lReturn, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
261 extern int SPY_Init(void) DECLSPEC_HIDDEN;
262
263 #include "pshpack1.h"
264
265 typedef struct
266 {
267     BYTE   bWidth;
268     BYTE   bHeight;
269     BYTE   bColorCount;
270     BYTE   bReserved;
271 } ICONRESDIR;
272
273 typedef struct
274 {
275     WORD   wWidth;
276     WORD   wHeight;
277 } CURSORDIR;
278
279 typedef struct
280 {   union
281     { ICONRESDIR icon;
282       CURSORDIR  cursor;
283     } ResInfo;
284     WORD   wPlanes;
285     WORD   wBitCount;
286     DWORD  dwBytesInRes;
287     WORD   wResId;
288 } CURSORICONDIRENTRY;
289
290 typedef struct
291 {
292     WORD                idReserved;
293     WORD                idType;
294     WORD                idCount;
295     CURSORICONDIRENTRY  idEntries[1];
296 } CURSORICONDIR;
297
298 #include "poppack.h"
299
300 extern BOOL get_icon_size( HICON handle, SIZE *size ) DECLSPEC_HIDDEN;
301
302 /* Mingw's assert() imports MessageBoxA and gets confused by user32 exporting it */
303 #ifdef __MINGW32__
304 #undef assert
305 #define assert(expr) ((void)0)
306 #endif
307
308 #endif /* __WINE_USER_PRIVATE_H */