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
27 #include "wine/windef16.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
;
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.
99 * This is called from the context of a new thread, as soon as it
100 * has started to run.
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
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
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.
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
127 * USIG_PROCESS_DESTROY
128 * This is called after a process has terminated.
131 * The meaning of the dwFlags bits is as follows:
134 * Current process is 32-bit.
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).
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. */
156 /**********************************************************************
157 * SetLastErrorEx [USER32.@]
159 * Sets the last-error code.
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
);
175 /* Fall through for now */
177 FIXME("(error=%08x, type=%08x): Unhandled type\n", error
,type
);
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
);
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
);
201 /******************************************************************************
202 * SetDebugErrorLevel [USER32.@]
203 * Sets the minimum error level for generating debugging events
206 * dwLevel [I] Debugging error level
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
);
226 /***********************************************************************
227 * RegisterLogonProcess (USER32.@)
229 DWORD WINAPI
RegisterLogonProcess(HANDLE hprocess
,BOOL x
)
231 FIXME("(%p,%d),stub!\n",hprocess
,x
);
235 /***********************************************************************
236 * SetLogonNotifyWindow (USER32.@)
238 DWORD WINAPI
SetLogonNotifyWindow(HWINSTA hwinsta
,HWND hwnd
)
240 FIXME("(%p,%p),stub!\n",hwinsta
,hwnd
);
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
);
262 /***********************************************************************
263 * DeregisterShellHookWindow [USER32.@]
265 BOOL WINAPI
DeregisterShellHookWindow(HWND hWnd
)
267 FIXME("(%p): stub\n", hWnd
);
272 /***********************************************************************
273 * RegisterTasklist [USER32.@]
275 DWORD WINAPI
RegisterTasklist (DWORD x
)
281 /***********************************************************************
282 * GetAppCompatFlags (USER32.@)
284 DWORD WINAPI
GetAppCompatFlags( HTASK hTask
)
286 FIXME("(%p) stub\n", hTask
);
290 /***********************************************************************
291 * GetAppCompatFlags2 (USER32.@)
293 DWORD WINAPI
GetAppCompatFlags2( HTASK hTask
)
295 FIXME("(%p) stub\n", hTask
);
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
);
307 FIXME("rect: %s\n", wine_dbgstr_rect(rect
));
308 /* Calls OffsetRect */
313 /***********************************************************************
314 * LoadLocalFonts (USER32.@)
316 VOID WINAPI
LoadLocalFonts(VOID
)
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
)
335 if (imm_get_ui_window
)
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");
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
);
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
);
407 /**********************************************************************
408 * DisableProcessWindowsGhosting [USER32.@]
411 VOID WINAPI
DisableProcessWindowsGhosting(VOID
)
414 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
418 /**********************************************************************
419 * UserHandleGrantAccess [USER32.@]
422 BOOL WINAPI
UserHandleGrantAccess(HANDLE handle
, HANDLE job
, BOOL grant
)
424 FIXME("(%p,%p,%d): stub\n", handle
, job
, grant
);
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
);
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
);
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
);
466 /**********************************************************************
467 * IsTouchWindow [USER32.@]
469 BOOL WINAPI
IsTouchWindow( HWND hwnd
, PULONG flags
)
471 FIXME("(%p %p): stub\n", hwnd
, flags
);
475 /**********************************************************************
476 * IsWindowRedirectedForPrint [USER32.@]
478 BOOL WINAPI
IsWindowRedirectedForPrint( HWND hwnd
)
480 FIXME("(%p): stub\n", hwnd
);
484 /**********************************************************************
485 * RegisterPointerDeviceNotifications [USER32.@]
487 BOOL WINAPI
RegisterPointerDeviceNotifications(HWND hwnd
, BOOL notifyrange
)
489 FIXME("(%p %d): stub\n", hwnd
, notifyrange
);
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
);
510 /**********************************************************************
511 * RegisterTouchHitTestingWindow [USER32.@]
513 BOOL WINAPI
RegisterTouchHitTestingWindow(HWND hwnd
, ULONG value
)
515 FIXME("(%p %d): stub\n", hwnd
, value
);
519 /**********************************************************************
520 * GetPointerType [USER32.@]
522 BOOL WINAPI
GetPointerType(UINT32 id
, POINTER_INPUT_TYPE
*type
)
524 FIXME("(%d %p): stub\n", id
, type
);
528 SetLastError(ERROR_INVALID_PARAMETER
);
536 const struct builtin_class_descr IME_builtin_class
=
540 WINPROC_IME
, /* proc */
541 2*sizeof(LONG_PTR
), /* extra */
542 IDC_ARROW
, /* cursor */
546 static BOOL
is_ime_ui_msg( UINT msg
)
549 case WM_IME_STARTCOMPOSITION
:
550 case WM_IME_ENDCOMPOSITION
:
551 case WM_IME_COMPOSITION
:
552 case WM_IME_SETCONTEXT
:
555 case WM_IME_COMPOSITIONFULL
:
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
))
576 static LRESULT
ime_internal_msg( WPARAM wParam
, LPARAM lParam
)
578 HWND hwnd
= (HWND
)lParam
;
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
);
590 FIXME("wParam = %lx\n", wParam
);
597 LRESULT WINAPI
ImeWndProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
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
);
614 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
617 LRESULT WINAPI
ImeWndProcW( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
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
);
634 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);