[02/10] user: Create 32-bit cursor handles
[wine/hacks.git] / dlls / user32 / user_private.h
bloba8f2c0c03373735e44d0baf0ce129b111744bf1c
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/windef16.h"
32 #include "wine/winbase16.h"
34 extern WORD USER_HeapSel DECLSPEC_HIDDEN;
36 static inline HLOCAL16 LOCAL_Alloc( HANDLE16 ds, UINT16 flags, WORD size )
38 STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
39 HANDLE16 oldDS = stack16->ds;
40 HLOCAL16 ret;
42 stack16->ds = ds;
43 ret = LocalAlloc16 (flags, size);
44 stack16->ds = oldDS;
45 return ret;
48 static inline HLOCAL16 LOCAL_ReAlloc( HANDLE16 ds, HLOCAL16 handle, WORD size, UINT16 flags )
50 STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
51 HANDLE16 oldDS = stack16->ds;
52 HLOCAL16 ret;
54 stack16->ds = ds;
55 ret = LocalReAlloc16 (handle, size, flags);
56 stack16->ds = oldDS;
57 return ret;
60 static inline HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle )
62 STACK16FRAME* stack16 = MapSL(PtrToUlong(NtCurrentTeb()->WOW32Reserved));
63 HANDLE16 oldDS = stack16->ds;
64 HLOCAL16 ret;
66 stack16->ds = ds;
67 ret = LocalFree16 (handle);
68 stack16->ds = oldDS;
69 return ret;
72 #define USER_HEAP_ALLOC(size) \
73 ((HANDLE)(ULONG_PTR)LOCAL_Alloc( USER_HeapSel, LMEM_FIXED, (size) ))
74 #define USER_HEAP_REALLOC(handle,size) \
75 ((HANDLE)(ULONG_PTR)LOCAL_ReAlloc( USER_HeapSel, LOWORD(handle), (size), LMEM_FIXED ))
76 #define USER_HEAP_FREE(handle) \
77 LOCAL_Free( USER_HeapSel, LOWORD(handle) )
78 #define USER_HEAP_LIN_ADDR(handle) \
79 ((handle) ? MapSL(MAKESEGPTR(USER_HeapSel, LOWORD(handle))) : NULL)
81 #define GET_WORD(ptr) (*(const WORD *)(ptr))
82 #define GET_DWORD(ptr) (*(const DWORD *)(ptr))
84 #define WM_SYSTIMER 0x0118
85 #define WM_POPUPSYSTEMMENU 0x0313
87 /* internal messages codes */
88 enum wine_internal_message
90 WM_WINE_DESTROYWINDOW = 0x80000000,
91 WM_WINE_SETWINDOWPOS,
92 WM_WINE_SHOWWINDOW,
93 WM_WINE_SETPARENT,
94 WM_WINE_SETWINDOWLONG,
95 WM_WINE_ENABLEWINDOW,
96 WM_WINE_SETACTIVEWINDOW,
97 WM_WINE_KEYBOARD_LL_HOOK,
98 WM_WINE_MOUSE_LL_HOOK,
99 WM_WINE_FIRST_DRIVER_MSG = 0x80001000, /* range of messages reserved for the USER driver */
100 WM_WINE_LAST_DRIVER_MSG = 0x80001fff
103 struct tagCURSORICONINFO;
105 typedef struct tagUSER_DRIVER {
106 /* keyboard functions */
107 HKL (*pActivateKeyboardLayout)(HKL, UINT);
108 void (*pBeep)(void);
109 SHORT (*pGetAsyncKeyState)(INT);
110 INT (*pGetKeyNameText)(LONG, LPWSTR, INT);
111 HKL (*pGetKeyboardLayout)(DWORD);
112 UINT (*pGetKeyboardLayoutList)(INT, HKL *);
113 BOOL (*pGetKeyboardLayoutName)(LPWSTR);
114 HKL (*pLoadKeyboardLayout)(LPCWSTR, UINT);
115 UINT (*pMapVirtualKeyEx)(UINT, UINT, HKL);
116 UINT (*pSendInput)(UINT, LPINPUT, int);
117 INT (*pToUnicodeEx)(UINT, UINT, const BYTE *, LPWSTR, int, UINT, HKL);
118 BOOL (*pUnloadKeyboardLayout)(HKL);
119 SHORT (*pVkKeyScanEx)(WCHAR, HKL);
120 /* mouse functions */
121 void (*pSetCursor)(struct tagCURSORICONINFO *);
122 BOOL (*pGetCursorPos)(LPPOINT);
123 BOOL (*pSetCursorPos)(INT,INT);
124 BOOL (*pClipCursor)(LPCRECT);
125 /* screen saver functions */
126 BOOL (*pGetScreenSaveActive)(void);
127 void (*pSetScreenSaveActive)(BOOL);
128 /* clipboard functions */
129 INT (*pAcquireClipboard)(HWND); /* Acquire selection */
130 BOOL (*pCountClipboardFormats)(void); /* Count available clipboard formats */
131 void (*pEmptyClipboard)(BOOL); /* Empty clipboard data */
132 void (*pEndClipboardUpdate)(void); /* End clipboard update */
133 UINT (*pEnumClipboardFormats)(UINT); /* Enumerate clipboard formats */
134 BOOL (*pGetClipboardData)(UINT, HANDLE16*, HANDLE*); /* Get specified selection data */
135 INT (*pGetClipboardFormatName)(UINT, LPWSTR, UINT); /* Get a clipboard format name */
136 BOOL (*pIsClipboardFormatAvailable)(UINT); /* Check if specified format is available */
137 UINT (*pRegisterClipboardFormat)(LPCWSTR); /* Register a clipboard format */
138 BOOL (*pSetClipboardData)(UINT, HANDLE16, HANDLE, BOOL); /* Set specified selection data */
139 /* display modes */
140 LONG (*pChangeDisplaySettingsEx)(LPCWSTR,LPDEVMODEW,HWND,DWORD,LPVOID);
141 BOOL (*pEnumDisplayMonitors)(HDC,LPRECT,MONITORENUMPROC,LPARAM);
142 BOOL (*pEnumDisplaySettingsEx)(LPCWSTR,DWORD,LPDEVMODEW,DWORD);
143 BOOL (*pGetMonitorInfo)(HMONITOR,MONITORINFO*);
144 /* windowing functions */
145 BOOL (*pCreateDesktopWindow)(HWND);
146 BOOL (*pCreateWindow)(HWND);
147 void (*pDestroyWindow)(HWND);
148 void (*pGetDC)(HDC,HWND,HWND,const RECT *,const RECT *,DWORD);
149 DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD);
150 void (*pReleaseDC)(HWND,HDC);
151 BOOL (*pScrollDC)(HDC, INT, INT, const RECT *, const RECT *, HRGN, LPRECT);
152 void (*pSetCapture)(HWND,UINT);
153 void (*pSetFocus)(HWND);
154 void (*pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
155 void (*pSetParent)(HWND,HWND,HWND);
156 int (*pSetWindowRgn)(HWND,HRGN,BOOL);
157 void (*pSetWindowIcon)(HWND,UINT,HICON);
158 void (*pSetWindowStyle)(HWND,INT,STYLESTRUCT*);
159 void (*pSetWindowText)(HWND,LPCWSTR);
160 UINT (*pShowWindow)(HWND,INT,RECT*,UINT);
161 LRESULT (*pSysCommand)(HWND,WPARAM,LPARAM);
162 LRESULT (*pWindowMessage)(HWND,UINT,WPARAM,LPARAM);
163 void (*pWindowPosChanging)(HWND,HWND,UINT,const RECT *,const RECT *,RECT *);
164 void (*pWindowPosChanged)(HWND,HWND,UINT,const RECT *,const RECT *,const RECT *,const RECT *);
165 } USER_DRIVER;
167 extern const USER_DRIVER *USER_Driver DECLSPEC_HIDDEN;
169 extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
171 struct received_message_info;
172 struct hook16_queue_info;
174 /* type of message-sending functions that need special WM_CHAR handling */
175 enum wm_char_mapping
177 WMCHAR_MAP_POSTMESSAGE,
178 WMCHAR_MAP_SENDMESSAGE,
179 WMCHAR_MAP_SENDMESSAGETIMEOUT,
180 WMCHAR_MAP_RECVMESSAGE,
181 WMCHAR_MAP_DISPATCHMESSAGE,
182 WMCHAR_MAP_CALLWINDOWPROC,
183 WMCHAR_MAP_COUNT,
184 WMCHAR_MAP_NOMAPPING = WMCHAR_MAP_COUNT
187 /* data to store state for A/W mappings of WM_CHAR */
188 struct wm_char_mapping_data
190 BYTE lead_byte[WMCHAR_MAP_COUNT];
191 MSG get_msg;
194 /* this is the structure stored in TEB->Win32ClientInfo */
195 /* no attempt is made to keep the layout compatible with the Windows one */
196 struct user_thread_info
198 HANDLE server_queue; /* Handle to server-side queue */
199 DWORD recursion_count; /* SendMessage recursion counter */
200 BOOL hook_unicode; /* Is current hook unicode? */
201 HHOOK hook; /* Current hook */
202 struct received_message_info *receive_info; /* Message being currently received */
203 struct hook16_queue_info *hook16_info; /* Opaque pointer for 16-bit hook support */
204 struct wm_char_mapping_data *wmchar_data; /* Data for WM_CHAR mappings */
205 DWORD GetMessageTimeVal; /* Value for GetMessageTime */
206 DWORD GetMessagePosVal; /* Value for GetMessagePos */
207 ULONG_PTR GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
208 HCURSOR cursor; /* Current cursor */
209 INT cursor_count; /* Cursor show count */
210 UINT active_hooks; /* Bitmap of active hooks */
211 HWND top_window; /* Desktop window */
212 HWND msg_window; /* HWND_MESSAGE parent window */
214 ULONG pad[9]; /* Available for more data */
217 struct hook_extra_info
219 HHOOK handle;
220 LPARAM lparam;
223 static inline struct user_thread_info *get_user_thread_info(void)
225 return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
228 /* check if hwnd is a broadcast magic handle */
229 static inline BOOL is_broadcast( HWND hwnd )
231 return (hwnd == HWND_BROADCAST || hwnd == HWND_TOPMOST);
234 extern HMODULE user32_module DECLSPEC_HIDDEN;
235 extern DWORD USER16_AlertableWait DECLSPEC_HIDDEN;
236 extern HBRUSH SYSCOLOR_55AABrush DECLSPEC_HIDDEN;
238 struct dce;
240 extern BOOL CLIPBOARD_ReleaseOwner(void) DECLSPEC_HIDDEN;
241 extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN;
242 extern BOOL HOOK_IsHooked( INT id ) DECLSPEC_HIDDEN;
243 extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret );
244 extern void free_dce( struct dce *dce, HWND hwnd ) DECLSPEC_HIDDEN;
245 extern void invalidate_dce( HWND hwnd, const RECT *rect ) DECLSPEC_HIDDEN;
246 extern void erase_now( HWND hwnd, UINT rdw_flags ) DECLSPEC_HIDDEN;
247 extern void *get_hook_proc( void *proc, const WCHAR *module );
248 extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
249 extern BOOL map_wparam_AtoW( UINT message, WPARAM *wparam, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
250 extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
251 UINT msg, WPARAM wparam, LPARAM lparam,
252 UINT flags, UINT timeout, PDWORD_PTR res_ptr ) DECLSPEC_HIDDEN;
253 extern HPEN SYSCOLOR_GetPen( INT index ) DECLSPEC_HIDDEN;
254 extern void SYSPARAMS_Init(void) DECLSPEC_HIDDEN;
255 extern void USER_CheckNotLock(void) DECLSPEC_HIDDEN;
256 extern BOOL USER_IsExitingThread( DWORD tid ) DECLSPEC_HIDDEN;
258 extern BOOL USER_SetWindowPos( WINDOWPOS * winpos ) DECLSPEC_HIDDEN;
260 typedef LRESULT (*winproc_callback_t)( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp,
261 LRESULT *result, void *arg );
262 typedef LRESULT (*winproc_callback16_t)( HWND16 hwnd, UINT16 msg, WPARAM16 wp, LPARAM lp,
263 LRESULT *result, void *arg );
265 extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
266 extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func ) DECLSPEC_HIDDEN;
267 extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode ) DECLSPEC_HIDDEN;
268 extern WNDPROC WINPROC_AllocProc( WNDPROC funcA, WNDPROC funcW ) DECLSPEC_HIDDEN;
269 extern BOOL WINPROC_IsUnicode( WNDPROC proc, BOOL def_val ) DECLSPEC_HIDDEN;
271 extern LRESULT WINPROC_CallProcAtoW( winproc_callback_t callback, HWND hwnd, UINT msg,
272 WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg,
273 enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
274 extern LRESULT WINPROC_CallProc16To32A( winproc_callback_t callback, HWND16 hwnd, UINT16 msg,
275 WPARAM16 wParam, LPARAM lParam, LRESULT *result, void *arg ) DECLSPEC_HIDDEN;
276 extern LRESULT WINPROC_CallProc32ATo16( winproc_callback16_t callback, HWND hwnd, UINT msg,
277 WPARAM wParam, LPARAM lParam, LRESULT *result, void *arg ) DECLSPEC_HIDDEN;
279 extern INT_PTR WINPROC_CallDlgProc16( DLGPROC16 func, HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
280 extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
281 extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
282 extern BOOL WINPROC_call_window( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
283 LRESULT *result, BOOL unicode, enum wm_char_mapping mapping ) DECLSPEC_HIDDEN;
285 /* message spy definitions */
287 #define SPY_DISPATCHMESSAGE16 0x0100
288 #define SPY_DISPATCHMESSAGE 0x0101
289 #define SPY_SENDMESSAGE16 0x0102
290 #define SPY_SENDMESSAGE 0x0103
291 #define SPY_DEFWNDPROC16 0x0104
292 #define SPY_DEFWNDPROC 0x0105
294 #define SPY_RESULT_OK16 0x0000
295 #define SPY_RESULT_OK 0x0001
296 #define SPY_RESULT_INVALIDHWND16 0x0002
297 #define SPY_RESULT_INVALIDHWND 0x0003
298 #define SPY_RESULT_DEFWND16 0x0004
299 #define SPY_RESULT_DEFWND 0x0005
301 extern const char *SPY_GetClassLongOffsetName( INT offset ) DECLSPEC_HIDDEN;
302 extern const char *SPY_GetMsgName( UINT msg, HWND hWnd ) DECLSPEC_HIDDEN;
303 extern const char *SPY_GetVKeyName(WPARAM wParam) DECLSPEC_HIDDEN;
304 extern void SPY_EnterMessage( INT iFlag, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
305 extern void SPY_ExitMessage( INT iFlag, HWND hwnd, UINT msg,
306 LRESULT lReturn, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
307 extern int SPY_Init(void) DECLSPEC_HIDDEN;
309 /* HANDLE16 <-> HANDLE conversions */
310 HCURSOR16 get_cursor_handle16( HCURSOR cursor32 );
311 HCURSOR get_cursor_handle32( HCURSOR16 cursor16 );
313 #define HCURSOR_16(h32) get_cursor_handle16(h32)
314 #define HICON_16(h32) get_cursor_handle16(h32)
315 #define HINSTANCE_16(h32) (LOWORD(h32))
317 #define HCURSOR_32(h16) get_cursor_handle32(h16)
318 #define HICON_32(h16) get_cursor_handle32(h16)
319 #define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))
320 #define HMODULE_32(h16) ((HMODULE)(ULONG_PTR)(h16))
322 #include "pshpack1.h"
324 typedef struct
326 BYTE bWidth;
327 BYTE bHeight;
328 BYTE bColorCount;
329 BYTE bReserved;
330 } ICONRESDIR;
332 typedef struct
334 WORD wWidth;
335 WORD wHeight;
336 } CURSORDIR;
338 typedef struct
339 { union
340 { ICONRESDIR icon;
341 CURSORDIR cursor;
342 } ResInfo;
343 WORD wPlanes;
344 WORD wBitCount;
345 DWORD dwBytesInRes;
346 WORD wResId;
347 } CURSORICONDIRENTRY;
349 typedef struct
351 WORD idReserved;
352 WORD idType;
353 WORD idCount;
354 CURSORICONDIRENTRY idEntries[1];
355 } CURSORICONDIR;
357 #include "poppack.h"
359 extern void CURSORICON_FreeModuleIcons( HMODULE16 hModule ) DECLSPEC_HIDDEN;
361 #endif /* __WINE_USER_PRIVATE_H */