4 * Copyright 1995 Thomas Sandford
5 * Copyright 1997 Marcus Meissner
6 * Copyright 1998 Turchanov Sergey
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/windef16.h"
32 #include "user_private.h"
34 #include "wine/unicode.h"
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(win
);
39 #define IMM_INIT_MAGIC 0x19650412
40 static HWND (WINAPI
*imm_get_ui_window
)(HKL
);
41 BOOL (WINAPI
*imm_register_window
)(HWND
) = NULL
;
42 void (WINAPI
*imm_unregister_window
)(HWND
) = NULL
;
45 static UINT WM_MSIME_SERVICE
;
46 static UINT WM_MSIME_RECONVERTOPTIONS
;
47 static UINT WM_MSIME_MOUSE
;
48 static UINT WM_MSIME_RECONVERTREQUEST
;
49 static UINT WM_MSIME_RECONVERT
;
50 static UINT WM_MSIME_QUERYPOSITION
;
51 static UINT WM_MSIME_DOCUMENTFEED
;
53 /* USER signal proc flags and codes */
54 /* See UserSignalProc for comments */
55 #define USIG_FLAGS_WIN32 0x0001
56 #define USIG_FLAGS_GUI 0x0002
57 #define USIG_FLAGS_FEEDBACK 0x0004
58 #define USIG_FLAGS_FAULT 0x0008
60 #define USIG_DLL_UNLOAD_WIN16 0x0001
61 #define USIG_DLL_UNLOAD_WIN32 0x0002
62 #define USIG_FAULT_DIALOG_PUSH 0x0003
63 #define USIG_FAULT_DIALOG_POP 0x0004
64 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
65 #define USIG_THREAD_INIT 0x0010
66 #define USIG_THREAD_EXIT 0x0020
67 #define USIG_PROCESS_CREATE 0x0100
68 #define USIG_PROCESS_INIT 0x0200
69 #define USIG_PROCESS_EXIT 0x0300
70 #define USIG_PROCESS_DESTROY 0x0400
71 #define USIG_PROCESS_RUNNING 0x0500
72 #define USIG_PROCESS_LOADED 0x0600
74 /***********************************************************************
75 * SignalProc32 (USER.391)
76 * UserSignalProc (USER32.@)
78 * The exact meaning of the USER signals is undocumented, but this
79 * should cover the basic idea:
81 * USIG_DLL_UNLOAD_WIN16
82 * This is sent when a 16-bit module is unloaded.
84 * USIG_DLL_UNLOAD_WIN32
85 * This is sent when a 32-bit module is unloaded.
87 * USIG_DLL_UNLOAD_ORPHANS
88 * This is sent after the last Win3.1 module is unloaded,
89 * to allow removal of orphaned menus.
91 * USIG_FAULT_DIALOG_PUSH
92 * USIG_FAULT_DIALOG_POP
93 * These are called to allow USER to prepare for displaying a
94 * fault dialog, even though the fault might have happened while
95 * inside a USER critical section.
98 * This is called from the context of a new thread, as soon as it
102 * This is called, still in its context, just before a thread is
103 * about to terminate.
105 * USIG_PROCESS_CREATE
106 * This is called, in the parent process context, after a new process
110 * This is called in the new process context, just after the main thread
111 * has started execution (after the main thread's USIG_THREAD_INIT has
114 * USIG_PROCESS_LOADED
115 * This is called after the executable file has been loaded into the
116 * new process context.
118 * USIG_PROCESS_RUNNING
119 * This is called immediately before the main entry point is called.
122 * This is called in the context of a process that is about to
123 * terminate (but before the last thread's USIG_THREAD_EXIT has
126 * USIG_PROCESS_DESTROY
127 * This is called after a process has terminated.
130 * The meaning of the dwFlags bits is as follows:
133 * Current process is 32-bit.
136 * Current process is a (Win32) GUI process.
138 * USIG_FLAGS_FEEDBACK
139 * Current process needs 'feedback' (determined from the STARTUPINFO
140 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
143 * The signal is being sent due to a fault.
145 WORD WINAPI
UserSignalProc( UINT uCode
, DWORD dwThreadOrProcessID
,
146 DWORD dwFlags
, HMODULE16 hModule
)
148 FIXME("(%04x, %08x, %04x, %04x)\n",
149 uCode
, dwThreadOrProcessID
, dwFlags
, hModule
);
150 /* FIXME: Should chain to GdiSignalProc now. */
155 /**********************************************************************
156 * SetLastErrorEx [USER32.@]
158 * Sets the last-error code.
163 void WINAPI
SetLastErrorEx(
164 DWORD error
, /* [in] Per-thread error code */
165 DWORD type
) /* [in] Error type */
167 TRACE("(0x%08x, 0x%08x)\n", error
,type
);
174 /* Fall through for now */
176 FIXME("(error=%08x, type=%08x): Unhandled type\n", error
,type
);
179 SetLastError( error
);
182 /******************************************************************************
183 * GetAltTabInfoA [USER32.@]
185 BOOL WINAPI
GetAltTabInfoA(HWND hwnd
, int iItem
, PALTTABINFO pati
, LPSTR pszItemText
, UINT cchItemText
)
187 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd
, iItem
, pati
, pszItemText
, cchItemText
);
191 /******************************************************************************
192 * GetAltTabInfoW [USER32.@]
194 BOOL WINAPI
GetAltTabInfoW(HWND hwnd
, int iItem
, PALTTABINFO pati
, LPWSTR pszItemText
, UINT cchItemText
)
196 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd
, iItem
, pati
, pszItemText
, cchItemText
);
200 /******************************************************************************
201 * SetDebugErrorLevel [USER32.@]
202 * Sets the minimum error level for generating debugging events
205 * dwLevel [I] Debugging error level
210 VOID WINAPI
SetDebugErrorLevel( DWORD dwLevel
)
212 FIXME("(%d): stub\n", dwLevel
);
216 /***********************************************************************
217 * SetWindowStationUser (USER32.@)
219 DWORD WINAPI
SetWindowStationUser(DWORD x1
,DWORD x2
)
221 FIXME("(0x%08x,0x%08x),stub!\n",x1
,x2
);
225 /***********************************************************************
226 * RegisterLogonProcess (USER32.@)
228 DWORD WINAPI
RegisterLogonProcess(HANDLE hprocess
,BOOL x
)
230 FIXME("(%p,%d),stub!\n",hprocess
,x
);
234 /***********************************************************************
235 * SetLogonNotifyWindow (USER32.@)
237 DWORD WINAPI
SetLogonNotifyWindow(HWINSTA hwinsta
,HWND hwnd
)
239 FIXME("(%p,%p),stub!\n",hwinsta
,hwnd
);
243 /***********************************************************************
244 * QueryDisplayConfig (USER32.@)
246 LONG WINAPI
QueryDisplayConfig(UINT32 flags
, UINT32
*numpathelements
, DISPLAYCONFIG_PATH_INFO
*pathinfo
,
247 UINT32
*numinfoelements
, DISPLAYCONFIG_MODE_INFO
*modeinfo
,
248 DISPLAYCONFIG_TOPOLOGY_ID
*topologyid
)
250 FIXME("(%08x %p %p %p %p %p)\n", flags
, numpathelements
, pathinfo
, numinfoelements
, modeinfo
, topologyid
);
251 return ERROR_CALL_NOT_IMPLEMENTED
;
254 /***********************************************************************
255 * RegisterSystemThread (USER32.@)
257 void WINAPI
RegisterSystemThread(DWORD flags
, DWORD reserved
)
259 FIXME("(%08x, %08x)\n", flags
, reserved
);
262 /***********************************************************************
263 * RegisterShellHookWindow [USER32.@]
265 BOOL WINAPI
RegisterShellHookWindow(HWND hWnd
)
267 FIXME("(%p): stub\n", hWnd
);
272 /***********************************************************************
273 * DeregisterShellHookWindow [USER32.@]
275 BOOL WINAPI
DeregisterShellHookWindow(HWND hWnd
)
277 FIXME("(%p): stub\n", hWnd
);
282 /***********************************************************************
283 * RegisterTasklist [USER32.@]
285 DWORD WINAPI
RegisterTasklist (DWORD x
)
292 /***********************************************************************
293 * RegisterDeviceNotificationA (USER32.@)
295 * See RegisterDeviceNotificationW.
297 HDEVNOTIFY WINAPI
RegisterDeviceNotificationA(HANDLE hnd
, LPVOID notifyfilter
, DWORD flags
)
299 FIXME("(hwnd=%p, filter=%p,flags=0x%08x) returns a fake device notification handle!\n",
300 hnd
,notifyfilter
,flags
);
301 return (HDEVNOTIFY
) 0xcafecafe;
304 /***********************************************************************
305 * RegisterDeviceNotificationW (USER32.@)
307 * Registers a window with the system so that it will receive
308 * notifications about a device.
311 * hRecipient [I] Window or service status handle that
312 * will receive notifications.
313 * pNotificationFilter [I] DEV_BROADCAST_HDR followed by some
314 * type-specific data.
315 * dwFlags [I] See notes
319 * A handle to the device notification.
323 * The dwFlags parameter can be one of two values:
324 *| DEVICE_NOTIFY_WINDOW_HANDLE - hRecipient is a window handle
325 *| DEVICE_NOTIFY_SERVICE_HANDLE - hRecipient is a service status handle
327 HDEVNOTIFY WINAPI
RegisterDeviceNotificationW(HANDLE hRecipient
, LPVOID pNotificationFilter
, DWORD dwFlags
)
329 FIXME("(hwnd=%p, filter=%p,flags=0x%08x) returns a fake device notification handle!\n",
330 hRecipient
,pNotificationFilter
,dwFlags
);
331 return (HDEVNOTIFY
) 0xcafeaffe;
334 /***********************************************************************
335 * UnregisterDeviceNotification (USER32.@)
338 BOOL WINAPI
UnregisterDeviceNotification(HDEVNOTIFY hnd
)
340 FIXME("(handle=%p), STUB!\n", hnd
);
344 /***********************************************************************
345 * GetAppCompatFlags (USER32.@)
347 DWORD WINAPI
GetAppCompatFlags( HTASK hTask
)
349 FIXME("(%p) stub\n", hTask
);
353 /***********************************************************************
354 * GetAppCompatFlags2 (USER32.@)
356 DWORD WINAPI
GetAppCompatFlags2( HTASK hTask
)
358 FIXME("(%p) stub\n", hTask
);
363 /***********************************************************************
364 * AlignRects (USER32.@)
366 BOOL WINAPI
AlignRects(LPRECT rect
, DWORD b
, DWORD c
, DWORD d
)
368 FIXME("(%p, %d, %d, %d): stub\n", rect
, b
, c
, d
);
370 FIXME("rect: %s\n", wine_dbgstr_rect(rect
));
371 /* Calls OffsetRect */
376 /***********************************************************************
377 * LoadLocalFonts (USER32.@)
379 VOID WINAPI
LoadLocalFonts(VOID
)
386 /***********************************************************************
387 * User32InitializeImmEntryTable
389 BOOL WINAPI
User32InitializeImmEntryTable(DWORD magic
)
391 static const WCHAR imm32_dllW
[] = {'i','m','m','3','2','.','d','l','l',0};
392 HMODULE imm32
= GetModuleHandleW(imm32_dllW
);
394 TRACE("(%x)\n", magic
);
396 if (!imm32
|| magic
!= IMM_INIT_MAGIC
)
399 if (imm_get_ui_window
)
402 WM_MSIME_SERVICE
= RegisterWindowMessageA("MSIMEService");
403 WM_MSIME_RECONVERTOPTIONS
= RegisterWindowMessageA("MSIMEReconvertOptions");
404 WM_MSIME_MOUSE
= RegisterWindowMessageA("MSIMEMouseOperation");
405 WM_MSIME_RECONVERTREQUEST
= RegisterWindowMessageA("MSIMEReconvertRequest");
406 WM_MSIME_RECONVERT
= RegisterWindowMessageA("MSIMEReconvert");
407 WM_MSIME_QUERYPOSITION
= RegisterWindowMessageA("MSIMEQueryPosition");
408 WM_MSIME_DOCUMENTFEED
= RegisterWindowMessageA("MSIMEDocumentFeed");
410 /* this part is not compatible with native imm32.dll */
411 imm_get_ui_window
= (void*)GetProcAddress(imm32
, "__wine_get_ui_window");
412 imm_register_window
= (void*)GetProcAddress(imm32
, "__wine_register_window");
413 imm_unregister_window
= (void*)GetProcAddress(imm32
, "__wine_unregister_window");
414 if (!imm_get_ui_window
)
415 FIXME("native imm32.dll not supported\n");
419 /**********************************************************************
420 * WINNLSGetIMEHotkey [USER32.@]
423 UINT WINAPI
WINNLSGetIMEHotkey(HWND hwnd
)
425 FIXME("hwnd %p: stub!\n", hwnd
);
426 return 0; /* unknown */
429 /**********************************************************************
430 * WINNLSEnableIME [USER32.@]
433 BOOL WINAPI
WINNLSEnableIME(HWND hwnd
, BOOL enable
)
435 FIXME("hwnd %p enable %d: stub!\n", hwnd
, enable
);
436 return TRUE
; /* success (?) */
439 /**********************************************************************
440 * WINNLSGetEnableStatus [USER32.@]
443 BOOL WINAPI
WINNLSGetEnableStatus(HWND hwnd
)
445 FIXME("hwnd %p: stub!\n", hwnd
);
446 return TRUE
; /* success (?) */
449 /**********************************************************************
450 * SendIMEMessageExA [USER32.@]
453 LRESULT WINAPI
SendIMEMessageExA(HWND hwnd
, LPARAM lparam
)
455 FIXME("(%p,%lx): stub\n", hwnd
, lparam
);
456 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
460 /**********************************************************************
461 * SendIMEMessageExW [USER32.@]
464 LRESULT WINAPI
SendIMEMessageExW(HWND hwnd
, LPARAM lparam
)
466 FIXME("(%p,%lx): stub\n", hwnd
, lparam
);
467 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
471 /**********************************************************************
472 * DisableProcessWindowsGhosting [USER32.@]
475 VOID WINAPI
DisableProcessWindowsGhosting(VOID
)
478 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
482 /**********************************************************************
483 * UserHandleGrantAccess [USER32.@]
486 BOOL WINAPI
UserHandleGrantAccess(HANDLE handle
, HANDLE job
, BOOL grant
)
488 FIXME("(%p,%p,%d): stub\n", handle
, job
, grant
);
492 /**********************************************************************
493 * RegisterPowerSettingNotification [USER32.@]
495 HPOWERNOTIFY WINAPI
RegisterPowerSettingNotification(HANDLE recipient
, const GUID
*guid
, DWORD flags
)
497 FIXME("(%p,%s,%x): stub\n", recipient
, debugstr_guid(guid
), flags
);
498 return (HPOWERNOTIFY
)0xdeadbeef;
501 /**********************************************************************
502 * UnregisterPowerSettingNotification [USER32.@]
504 BOOL WINAPI
UnregisterPowerSettingNotification(HPOWERNOTIFY handle
)
506 FIXME("(%p): stub\n", handle
);
510 /*****************************************************************************
511 * GetGestureConfig (USER32.@)
513 BOOL WINAPI
GetGestureConfig( HWND hwnd
, DWORD reserved
, DWORD flags
, UINT
*count
, GESTURECONFIG
*config
, UINT size
)
515 FIXME("(%p %08x %08x %p %p %u): stub\n", hwnd
, reserved
, flags
, count
, config
, size
);
516 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
520 /**********************************************************************
521 * SetGestureConfig [USER32.@]
523 BOOL WINAPI
SetGestureConfig( HWND hwnd
, DWORD reserved
, UINT id
, PGESTURECONFIG config
, UINT size
)
525 FIXME("(%p %08x %u %p %u): stub\n", hwnd
, reserved
, id
, config
, size
);
526 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
530 /**********************************************************************
531 * IsTouchWindow [USER32.@]
533 BOOL WINAPI
IsTouchWindow( HWND hwnd
, PULONG flags
)
535 FIXME("(%p %p): stub\n", hwnd
, flags
);
539 /**********************************************************************
540 * IsWindowRedirectedForPrint [USER32.@]
542 BOOL WINAPI
IsWindowRedirectedForPrint( HWND hwnd
)
544 FIXME("(%p): stub\n", hwnd
);
548 /**********************************************************************
549 * GetDisplayConfigBufferSizes [USER32.@]
551 LONG WINAPI
GetDisplayConfigBufferSizes(UINT32 flags
, UINT32
*num_path_info
, UINT32
*num_mode_info
)
553 FIXME("(0x%x %p %p): stub\n", flags
, num_path_info
, num_mode_info
);
555 if (!num_path_info
|| !num_mode_info
)
556 return ERROR_INVALID_PARAMETER
;
560 return ERROR_NOT_SUPPORTED
;
563 /**********************************************************************
564 * RegisterPointerDeviceNotifications [USER32.@]
566 BOOL WINAPI
RegisterPointerDeviceNotifications(HWND hwnd
, BOOL notifyrange
)
568 FIXME("(%p %d): stub\n", hwnd
, notifyrange
);
572 /**********************************************************************
573 * GetPointerDevices [USER32.@]
575 BOOL WINAPI
GetPointerDevices(UINT32
*device_count
, POINTER_DEVICE_INFO
*devices
)
577 FIXME("(%p %p): partial stub\n", device_count
, devices
);
589 /**********************************************************************
590 * RegisterTouchHitTestingWindow [USER32.@]
592 BOOL WINAPI
RegisterTouchHitTestingWindow(HWND hwnd
, ULONG value
)
594 FIXME("(%p %d): stub\n", hwnd
, value
);
598 /**********************************************************************
599 * GetPointerType [USER32.@]
601 BOOL WINAPI
GetPointerType(UINT32 id
, POINTER_INPUT_TYPE
*type
)
603 FIXME("(%d %p): stub\n", id
, type
);
607 SetLastError(ERROR_INVALID_PARAMETER
);
615 static const WCHAR imeW
[] = {'I','M','E',0};
616 const struct builtin_class_descr IME_builtin_class
=
620 WINPROC_IME
, /* proc */
621 2*sizeof(LONG_PTR
), /* extra */
622 IDC_ARROW
, /* cursor */
626 static BOOL
is_ime_ui_msg( UINT msg
)
629 case WM_IME_STARTCOMPOSITION
:
630 case WM_IME_ENDCOMPOSITION
:
631 case WM_IME_COMPOSITION
:
632 case WM_IME_SETCONTEXT
:
635 case WM_IME_COMPOSITIONFULL
:
643 if ((msg
== WM_MSIME_RECONVERTOPTIONS
) ||
644 (msg
== WM_MSIME_SERVICE
) ||
645 (msg
== WM_MSIME_MOUSE
) ||
646 (msg
== WM_MSIME_RECONVERTREQUEST
) ||
647 (msg
== WM_MSIME_RECONVERT
) ||
648 (msg
== WM_MSIME_QUERYPOSITION
) ||
649 (msg
== WM_MSIME_DOCUMENTFEED
))
656 LRESULT WINAPI
ImeWndProcA( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
663 if (imm_get_ui_window
&& is_ime_ui_msg(msg
))
665 if ((uiwnd
= imm_get_ui_window(GetKeyboardLayout(0))))
666 return SendMessageA(uiwnd
, msg
, wParam
, lParam
);
670 return DefWindowProcA(hwnd
, msg
, wParam
, lParam
);
673 LRESULT WINAPI
ImeWndProcW( HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
680 if (imm_get_ui_window
&& is_ime_ui_msg(msg
))
682 if ((uiwnd
= imm_get_ui_window(GetKeyboardLayout(0))))
683 return SendMessageW(uiwnd
, msg
, wParam
, lParam
);
687 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);