gdi32: Try to parse font names without FreeType.
[wine/zf.git] / dlls / user32 / misc.c
blobe12a1af55719969d9a681b554cc2ce46a6775db1
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 "user_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(win);
37 #define IMM_INIT_MAGIC 0x19650412
38 static HWND (WINAPI *imm_get_ui_window)(HKL);
39 BOOL (WINAPI *imm_register_window)(HWND) = NULL;
40 void (WINAPI *imm_unregister_window)(HWND) = NULL;
42 /* MSIME messages */
43 static UINT WM_MSIME_SERVICE;
44 static UINT WM_MSIME_RECONVERTOPTIONS;
45 static UINT WM_MSIME_MOUSE;
46 static UINT WM_MSIME_RECONVERTREQUEST;
47 static UINT WM_MSIME_RECONVERT;
48 static UINT WM_MSIME_QUERYPOSITION;
49 static UINT WM_MSIME_DOCUMENTFEED;
51 /* USER signal proc flags and codes */
52 /* See UserSignalProc for comments */
53 #define USIG_FLAGS_WIN32 0x0001
54 #define USIG_FLAGS_GUI 0x0002
55 #define USIG_FLAGS_FEEDBACK 0x0004
56 #define USIG_FLAGS_FAULT 0x0008
58 #define USIG_DLL_UNLOAD_WIN16 0x0001
59 #define USIG_DLL_UNLOAD_WIN32 0x0002
60 #define USIG_FAULT_DIALOG_PUSH 0x0003
61 #define USIG_FAULT_DIALOG_POP 0x0004
62 #define USIG_DLL_UNLOAD_ORPHANS 0x0005
63 #define USIG_THREAD_INIT 0x0010
64 #define USIG_THREAD_EXIT 0x0020
65 #define USIG_PROCESS_CREATE 0x0100
66 #define USIG_PROCESS_INIT 0x0200
67 #define USIG_PROCESS_EXIT 0x0300
68 #define USIG_PROCESS_DESTROY 0x0400
69 #define USIG_PROCESS_RUNNING 0x0500
70 #define USIG_PROCESS_LOADED 0x0600
72 /***********************************************************************
73 * SignalProc32 (USER.391)
74 * UserSignalProc (USER32.@)
76 * The exact meaning of the USER signals is undocumented, but this
77 * should cover the basic idea:
79 * USIG_DLL_UNLOAD_WIN16
80 * This is sent when a 16-bit module is unloaded.
82 * USIG_DLL_UNLOAD_WIN32
83 * This is sent when a 32-bit module is unloaded.
85 * USIG_DLL_UNLOAD_ORPHANS
86 * This is sent after the last Win3.1 module is unloaded,
87 * to allow removal of orphaned menus.
89 * USIG_FAULT_DIALOG_PUSH
90 * USIG_FAULT_DIALOG_POP
91 * These are called to allow USER to prepare for displaying a
92 * fault dialog, even though the fault might have happened while
93 * inside a USER critical section.
95 * USIG_THREAD_INIT
96 * This is called from the context of a new thread, as soon as it
97 * has started to run.
99 * USIG_THREAD_EXIT
100 * This is called, still in its context, just before a thread is
101 * about to terminate.
103 * USIG_PROCESS_CREATE
104 * This is called, in the parent process context, after a new process
105 * has been created.
107 * USIG_PROCESS_INIT
108 * This is called in the new process context, just after the main thread
109 * has started execution (after the main thread's USIG_THREAD_INIT has
110 * been sent).
112 * USIG_PROCESS_LOADED
113 * This is called after the executable file has been loaded into the
114 * new process context.
116 * USIG_PROCESS_RUNNING
117 * This is called immediately before the main entry point is called.
119 * USIG_PROCESS_EXIT
120 * This is called in the context of a process that is about to
121 * terminate (but before the last thread's USIG_THREAD_EXIT has
122 * been sent).
124 * USIG_PROCESS_DESTROY
125 * This is called after a process has terminated.
128 * The meaning of the dwFlags bits is as follows:
130 * USIG_FLAGS_WIN32
131 * Current process is 32-bit.
133 * USIG_FLAGS_GUI
134 * Current process is a (Win32) GUI process.
136 * USIG_FLAGS_FEEDBACK
137 * Current process needs 'feedback' (determined from the STARTUPINFO
138 * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK).
140 * USIG_FLAGS_FAULT
141 * The signal is being sent due to a fault.
143 WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID,
144 DWORD dwFlags, HMODULE16 hModule )
146 FIXME("(%04x, %08x, %04x, %04x)\n",
147 uCode, dwThreadOrProcessID, dwFlags, hModule );
148 /* FIXME: Should chain to GdiSignalProc now. */
149 return 0;
153 /**********************************************************************
154 * SetLastErrorEx [USER32.@]
156 * Sets the last-error code.
158 * RETURNS
159 * None.
161 void WINAPI SetLastErrorEx(
162 DWORD error, /* [in] Per-thread error code */
163 DWORD type) /* [in] Error type */
165 TRACE("(0x%08x, 0x%08x)\n", error,type);
166 switch(type) {
167 case 0:
168 break;
169 case SLE_ERROR:
170 case SLE_MINORERROR:
171 case SLE_WARNING:
172 /* Fall through for now */
173 default:
174 FIXME("(error=%08x, type=%08x): Unhandled type\n", error,type);
175 break;
177 SetLastError( error );
180 /******************************************************************************
181 * GetAltTabInfoA [USER32.@]
183 BOOL WINAPI GetAltTabInfoA(HWND hwnd, int iItem, PALTTABINFO pati, LPSTR pszItemText, UINT cchItemText)
185 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
186 return FALSE;
189 /******************************************************************************
190 * GetAltTabInfoW [USER32.@]
192 BOOL WINAPI GetAltTabInfoW(HWND hwnd, int iItem, PALTTABINFO pati, LPWSTR pszItemText, UINT cchItemText)
194 FIXME("(%p, 0x%08x, %p, %p, 0x%08x)\n", hwnd, iItem, pati, pszItemText, cchItemText);
195 return FALSE;
198 /******************************************************************************
199 * SetDebugErrorLevel [USER32.@]
200 * Sets the minimum error level for generating debugging events
202 * PARAMS
203 * dwLevel [I] Debugging error level
205 * RETURNS
206 * Nothing.
208 VOID WINAPI SetDebugErrorLevel( DWORD dwLevel )
210 FIXME("(%d): stub\n", dwLevel);
214 /***********************************************************************
215 * SetWindowStationUser (USER32.@)
217 DWORD WINAPI SetWindowStationUser(DWORD x1,DWORD x2)
219 FIXME("(0x%08x,0x%08x),stub!\n",x1,x2);
220 return 1;
223 /***********************************************************************
224 * RegisterLogonProcess (USER32.@)
226 DWORD WINAPI RegisterLogonProcess(HANDLE hprocess,BOOL x)
228 FIXME("(%p,%d),stub!\n",hprocess,x);
229 return 1;
232 /***********************************************************************
233 * SetLogonNotifyWindow (USER32.@)
235 DWORD WINAPI SetLogonNotifyWindow(HWINSTA hwinsta,HWND hwnd)
237 FIXME("(%p,%p),stub!\n",hwinsta,hwnd);
238 return 1;
241 /***********************************************************************
242 * RegisterSystemThread (USER32.@)
244 void WINAPI RegisterSystemThread(DWORD flags, DWORD reserved)
246 FIXME("(%08x, %08x)\n", flags, reserved);
249 /***********************************************************************
250 * RegisterShellHookWindow [USER32.@]
252 BOOL WINAPI RegisterShellHookWindow(HWND hWnd)
254 FIXME("(%p): stub\n", hWnd);
255 return FALSE;
259 /***********************************************************************
260 * DeregisterShellHookWindow [USER32.@]
262 BOOL WINAPI DeregisterShellHookWindow(HWND hWnd)
264 FIXME("(%p): stub\n", hWnd);
265 return FALSE;
269 /***********************************************************************
270 * RegisterTasklist [USER32.@]
272 DWORD WINAPI RegisterTasklist (DWORD x)
274 FIXME("0x%08x\n",x);
275 return TRUE;
278 /***********************************************************************
279 * GetAppCompatFlags (USER32.@)
281 DWORD WINAPI GetAppCompatFlags( HTASK hTask )
283 FIXME("(%p) stub\n", hTask);
284 return 0;
287 /***********************************************************************
288 * GetAppCompatFlags2 (USER32.@)
290 DWORD WINAPI GetAppCompatFlags2( HTASK hTask )
292 FIXME("(%p) stub\n", hTask);
293 return 0;
297 /***********************************************************************
298 * AlignRects (USER32.@)
300 BOOL WINAPI AlignRects(LPRECT rect, DWORD b, DWORD c, DWORD d)
302 FIXME("(%p, %d, %d, %d): stub\n", rect, b, c, d);
303 if (rect)
304 FIXME("rect: %s\n", wine_dbgstr_rect(rect));
305 /* Calls OffsetRect */
306 return FALSE;
310 /***********************************************************************
311 * LoadLocalFonts (USER32.@)
313 VOID WINAPI LoadLocalFonts(VOID)
315 /* are loaded. */
316 return;
320 /***********************************************************************
321 * User32InitializeImmEntryTable
323 BOOL WINAPI User32InitializeImmEntryTable(DWORD magic)
325 HMODULE imm32 = GetModuleHandleW(L"imm32.dll");
327 TRACE("(%x)\n", magic);
329 if (!imm32 || magic != IMM_INIT_MAGIC)
330 return FALSE;
332 if (imm_get_ui_window)
333 return TRUE;
335 WM_MSIME_SERVICE = RegisterWindowMessageA("MSIMEService");
336 WM_MSIME_RECONVERTOPTIONS = RegisterWindowMessageA("MSIMEReconvertOptions");
337 WM_MSIME_MOUSE = RegisterWindowMessageA("MSIMEMouseOperation");
338 WM_MSIME_RECONVERTREQUEST = RegisterWindowMessageA("MSIMEReconvertRequest");
339 WM_MSIME_RECONVERT = RegisterWindowMessageA("MSIMEReconvert");
340 WM_MSIME_QUERYPOSITION = RegisterWindowMessageA("MSIMEQueryPosition");
341 WM_MSIME_DOCUMENTFEED = RegisterWindowMessageA("MSIMEDocumentFeed");
343 /* this part is not compatible with native imm32.dll */
344 imm_get_ui_window = (void*)GetProcAddress(imm32, "__wine_get_ui_window");
345 imm_register_window = (void*)GetProcAddress(imm32, "__wine_register_window");
346 imm_unregister_window = (void*)GetProcAddress(imm32, "__wine_unregister_window");
347 if (!imm_get_ui_window)
348 FIXME("native imm32.dll not supported\n");
349 return TRUE;
352 /**********************************************************************
353 * WINNLSGetIMEHotkey [USER32.@]
356 UINT WINAPI WINNLSGetIMEHotkey(HWND hwnd)
358 FIXME("hwnd %p: stub!\n", hwnd);
359 return 0; /* unknown */
362 /**********************************************************************
363 * WINNLSEnableIME [USER32.@]
366 BOOL WINAPI WINNLSEnableIME(HWND hwnd, BOOL enable)
368 FIXME("hwnd %p enable %d: stub!\n", hwnd, enable);
369 return TRUE; /* success (?) */
372 /**********************************************************************
373 * WINNLSGetEnableStatus [USER32.@]
376 BOOL WINAPI WINNLSGetEnableStatus(HWND hwnd)
378 FIXME("hwnd %p: stub!\n", hwnd);
379 return TRUE; /* success (?) */
382 /**********************************************************************
383 * SendIMEMessageExA [USER32.@]
386 LRESULT WINAPI SendIMEMessageExA(HWND hwnd, LPARAM lparam)
388 FIXME("(%p,%lx): stub\n", hwnd, lparam);
389 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
390 return 0;
393 /**********************************************************************
394 * SendIMEMessageExW [USER32.@]
397 LRESULT WINAPI SendIMEMessageExW(HWND hwnd, LPARAM lparam)
399 FIXME("(%p,%lx): stub\n", hwnd, lparam);
400 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
401 return 0;
404 /**********************************************************************
405 * DisableProcessWindowsGhosting [USER32.@]
408 VOID WINAPI DisableProcessWindowsGhosting(VOID)
410 FIXME(": stub\n");
411 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
412 return;
415 /**********************************************************************
416 * UserHandleGrantAccess [USER32.@]
419 BOOL WINAPI UserHandleGrantAccess(HANDLE handle, HANDLE job, BOOL grant)
421 FIXME("(%p,%p,%d): stub\n", handle, job, grant);
422 return TRUE;
425 /**********************************************************************
426 * RegisterPowerSettingNotification [USER32.@]
428 HPOWERNOTIFY WINAPI RegisterPowerSettingNotification(HANDLE recipient, const GUID *guid, DWORD flags)
430 FIXME("(%p,%s,%x): stub\n", recipient, debugstr_guid(guid), flags);
431 return (HPOWERNOTIFY)0xdeadbeef;
434 /**********************************************************************
435 * UnregisterPowerSettingNotification [USER32.@]
437 BOOL WINAPI UnregisterPowerSettingNotification(HPOWERNOTIFY handle)
439 FIXME("(%p): stub\n", handle);
440 return TRUE;
443 /*****************************************************************************
444 * GetGestureConfig (USER32.@)
446 BOOL WINAPI GetGestureConfig( HWND hwnd, DWORD reserved, DWORD flags, UINT *count, GESTURECONFIG *config, UINT size )
448 FIXME("(%p %08x %08x %p %p %u): stub\n", hwnd, reserved, flags, count, config, size);
449 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
450 return FALSE;
453 /**********************************************************************
454 * SetGestureConfig [USER32.@]
456 BOOL WINAPI SetGestureConfig( HWND hwnd, DWORD reserved, UINT id, PGESTURECONFIG config, UINT size )
458 FIXME("(%p %08x %u %p %u): stub\n", hwnd, reserved, id, config, size);
459 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
460 return FALSE;
463 /**********************************************************************
464 * IsTouchWindow [USER32.@]
466 BOOL WINAPI IsTouchWindow( HWND hwnd, PULONG flags )
468 FIXME("(%p %p): stub\n", hwnd, flags);
469 return FALSE;
472 /**********************************************************************
473 * IsWindowRedirectedForPrint [USER32.@]
475 BOOL WINAPI IsWindowRedirectedForPrint( HWND hwnd )
477 FIXME("(%p): stub\n", hwnd);
478 return FALSE;
481 /**********************************************************************
482 * RegisterPointerDeviceNotifications [USER32.@]
484 BOOL WINAPI RegisterPointerDeviceNotifications(HWND hwnd, BOOL notifyrange)
486 FIXME("(%p %d): stub\n", hwnd, notifyrange);
487 return TRUE;
490 /**********************************************************************
491 * GetPointerDevices [USER32.@]
493 BOOL WINAPI GetPointerDevices(UINT32 *device_count, POINTER_DEVICE_INFO *devices)
495 FIXME("(%p %p): partial stub\n", device_count, devices);
497 if (!device_count)
498 return FALSE;
500 if (devices)
501 return FALSE;
503 *device_count = 0;
504 return TRUE;
507 /**********************************************************************
508 * RegisterTouchHitTestingWindow [USER32.@]
510 BOOL WINAPI RegisterTouchHitTestingWindow(HWND hwnd, ULONG value)
512 FIXME("(%p %d): stub\n", hwnd, value);
513 return TRUE;
516 /**********************************************************************
517 * GetPointerType [USER32.@]
519 BOOL WINAPI GetPointerType(UINT32 id, POINTER_INPUT_TYPE *type)
521 FIXME("(%d %p): stub\n", id, type);
523 if(!id || !type)
525 SetLastError(ERROR_INVALID_PARAMETER);
526 return FALSE;
529 *type = PT_MOUSE;
530 return TRUE;
533 const struct builtin_class_descr IME_builtin_class =
535 L"IME", /* name */
536 0, /* style */
537 WINPROC_IME, /* proc */
538 2*sizeof(LONG_PTR), /* extra */
539 IDC_ARROW, /* cursor */
540 0 /* brush */
543 static BOOL is_ime_ui_msg( UINT msg )
545 switch(msg) {
546 case WM_IME_STARTCOMPOSITION:
547 case WM_IME_ENDCOMPOSITION:
548 case WM_IME_COMPOSITION:
549 case WM_IME_SETCONTEXT:
550 case WM_IME_NOTIFY:
551 case WM_IME_CONTROL:
552 case WM_IME_COMPOSITIONFULL:
553 case WM_IME_SELECT:
554 case WM_IME_CHAR:
555 case WM_IME_REQUEST:
556 case WM_IME_KEYDOWN:
557 case WM_IME_KEYUP:
558 return TRUE;
559 default:
560 if ((msg == WM_MSIME_RECONVERTOPTIONS) ||
561 (msg == WM_MSIME_SERVICE) ||
562 (msg == WM_MSIME_MOUSE) ||
563 (msg == WM_MSIME_RECONVERTREQUEST) ||
564 (msg == WM_MSIME_RECONVERT) ||
565 (msg == WM_MSIME_QUERYPOSITION) ||
566 (msg == WM_MSIME_DOCUMENTFEED))
567 return TRUE;
569 return FALSE;
573 LRESULT WINAPI ImeWndProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
575 HWND uiwnd;
577 if (msg==WM_CREATE)
578 return TRUE;
580 if (imm_get_ui_window && is_ime_ui_msg(msg))
582 if ((uiwnd = imm_get_ui_window(GetKeyboardLayout(0))))
583 return SendMessageA(uiwnd, msg, wParam, lParam);
584 return FALSE;
587 return DefWindowProcA(hwnd, msg, wParam, lParam);
590 LRESULT WINAPI ImeWndProcW( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
592 HWND uiwnd;
594 if (msg==WM_CREATE)
595 return TRUE;
597 if (imm_get_ui_window && is_ime_ui_msg(msg))
599 if ((uiwnd = imm_get_ui_window(GetKeyboardLayout(0))))
600 return SendMessageW(uiwnd, msg, wParam, lParam);
601 return FALSE;
604 return DefWindowProcW(hwnd, msg, wParam, lParam);