d3d10: Return the read value from read_dword().
[wine.git] / dlls / user32 / misc.c
blob25d0b6766673becf8b365158a251ce1752597b7c
1 /*
2 * Misc USER functions
4 * Copyright 1995 Thomas Sandford
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Turchanov Sergey
7 * Copyright 2019 Micah N Gorrell for CodeWeavers
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "wine/windef16.h"
28 #include "winbase.h"
29 #include "wingdi.h"
30 #include "controls.h"
31 #include "imm.h"
32 #include "user_private.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(win);
38 BOOL WINAPI ImmSetActiveContext(HWND, HIMC, BOOL);
40 #define IMM_INIT_MAGIC 0x19650412
41 static HWND (WINAPI *imm_get_ui_window)(HKL);
42 BOOL (WINAPI *imm_register_window)(HWND) = NULL;
43 void (WINAPI *imm_unregister_window)(HWND) = NULL;
45 /* MSIME messages */
46 static UINT WM_MSIME_SERVICE;
47 static UINT WM_MSIME_RECONVERTOPTIONS;
48 static UINT WM_MSIME_MOUSE;
49 static UINT WM_MSIME_RECONVERTREQUEST;
50 static UINT WM_MSIME_RECONVERT;
51 static UINT WM_MSIME_QUERYPOSITION;
52 static UINT WM_MSIME_DOCUMENTFEED;
54 /* USER signal proc flags and codes */
55 /* See UserSignalProc for comments */
56 #define USIG_FLAGS_WIN32 0x0001
57 #define USIG_FLAGS_GUI 0x0002
58 #define USIG_FLAGS_FEEDBACK 0x0004
59 #define USIG_FLAGS_FAULT 0x0008
61 #define USIG_DLL_UNLOAD_WIN16 0x0001
62 #define USIG_DLL_UNLOAD_WIN32 0x0002
63 #define USIG_FAULT_DIALOG_PUSH 0x0003
64 #define USIG_FAULT_DIALOG_POP 0x0004
65 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
66 #define USIG_THREAD_INIT 0x0010
67 #define USIG_THREAD_EXIT 0x0020
68 #define USIG_PROCESS_CREATE 0x0100
69 #define USIG_PROCESS_INIT 0x0200
70 #define USIG_PROCESS_EXIT 0x0300
71 #define USIG_PROCESS_DESTROY 0x0400
72 #define USIG_PROCESS_RUNNING 0x0500
73 #define USIG_PROCESS_LOADED 0x0600
75 /***********************************************************************
76 * SignalProc32 (USER.391)
77 * UserSignalProc (USER32.@)
79 * The exact meaning of the USER signals is undocumented, but this
80 * should cover the basic idea:
82 * USIG_DLL_UNLOAD_WIN16
83 * This is sent when a 16-bit module is unloaded.
85 * USIG_DLL_UNLOAD_WIN32
86 * This is sent when a 32-bit module is unloaded.
88 * USIG_DLL_UNLOAD_ORPHANS
89 * This is sent after the last Win3.1 module is unloaded,
90 * to allow removal of orphaned menus.
92 * USIG_FAULT_DIALOG_PUSH
93 * USIG_FAULT_DIALOG_POP
94 * These are called to allow USER to prepare for displaying a
95 * fault dialog, even though the fault might have happened while
96 * inside a USER critical section.
98 * USIG_THREAD_INIT
99 * This is called from the context of a new thread, as soon as it
100 * has started to run.
102 * USIG_THREAD_EXIT
103 * This is called, still in its context, just before a thread is
104 * about to terminate.
106 * USIG_PROCESS_CREATE
107 * This is called, in the parent process context, after a new process
108 * has been created.
110 * USIG_PROCESS_INIT
111 * This is called in the new process context, just after the main thread
112 * has started execution (after the main thread's USIG_THREAD_INIT has
113 * been sent).
115 * USIG_PROCESS_LOADED
116 * This is called after the executable file has been loaded into the
117 * new process context.
119 * USIG_PROCESS_RUNNING
120 * This is called immediately before the main entry point is called.
122 * USIG_PROCESS_EXIT
123 * This is called in the context of a process that is about to
124 * terminate (but before the last thread's USIG_THREAD_EXIT has
125 * been sent).
127 * USIG_PROCESS_DESTROY
128 * This is called after a process has terminated.
131 * The meaning of the dwFlags bits is as follows:
133 * USIG_FLAGS_WIN32
134 * Current process is 32-bit.
136 * USIG_FLAGS_GUI
137 * Current process is a (Win32) GUI process.
139 * USIG_FLAGS_FEEDBACK
140 * Current process needs 'feedback' (determined from the STARTUPINFO
141 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
143 * USIG_FLAGS_FAULT
144 * The signal is being sent due to a fault.
146 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
147 DWORD dwFlags, HMODULE16 hModule )
149 FIXME("(%04x, %08x, %04x, %04x)\n",
150 uCode, dwThreadOrProcessID, dwFlags, hModule );
151 /* FIXME: Should chain to GdiSignalProc now. */
152 return 0;
156 /**********************************************************************
157 * SetLastErrorEx [USER32.@]
159 * Sets the last-error code.
161 * RETURNS
162 * None.
164 void WINAPI SetLastErrorEx(
165 DWORD error, /* [in] Per-thread error code */
166 DWORD type) /* [in] Error type */
168 TRACE("(0x%08x, 0x%08x)\n", error,type);
169 switch(type) {
170 case 0:
171 break;
172 case SLE_ERROR:
173 case SLE_MINORERROR:
174 case SLE_WARNING:
175 /* Fall through for now */
176 default:
177 FIXME("(error=%08x, type=%08x): Unhandled type\n", error,type);
178 break;
180 SetLastError( error );
183 /******************************************************************************
184 * GetAltTabInfoA [USER32.@]
186 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
188 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
189 return FALSE;
192 /******************************************************************************
193 * GetAltTabInfoW [USER32.@]
195 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
197 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
198 return FALSE;
201 /******************************************************************************
202 * SetDebugErrorLevel [USER32.@]
203 * Sets the minimum error level for generating debugging events
205 * PARAMS
206 * dwLevel [I] Debugging error level
208 * RETURNS
209 * Nothing.
211 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
213 FIXME("(%d): stub\n", dwLevel);
217 /***********************************************************************
218 * SetWindowStationUser (USER32.@)
220 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
222 FIXME("(0x%08x,0x%08x),stub!\n",x1,x2);
223 return 1;
226 /***********************************************************************
227 * RegisterLogonProcess (USER32.@)
229 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
231 FIXME("(%p,%d),stub!\n",hprocess,x);
232 return 1;
235 /***********************************************************************
236 * SetLogonNotifyWindow (USER32.@)
238 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
240 FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
241 return 1;
244 /***********************************************************************
245 * RegisterSystemThread (USER32.@)
247 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
249 FIXME("(%08x, %08x)\n", flags, reserved);
252 /***********************************************************************
253 * RegisterShellHookWindow [USER32.@]
255 BOOL WINAPI RegisterShellHookWindow(HWND hWnd)
257 FIXME("(%p): stub\n", hWnd);
258 return FALSE;
262 /***********************************************************************
263 * DeregisterShellHookWindow [USER32.@]
265 BOOL WINAPI DeregisterShellHookWindow(HWND hWnd)
267 FIXME("(%p): stub\n", hWnd);
268 return FALSE;
272 /***********************************************************************
273 * RegisterTasklist [USER32.@]
275 DWORD WINAPI RegisterTasklist (DWORD x)
277 FIXME("0x%08x\n",x);
278 return TRUE;
281 /***********************************************************************
282 * GetAppCompatFlags (USER32.@)
284 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
286 FIXME("(%p) stub\n", hTask);
287 return 0;
290 /***********************************************************************
291 * GetAppCompatFlags2 (USER32.@)
293 DWORD WINAPI GetAppCompatFlags2( HTASK hTask )
295 FIXME("(%p) stub\n", hTask);
296 return 0;
300 /***********************************************************************
301 * AlignRects (USER32.@)
303 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
305 FIXME("(%p, %d, %d, %d): stub\n", rect, b, c, d);
306 if (rect)
307 FIXME("rect: %s\n", wine_dbgstr_rect(rect));
308 /* Calls OffsetRect */
309 return FALSE;
313 /***********************************************************************
314 * LoadLocalFonts (USER32.@)
316 VOID WINAPI LoadLocalFonts(VOID)
318 /* are loaded. */
319 return;
323 /***********************************************************************
324 * User32InitializeImmEntryTable
326 BOOL WINAPI User32InitializeImmEntryTable(DWORD magic)
328 HMODULE imm32 = GetModuleHandleW(L"imm32.dll");
330 TRACE("(%x)\n", magic);
332 if (!imm32 || magic != IMM_INIT_MAGIC)
333 return FALSE;
335 if (imm_get_ui_window)
336 return TRUE;
338 WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
339 WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
340 WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
341 WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
342 WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
343 WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
344 WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
346 /* this part is not compatible with native imm32.dll */
347 imm_get_ui_window = (void*)GetProcAddress(imm32, "__wine_get_ui_window");
348 imm_register_window = (void*)GetProcAddress(imm32, "__wine_register_window");
349 imm_unregister_window = (void*)GetProcAddress(imm32, "__wine_unregister_window");
350 if (!imm_get_ui_window)
351 FIXME("native imm32.dll not supported\n");
352 return TRUE;
355 /**********************************************************************
356 * WINNLSGetIMEHotkey [USER32.@]
359 UINT WINAPI WINNLSGetIMEHotkey(HWND hwnd)
361 FIXME("hwnd %p: stub!\n", hwnd);
362 return 0; /* unknown */
365 /**********************************************************************
366 * WINNLSEnableIME [USER32.@]
369 BOOL WINAPI WINNLSEnableIME(HWND hwnd, BOOL enable)
371 FIXME("hwnd %p enable %d: stub!\n", hwnd, enable);
372 return TRUE; /* success (?) */
375 /**********************************************************************
376 * WINNLSGetEnableStatus [USER32.@]
379 BOOL WINAPI WINNLSGetEnableStatus(HWND hwnd)
381 FIXME("hwnd %p: stub!\n", hwnd);
382 return TRUE; /* success (?) */
385 /**********************************************************************
386 * SendIMEMessageExA [USER32.@]
389 LRESULT WINAPI SendIMEMessageExA(HWND hwnd, LPARAM lparam)
391 FIXME("(%p,%lx): stub\n", hwnd, lparam);
392 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
393 return 0;
396 /**********************************************************************
397 * SendIMEMessageExW [USER32.@]
400 LRESULT WINAPI SendIMEMessageExW(HWND hwnd, LPARAM lparam)
402 FIXME("(%p,%lx): stub\n", hwnd, lparam);
403 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
404 return 0;
407 /**********************************************************************
408 * DisableProcessWindowsGhosting [USER32.@]
411 VOID WINAPI DisableProcessWindowsGhosting(VOID)
413 FIXME(": stub\n");
414 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
415 return;
418 /**********************************************************************
419 * UserHandleGrantAccess [USER32.@]
422 BOOL WINAPI UserHandleGrantAccess(HANDLE handle, HANDLE job, BOOL grant)
424 FIXME("(%p,%p,%d): stub\n", handle, job, grant);
425 return TRUE;
428 /**********************************************************************
429 * RegisterPowerSettingNotification [USER32.@]
431 HPOWERNOTIFY WINAPI RegisterPowerSettingNotification(HANDLE recipient, const GUID *guid, DWORD flags)
433 FIXME("(%p,%s,%x): stub\n", recipient, debugstr_guid(guid), flags);
434 return (HPOWERNOTIFY)0xdeadbeef;
437 /**********************************************************************
438 * UnregisterPowerSettingNotification [USER32.@]
440 BOOL WINAPI UnregisterPowerSettingNotification(HPOWERNOTIFY handle)
442 FIXME("(%p): stub\n", handle);
443 return TRUE;
446 /*****************************************************************************
447 * GetGestureConfig (USER32.@)
449 BOOL WINAPI GetGestureConfig( HWND hwnd, DWORD reserved, DWORD flags, UINT *count, GESTURECONFIG *config, UINT size )
451 FIXME("(%p %08x %08x %p %p %u): stub\n", hwnd, reserved, flags, count, config, size);
452 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
453 return FALSE;
456 /**********************************************************************
457 * SetGestureConfig [USER32.@]
459 BOOL WINAPI SetGestureConfig( HWND hwnd, DWORD reserved, UINT id, PGESTURECONFIG config, UINT size )
461 FIXME("(%p %08x %u %p %u): stub\n", hwnd, reserved, id, config, size);
462 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
463 return FALSE;
466 /**********************************************************************
467 * IsTouchWindow [USER32.@]
469 BOOL WINAPI IsTouchWindow( HWND hwnd, PULONG flags )
471 FIXME("(%p %p): stub\n", hwnd, flags);
472 return FALSE;
475 /**********************************************************************
476 * IsWindowRedirectedForPrint [USER32.@]
478 BOOL WINAPI IsWindowRedirectedForPrint( HWND hwnd )
480 FIXME("(%p): stub\n", hwnd);
481 return FALSE;
484 /**********************************************************************
485 * RegisterPointerDeviceNotifications [USER32.@]
487 BOOL WINAPI RegisterPointerDeviceNotifications(HWND hwnd, BOOL notifyrange)
489 FIXME("(%p %d): stub\n", hwnd, notifyrange);
490 return TRUE;
493 /**********************************************************************
494 * GetPointerDevices [USER32.@]
496 BOOL WINAPI GetPointerDevices(UINT32 *device_count, POINTER_DEVICE_INFO *devices)
498 FIXME("(%p %p): partial stub\n", device_count, devices);
500 if (!device_count)
501 return FALSE;
503 if (devices)
504 return FALSE;
506 *device_count = 0;
507 return TRUE;
510 /**********************************************************************
511 * RegisterTouchHitTestingWindow [USER32.@]
513 BOOL WINAPI RegisterTouchHitTestingWindow(HWND hwnd, ULONG value)
515 FIXME("(%p %d): stub\n", hwnd, value);
516 return TRUE;
519 /**********************************************************************
520 * GetPointerType [USER32.@]
522 BOOL WINAPI GetPointerType(UINT32 id, POINTER_INPUT_TYPE *type)
524 FIXME("(%d %p): stub\n", id, type);
526 if(!id || !type)
528 SetLastError(ERROR_INVALID_PARAMETER);
529 return FALSE;
532 *type = PT_MOUSE;
533 return TRUE;
536 const struct builtin_class_descr IME_builtin_class =
538 L"IME", /* name */
539 0, /* style */
540 WINPROC_IME, /* proc */
541 2*sizeof(LONG_PTR), /* extra */
542 IDC_ARROW, /* cursor */
543 0 /* brush */
546 static BOOL is_ime_ui_msg( UINT msg )
548 switch(msg) {
549 case WM_IME_STARTCOMPOSITION:
550 case WM_IME_ENDCOMPOSITION:
551 case WM_IME_COMPOSITION:
552 case WM_IME_SETCONTEXT:
553 case WM_IME_NOTIFY:
554 case WM_IME_CONTROL:
555 case WM_IME_COMPOSITIONFULL:
556 case WM_IME_SELECT:
557 case WM_IME_CHAR:
558 case WM_IME_REQUEST:
559 case WM_IME_KEYDOWN:
560 case WM_IME_KEYUP:
561 return TRUE;
562 default:
563 if ((msg == WM_MSIME_RECONVERTOPTIONS) ||
564 (msg == WM_MSIME_SERVICE) ||
565 (msg == WM_MSIME_MOUSE) ||
566 (msg == WM_MSIME_RECONVERTREQUEST) ||
567 (msg == WM_MSIME_RECONVERT) ||
568 (msg == WM_MSIME_QUERYPOSITION) ||
569 (msg == WM_MSIME_DOCUMENTFEED))
570 return TRUE;
572 return FALSE;
576 static LRESULT ime_internal_msg( WPARAM wParam, LPARAM lParam)
578 HWND hwnd = (HWND)lParam;
579 HIMC himc;
581 switch(wParam)
583 case IME_INTERNAL_ACTIVATE:
584 case IME_INTERNAL_DEACTIVATE:
585 himc = ImmGetContext(hwnd);
586 ImmSetActiveContext(hwnd, himc, wParam == IME_INTERNAL_ACTIVATE);
587 ImmReleaseContext(hwnd, himc);
588 break;
589 default:
590 FIXME("wParam = %lx\n", wParam);
591 break;
594 return 0;
597 LRESULT WINAPI ImeWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
599 HWND uiwnd;
601 if (msg==WM_CREATE)
602 return TRUE;
604 if (msg==WM_IME_INTERNAL)
605 return ime_internal_msg(wParam, lParam);
607 if (imm_get_ui_window && is_ime_ui_msg(msg))
609 if ((uiwnd = imm_get_ui_window( NtUserGetKeyboardLayout(0) )))
610 return SendMessageA(uiwnd, msg, wParam, lParam);
611 return FALSE;
614 return DefWindowProcA(hwnd, msg, wParam, lParam);
617 LRESULT WINAPI ImeWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
619 HWND uiwnd;
621 if (msg==WM_CREATE)
622 return TRUE;
624 if (msg==WM_IME_INTERNAL)
625 return ime_internal_msg(wParam, lParam);
627 if (imm_get_ui_window && is_ime_ui_msg(msg))
629 if ((uiwnd = imm_get_ui_window( NtUserGetKeyboardLayout(0) )))
630 return SendMessageW(uiwnd, msg, wParam, lParam);
631 return FALSE;
634 return DefWindowProcW(hwnd, msg, wParam, lParam);