mfplat: Read queue subscriber within the critical section.
[wine/zf.git] / dlls / user32 / user_private.h
blob7761a1ceb4fa3d831936c1601ab3ff49744805fc
1 /*
2 * USER private definitions
4 * Copyright 1993 Alexandre Julliard
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.
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.
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
21 #ifndef __WINE_USER_PRIVATE_H
22 #define __WINE_USER_PRIVATE_H
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 #include "wine/heap.h"
33 #define GET_WORD(ptr) (*(const WORD *)(ptr))
34 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
35 #define GET_LONG(ptr) (*(const LONG *)(ptr))
37 #define WM_SYSTIMER 0x0118
38 #define WM_POPUPSYSTEMMENU 0x0313
40 #define WINE_MOUSE_HANDLE ((HANDLE)1)
41 #define WINE_KEYBOARD_HANDLE ((HANDLE)2)
43 struct window_surface;
45 /* internal messages codes */
46 enum wine_internal_message
48 WM_WINE_DESTROYWINDOW = 0x80000000,
49 WM_WINE_SETWINDOWPOS,
50 WM_WINE_SHOWWINDOW,
51 WM_WINE_SETPARENT,
52 WM_WINE_SETWINDOWLONG,
53 WM_WINE_SETSTYLE,
54 WM_WINE_SETACTIVEWINDOW,
55 WM_WINE_KEYBOARD_LL_HOOK,
56 WM_WINE_MOUSE_LL_HOOK,
57 WM_WINE_CLIPCURSOR,
58 WM_WINE_UPDATEWINDOWSTATE,
59 WM_WINE_FIRST_DRIVER_MSG = 0x80001000, /* range of messages reserved for the USER driver */
60 WM_WINE_LAST_DRIVER_MSG = 0x80001fff
63 typedef struct tagUSER_DRIVER {
64 /* keyboard functions */
65 HKL (CDECL *pActivateKeyboardLayout)(HKL, UINT);
66 void (CDECL *pBeep)(void);
67 INT (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT);
68 HKL (CDECL *pGetKeyboardLayout)(DWORD);
69 UINT (CDECL *pGetKeyboardLayoutList)(INT, HKL *);
70 BOOL (CDECL *pGetKeyboardLayoutName)(LPWSTR);
71 HKL (CDECL *pLoadKeyboardLayout)(LPCWSTR, UINT);
72 UINT (CDECL *pMapVirtualKeyEx)(UINT, UINT, HKL);
73 BOOL (CDECL *pRegisterHotKey)(HWND, UINT, UINT);
74 INT (CDECL *pToUnicodeEx)(UINT, UINT, const BYTE *, LPWSTR, int, UINT, HKL);
75 BOOL (CDECL *pUnloadKeyboardLayout)(HKL);
76 void (CDECL *pUnregisterHotKey)(HWND, UINT, UINT);
77 SHORT (CDECL *pVkKeyScanEx)(WCHAR, HKL);
78 /* cursor/icon functions */
79 void (CDECL *pDestroyCursorIcon)(HCURSOR);
80 void (CDECL *pSetCursor)(HCURSOR);
81 BOOL (CDECL *pGetCursorPos)(LPPOINT);
82 BOOL (CDECL *pSetCursorPos)(INT,INT);
83 BOOL (CDECL *pClipCursor)(LPCRECT);
84 /* clipboard functions */
85 void (CDECL *pUpdateClipboard)(void);
86 /* display modes */
87 LONG (CDECL *pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
88 BOOL (CDECL *pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
89 BOOL (CDECL *pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
90 BOOL (CDECL *pGetMonitorInfo)(HMONITOR,MONITORINFO*);
91 /* windowing functions */
92 BOOL (CDECL *pCreateDesktopWindow)(HWND);
93 BOOL (CDECL *pCreateWindow)(HWND);
94 void (CDECL *pDestroyWindow)(HWND);
95 void (CDECL *pFlashWindowEx)(FLASHWINFO*);
96 void (CDECL *pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD);
97 DWORD (CDECL *pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
98 void (CDECL *pReleaseDC)(HWND,HDC);
99 BOOL (CDECL *pScrollDC)(HDC,INT,INT,HRGN);
100 void (CDECL *pSetCapture)(HWND,UINT);
101 void (CDECL *pSetFocus)(HWND);
102 void (CDECL *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
103 void (CDECL *pSetParent)(HWND,HWND,HWND);
104 void (CDECL *pSetWindowRgn)(HWND,HRGN,BOOL);
105 void (CDECL *pSetWindowIcon)(HWND,UINT,HICON);
106 void (CDECL *pSetWindowStyle)(HWND,INT,STYLESTRUCT*);
107 void (CDECL *pSetWindowText)(HWND,LPCWSTR);
108 UINT (CDECL *pShowWindow)(HWND,INT,RECT*,UINT);
109 LRESULT (CDECL *pSysCommand)(HWND,WPARAM,LPARAM);
110 BOOL (CDECL *pUpdateLayeredWindow)(HWND,const UPDATELAYEREDWINDOWINFO *,const RECT *);
111 LRESULT (CDECL *pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
112 void (CDECL *pWindowPosChanging)(HWND,HWND,UINT,const RECT *,const RECT *,RECT *,struct window_surface**);
113 void (CDECL *pWindowPosChanged)(HWND,HWND,UINT,const RECT *,const RECT *,const RECT *,const RECT *,struct window_surface*);
114 /* system parameters */
115 BOOL (CDECL *pSystemParametersInfo)(UINT,UINT,void*,UINT);
116 /* thread management */
117 void (CDECL *pThreadDetach)(void);
118 } USER_DRIVER;
120 extern const USER_DRIVER *USER_Driver DECLSPEC_HIDDEN;
122 extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
124 extern BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ) DECLSPEC_HIDDEN;
125 extern BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, MONITORINFO *info ) DECLSPEC_HIDDEN;
127 struct received_message_info;
129 enum user_obj_type
131 USER_WINDOW = 1, /* window */
132 USER_MENU, /* menu */
133 USER_ACCEL, /* accelerator */
134 USER_ICON, /* icon or cursor */
135 USER_DWP /* DeferWindowPos structure */
138 struct user_object
140 HANDLE handle;
141 enum user_obj_type type;
144 #define OBJ_OTHER_PROCESS ((void *)1) /* returned by get_user_handle_ptr on unknown handles */
146 HANDLE alloc_user_handle( struct user_object *ptr, enum user_obj_type type ) DECLSPEC_HIDDEN;
147 void *get_user_handle_ptr( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
148 void release_user_handle_ptr( void *ptr ) DECLSPEC_HIDDEN;
149 void *free_user_handle( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
151 /* type of message-sending functions that need special WM_CHAR handling */
152 enum wm_char_mapping
154 WMCHAR_MAP_POSTMESSAGE,
155 WMCHAR_MAP_SENDMESSAGE,
156 WMCHAR_MAP_SENDMESSAGETIMEOUT,
157 WMCHAR_MAP_RECVMESSAGE,
158 WMCHAR_MAP_DISPATCHMESSAGE,
159 WMCHAR_MAP_CALLWINDOWPROC,
160 WMCHAR_MAP_COUNT,
161 WMCHAR_MAP_NOMAPPING = WMCHAR_MAP_COUNT
164 /* data to store state for A/W mappings of WM_CHAR */
165 struct wm_char_mapping_data
167 BYTE lead_byte[WMCHAR_MAP_COUNT];
168 MSG get_msg;
171 /* on windows the buffer capacity is quite large as well, enough to */
172 /* hold up to 10s of 1kHz mouse rawinput events */
173 #define RAWINPUT_BUFFER_SIZE (512*1024)
175 struct rawinput_thread_data
177 UINT hw_id; /* current rawinput message id */
178 RAWINPUT buffer[1]; /* rawinput message data buffer */
181 /* this is the structure stored in TEB->Win32ClientInfo */
182 /* no attempt is made to keep the layout compatible with the Windows one */
183 struct user_thread_info
185 HANDLE server_queue; /* Handle to server-side queue */
186 DWORD wake_mask; /* Current queue wake mask */
187 DWORD changed_mask; /* Current queue changed mask */
188 WORD recursion_count; /* SendMessage recursion counter */
189 WORD message_count; /* Get/PeekMessage loop counter */
190 WORD hook_call_depth; /* Number of recursively called hook procs */
191 WORD hook_unicode; /* Is current hook unicode? */
192 HHOOK hook; /* Current hook */
193 UINT active_hooks; /* Bitmap of active hooks */
194 DPI_AWARENESS dpi_awareness; /* DPI awareness */
195 INPUT_MESSAGE_SOURCE msg_source; /* Message source for current message */
196 struct received_message_info *receive_info; /* Message being currently received */
197 struct wm_char_mapping_data *wmchar_data; /* Data for WM_CHAR mappings */
198 DWORD GetMessageTimeVal; /* Value for GetMessageTime */
199 DWORD GetMessagePosVal; /* Value for GetMessagePos */
200 ULONG_PTR GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
201 struct user_key_state_info *key_state; /* Cache of global key state */
202 HWND top_window; /* Desktop window */
203 HWND msg_window; /* HWND_MESSAGE parent window */
204 struct rawinput_thread_data *rawinput; /* RawInput thread local data / buffer */
207 C_ASSERT( sizeof(struct user_thread_info) <= sizeof(((TEB *)0)->Win32ClientInfo) );
209 extern INT global_key_state_counter DECLSPEC_HIDDEN;
210 extern BOOL (WINAPI *imm_register_window)(HWND) DECLSPEC_HIDDEN;
211 extern void (WINAPI *imm_unregister_window)(HWND) DECLSPEC_HIDDEN;
213 struct user_key_state_info
215 UINT time; /* Time of last key state refresh */
216 INT counter; /* Counter to invalidate the key state */
217 BYTE state[256]; /* State for each key */
220 struct hook_extra_info
222 HHOOK handle;
223 LPARAM lparam;
226 static inline struct user_thread_info *get_user_thread_info(void)
228 return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
231 /* check if hwnd is a broadcast magic handle */
232 static inline BOOL is_broadcast( HWND hwnd )
234 return (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST);
237 extern HMODULE user32_module DECLSPEC_HIDDEN;
239 struct dce;
240 struct tagWND;
242 struct hardware_msg_data;
243 extern BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data);
244 extern struct rawinput_thread_data *rawinput_thread_data(void);
246 extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN;
247 extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN;
248 extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) DECLSPEC_HIDDEN;
249 extern void free_dce( struct dce *dce, HWND hwnd ) DECLSPEC_HIDDEN;
250 extern void invalidate_dce( struct tagWND *win, const RECT *rect ) DECLSPEC_HIDDEN;
251 extern HDC get_display_dc(void) DECLSPEC_HIDDEN;
252 extern void release_display_dc( HDC hdc ) DECLSPEC_HIDDEN;
253 extern void erase_now( HWND hwnd, UINT rdw_flags ) DECLSPEC_HIDDEN;
254 extern void move_window_bits( HWND hwnd, struct window_surface *old_surface,
255 struct window_surface *new_surface,
256 const RECT *visible_rect, const RECT *old_visible_rect,
257 const RECT *window_rect, const RECT *valid_rects ) DECLSPEC_HIDDEN;
258 extern void move_window_bits_parent( HWND hwnd, HWND parent, const RECT *window_rect,
259 const RECT *valid_rects ) DECLSPEC_HIDDEN;
260 extern void update_window_state( HWND hwnd ) DECLSPEC_HIDDEN;
261 extern void *get_hook_proc( void *proc, const WCHAR *module, HMODULE *free_module ) DECLSPEC_HIDDEN;
262 extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN;
263 extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
264 extern DWORD get_input_codepage( void ) DECLSPEC_HIDDEN;
265 extern BOOL map_wparam_AtoW( UINT message, WPARAM *wparam, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
266 extern NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags ) DECLSPEC_HIDDEN;
267 extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
268 UINT msg, WPARAM wparam, LPARAM lparam,
269 UINT flags, UINT timeout, PDWORD_PTR res_ptr ) DECLSPEC_HIDDEN;
270 extern HPEN SYSCOLOR_GetPen( INT index ) DECLSPEC_HIDDEN;
271 extern HBRUSH SYSCOLOR_Get55AABrush(void) DECLSPEC_HIDDEN;
272 extern void SYSPARAMS_Init(void) DECLSPEC_HIDDEN;
273 extern void USER_CheckNotLock(void) DECLSPEC_HIDDEN;
274 extern BOOL USER_IsExitingThread( DWORD tid ) DECLSPEC_HIDDEN;
276 extern BOOL USER_SetWindowPos( WINDOWPOS * winpos, int parent_x, int parent_y ) DECLSPEC_HIDDEN;
278 typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
279 LRESULT *result, void *arg );
281 extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
282 extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode ) DECLSPEC_HIDDEN;
283 extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val ) DECLSPEC_HIDDEN;
285 extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
286 WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg,
287 enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
289 extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
290 extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
291 extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
292 LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
294 extern const WCHAR *CLASS_GetVersionedName(const WCHAR *classname, UINT *basename_offset,
295 WCHAR *combined, BOOL register_class) DECLSPEC_HIDDEN;
297 /* message spy definitions */
299 #define SPY_DISPATCHMESSAGE 0x0100
300 #define SPY_SENDMESSAGE 0x0101
301 #define SPY_DEFWNDPROC 0x0102
303 #define SPY_RESULT_OK 0x0001
304 #define SPY_RESULT_DEFWND 0x0002
306 extern const char *SPY_GetClassLongOffsetName( INT offset ) DECLSPEC_HIDDEN;
307 extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ) DECLSPEC_HIDDEN;
308 extern const char *SPY_GetVKeyName(WPARAM wParam) DECLSPEC_HIDDEN;
309 extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
310 extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg,
311 LRESULT lReturn, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
313 #include "pshpack1.h"
315 typedef struct
317 BYTE bWidth;
318 BYTE bHeight;
319 BYTE bColorCount;
320 BYTE bReserved;
321 } ICONRESDIR;
323 typedef struct
325 WORD wWidth;
326 WORD wHeight;
327 } CURSORDIR;
329 typedef struct
330 { union
331 { ICONRESDIR icon;
332 CURSORDIR cursor;
333 } ResInfo;
334 WORD wPlanes;
335 WORD wBitCount;
336 DWORD dwBytesInRes;
337 WORD wResId;
338 } CURSORICONDIRENTRY;
340 typedef struct
342 WORD idReserved;
343 WORD idType;
344 WORD idCount;
345 CURSORICONDIRENTRY idEntries[1];
346 } CURSORICONDIR;
348 typedef struct {
349 BYTE bWidth;
350 BYTE bHeight;
351 BYTE bColorCount;
352 BYTE bReserved;
353 WORD xHotspot;
354 WORD yHotspot;
355 DWORD dwDIBSize;
356 DWORD dwDIBOffset;
357 } CURSORICONFILEDIRENTRY;
359 typedef struct
361 WORD idReserved;
362 WORD idType;
363 WORD idCount;
364 CURSORICONFILEDIRENTRY idEntries[1];
365 } CURSORICONFILEDIR;
367 #include "poppack.h"
369 extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
370 extern BOOL get_icon_size( HICON handle, SIZE *size ) DECLSPEC_HIDDEN;
372 struct png_funcs
374 BOOL (CDECL *get_png_info)(const void *png_data, DWORD size, int *width, int *height, int *bpp);
375 BITMAPINFO * (CDECL *load_png)(const char *png_data, DWORD *size);
378 /* Mingw's assert() imports MessageBoxA and gets confused by user32 exporting it */
379 #ifdef __MINGW32__
380 #undef assert
381 #define assert(expr) ((void)0)
382 #endif
384 static inline WCHAR *heap_strdupW(const WCHAR *src)
386 WCHAR *dst;
387 unsigned len;
388 if (!src) return NULL;
389 len = (lstrlenW(src) + 1) * sizeof(WCHAR);
390 if ((dst = heap_alloc(len))) memcpy(dst, src, len);
391 return dst;
394 #endif /* __WINE_USER_PRIVATE_H */