user32: Support returning to the process default in SetThreadDpiAwarenessContext().
[wine.git] / dlls / user32 / user_private.h
blob30ab511f57eeefbbdbbdd77c8b1ab9158991b872
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"
32 #define GET_WORD(ptr) (*(const WORD *)(ptr))
33 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
35 #define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
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_FIRST_DRIVER_MSG = 0x80001000, /* range of messages reserved for the USER driver */
59 WM_WINE_LAST_DRIVER_MSG = 0x80001fff
62 typedef struct tagUSER_DRIVER {
63 /* keyboard functions */
64 HKL (CDECL *pActivateKeyboardLayout)(HKL, UINT);
65 void (CDECL *pBeep)(void);
66 SHORT (CDECL *pGetAsyncKeyState)(INT);
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 struct received_message_info;
126 enum user_obj_type
128 USER_WINDOW = 1, /* window */
129 USER_MENU, /* menu */
130 USER_ACCEL, /* accelerator */
131 USER_ICON, /* icon or cursor */
132 USER_DWP /* DeferWindowPos structure */
135 struct user_object
137 HANDLE handle;
138 enum user_obj_type type;
141 #define OBJ_OTHER_PROCESS ((void *)1) /* returned by get_user_handle_ptr on unknown handles */
143 HANDLE alloc_user_handle( struct user_object *ptr, enum user_obj_type type ) DECLSPEC_HIDDEN;
144 void *get_user_handle_ptr( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
145 void release_user_handle_ptr( void *ptr ) DECLSPEC_HIDDEN;
146 void *free_user_handle( HANDLE handle, enum user_obj_type type ) DECLSPEC_HIDDEN;
148 /* type of message-sending functions that need special WM_CHAR handling */
149 enum wm_char_mapping
151 WMCHAR_MAP_POSTMESSAGE,
152 WMCHAR_MAP_SENDMESSAGE,
153 WMCHAR_MAP_SENDMESSAGETIMEOUT,
154 WMCHAR_MAP_RECVMESSAGE,
155 WMCHAR_MAP_DISPATCHMESSAGE,
156 WMCHAR_MAP_CALLWINDOWPROC,
157 WMCHAR_MAP_COUNT,
158 WMCHAR_MAP_NOMAPPING = WMCHAR_MAP_COUNT
161 /* data to store state for A/W mappings of WM_CHAR */
162 struct wm_char_mapping_data
164 BYTE lead_byte[WMCHAR_MAP_COUNT];
165 MSG get_msg;
168 /* this is the structure stored in TEB->Win32ClientInfo */
169 /* no attempt is made to keep the layout compatible with the Windows one */
170 struct user_thread_info
172 DPI_AWARENESS dpi_awareness; /* DPI awareness */
173 HANDLE server_queue; /* Handle to server-side queue */
174 DWORD wake_mask; /* Current queue wake mask */
175 DWORD changed_mask; /* Current queue changed mask */
176 WORD recursion_count; /* SendMessage recursion counter */
177 WORD message_count; /* Get/PeekMessage loop counter */
178 WORD hook_call_depth; /* Number of recursively called hook procs */
179 BOOL hook_unicode; /* Is current hook unicode? */
180 HHOOK hook; /* Current hook */
181 struct received_message_info *receive_info; /* Message being currently received */
182 struct wm_char_mapping_data *wmchar_data; /* Data for WM_CHAR mappings */
183 DWORD GetMessageTimeVal; /* Value for GetMessageTime */
184 DWORD GetMessagePosVal; /* Value for GetMessagePos */
185 ULONG_PTR GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
186 UINT active_hooks; /* Bitmap of active hooks */
187 struct user_key_state_info *key_state; /* Cache of global key state */
188 HWND top_window; /* Desktop window */
189 HWND msg_window; /* HWND_MESSAGE parent window */
190 RAWINPUT *rawinput;
193 C_ASSERT( sizeof(struct user_thread_info) <= sizeof(((TEB *)0)->Win32ClientInfo) );
195 extern INT global_key_state_counter DECLSPEC_HIDDEN;
196 extern BOOL (WINAPI *imm_register_window)(HWND) DECLSPEC_HIDDEN;
197 extern void (WINAPI *imm_unregister_window)(HWND) DECLSPEC_HIDDEN;
199 struct user_key_state_info
201 UINT time; /* Time of last key state refresh */
202 INT counter; /* Counter to invalidate the key state */
203 BYTE state[256]; /* State for each key */
206 struct hook_extra_info
208 HHOOK handle;
209 LPARAM lparam;
212 static inline struct user_thread_info *get_user_thread_info(void)
214 return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
217 /* check if hwnd is a broadcast magic handle */
218 static inline BOOL is_broadcast( HWND hwnd )
220 return (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST);
223 extern HMODULE user32_module DECLSPEC_HIDDEN;
225 struct dce;
226 struct tagWND;
228 extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN;
229 extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN;
230 extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) DECLSPEC_HIDDEN;
231 extern void free_dce( struct dce *dce, HWND hwnd ) DECLSPEC_HIDDEN;
232 extern void invalidate_dce( struct tagWND *win, const RECT *rect ) DECLSPEC_HIDDEN;
233 extern HDC get_display_dc(void) DECLSPEC_HIDDEN;
234 extern void release_display_dc( HDC hdc ) DECLSPEC_HIDDEN;
235 extern void erase_now( HWND hwnd, UINT rdw_flags ) DECLSPEC_HIDDEN;
236 extern void move_window_bits( HWND hwnd, struct window_surface *old_surface,
237 struct window_surface *new_surface,
238 const RECT *visible_rect, const RECT *old_visible_rect,
239 const RECT *window_rect, const RECT *valid_rects ) DECLSPEC_HIDDEN;
240 extern void move_window_bits_parent( HWND hwnd, HWND parent, const RECT *window_rect,
241 const RECT *valid_rects ) DECLSPEC_HIDDEN;
242 extern void *get_hook_proc( void *proc, const WCHAR *module, HMODULE *free_module ) DECLSPEC_HIDDEN;
243 extern RECT get_virtual_screen_rect(void) DECLSPEC_HIDDEN;
244 extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
245 extern DWORD get_input_codepage( void ) DECLSPEC_HIDDEN;
246 extern BOOL map_wparam_AtoW( UINT message, WPARAM *wparam, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
247 extern NTSTATUS send_hardware_message( HWND hwnd, const INPUT *input, UINT flags ) DECLSPEC_HIDDEN;
248 extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
249 UINT msg, WPARAM wparam, LPARAM lparam,
250 UINT flags, UINT timeout, PDWORD_PTR res_ptr ) DECLSPEC_HIDDEN;
251 extern HPEN SYSCOLOR_GetPen( INT index ) DECLSPEC_HIDDEN;
252 extern HBRUSH SYSCOLOR_Get55AABrush(void) DECLSPEC_HIDDEN;
253 extern void SYSPARAMS_Init(void) DECLSPEC_HIDDEN;
254 extern void USER_CheckNotLock(void) DECLSPEC_HIDDEN;
255 extern BOOL USER_IsExitingThread( DWORD tid ) DECLSPEC_HIDDEN;
257 extern BOOL USER_SetWindowPos( WINDOWPOS * winpos ) DECLSPEC_HIDDEN;
259 typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
260 LRESULT *result, void *arg );
262 extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
263 extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode ) DECLSPEC_HIDDEN;
264 extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val ) DECLSPEC_HIDDEN;
266 extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
267 WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg,
268 enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
270 extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
271 extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
272 extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
273 LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
275 extern const WCHAR *CLASS_GetVersionedName(const WCHAR *classname, UINT *basename_offset,
276 BOOL register_class) DECLSPEC_HIDDEN;
278 /* message spy definitions */
280 #define SPY_DISPATCHMESSAGE 0x0100
281 #define SPY_SENDMESSAGE 0x0101
282 #define SPY_DEFWNDPROC 0x0102
284 #define SPY_RESULT_OK 0x0001
285 #define SPY_RESULT_DEFWND 0x0002
287 extern const char *SPY_GetClassLongOffsetName( INT offset ) DECLSPEC_HIDDEN;
288 extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ) DECLSPEC_HIDDEN;
289 extern const char *SPY_GetVKeyName(WPARAM wParam) DECLSPEC_HIDDEN;
290 extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
291 extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg,
292 LRESULT lReturn, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
294 #include "pshpack1.h"
296 typedef struct
298 BYTE bWidth;
299 BYTE bHeight;
300 BYTE bColorCount;
301 BYTE bReserved;
302 } ICONRESDIR;
304 typedef struct
306 WORD wWidth;
307 WORD wHeight;
308 } CURSORDIR;
310 typedef struct
311 { union
312 { ICONRESDIR icon;
313 CURSORDIR cursor;
314 } ResInfo;
315 WORD wPlanes;
316 WORD wBitCount;
317 DWORD dwBytesInRes;
318 WORD wResId;
319 } CURSORICONDIRENTRY;
321 typedef struct
323 WORD idReserved;
324 WORD idType;
325 WORD idCount;
326 CURSORICONDIRENTRY idEntries[1];
327 } CURSORICONDIR;
329 typedef struct {
330 BYTE bWidth;
331 BYTE bHeight;
332 BYTE bColorCount;
333 BYTE bReserved;
334 WORD xHotspot;
335 WORD yHotspot;
336 DWORD dwDIBSize;
337 DWORD dwDIBOffset;
338 } CURSORICONFILEDIRENTRY;
340 typedef struct
342 WORD idReserved;
343 WORD idType;
344 WORD idCount;
345 CURSORICONFILEDIRENTRY idEntries[1];
346 } CURSORICONFILEDIR;
348 #include "poppack.h"
350 extern int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) DECLSPEC_HIDDEN;
351 extern BOOL get_icon_size( HICON handle, SIZE *size ) DECLSPEC_HIDDEN;
353 /* Mingw's assert() imports MessageBoxA and gets confused by user32 exporting it */
354 #ifdef __MINGW32__
355 #undef assert
356 #define assert(expr) ((void)0)
357 #endif
359 #endif /* __WINE_USER_PRIVATE_H */