richedit: Avoid strlen in traces.
[wine] / dlls / user32 / driver.c
1 /*
2  * USER driver support
3  *
4  * Copyright 2000, 2005 Alexandre Julliard
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "wine/debug.h"
27
28 #include "user_private.h"
29
30 static USER_DRIVER null_driver, lazy_load_driver;
31
32 const USER_DRIVER *USER_Driver = &lazy_load_driver;
33 static DWORD driver_load_error;
34
35 /* load the graphics driver */
36 static const USER_DRIVER *load_driver(void)
37 {
38     char buffer[MAX_PATH], libname[32], *name, *next;
39     HKEY hkey;
40     void *ptr;
41     HMODULE graphics_driver;
42     USER_DRIVER *driver, *prev;
43
44     strcpy( buffer, "x11" );  /* default value */
45     /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
46     if (!RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\Drivers", &hkey ))
47     {
48         DWORD type, count = sizeof(buffer);
49         RegQueryValueExA( hkey, "Graphics", 0, &type, (LPBYTE) buffer, &count );
50         RegCloseKey( hkey );
51     }
52
53     name = buffer;
54     while (name)
55     {
56         next = strchr( name, ',' );
57         if (next) *next++ = 0;
58
59         snprintf( libname, sizeof(libname), "wine%s.drv", name );
60         if ((graphics_driver = LoadLibraryA( libname )) != 0) break;
61         name = next;
62     }
63
64     if (!graphics_driver)
65         driver_load_error = GetLastError();
66
67     driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) );
68     *driver = null_driver;
69
70     if (graphics_driver)
71     {
72 #define GET_USER_FUNC(name) \
73     do { if ((ptr = GetProcAddress( graphics_driver, #name ))) driver->p##name = ptr; } while(0)
74
75         GET_USER_FUNC(ActivateKeyboardLayout);
76         GET_USER_FUNC(Beep);
77         GET_USER_FUNC(GetAsyncKeyState);
78         GET_USER_FUNC(GetKeyNameText);
79         GET_USER_FUNC(GetKeyboardLayout);
80         GET_USER_FUNC(GetKeyboardLayoutList);
81         GET_USER_FUNC(GetKeyboardLayoutName);
82         GET_USER_FUNC(LoadKeyboardLayout);
83         GET_USER_FUNC(MapVirtualKeyEx);
84         GET_USER_FUNC(SendInput);
85         GET_USER_FUNC(ToUnicodeEx);
86         GET_USER_FUNC(UnloadKeyboardLayout);
87         GET_USER_FUNC(VkKeyScanEx);
88         GET_USER_FUNC(SetCursor);
89         GET_USER_FUNC(GetCursorPos);
90         GET_USER_FUNC(SetCursorPos);
91         GET_USER_FUNC(ClipCursor);
92         GET_USER_FUNC(GetScreenSaveActive);
93         GET_USER_FUNC(SetScreenSaveActive);
94         GET_USER_FUNC(AcquireClipboard);
95         GET_USER_FUNC(EmptyClipboard);
96         GET_USER_FUNC(SetClipboardData);
97         GET_USER_FUNC(GetClipboardData);
98         GET_USER_FUNC(CountClipboardFormats);
99         GET_USER_FUNC(EnumClipboardFormats);
100         GET_USER_FUNC(IsClipboardFormatAvailable);
101         GET_USER_FUNC(RegisterClipboardFormat);
102         GET_USER_FUNC(GetClipboardFormatName);
103         GET_USER_FUNC(EndClipboardUpdate);
104         GET_USER_FUNC(ChangeDisplaySettingsEx);
105         GET_USER_FUNC(EnumDisplayMonitors);
106         GET_USER_FUNC(EnumDisplaySettingsEx);
107         GET_USER_FUNC(GetMonitorInfo);
108         GET_USER_FUNC(CreateDesktopWindow);
109         GET_USER_FUNC(CreateWindow);
110         GET_USER_FUNC(DestroyWindow);
111         GET_USER_FUNC(GetDC);
112         GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
113         GET_USER_FUNC(ReleaseDC);
114         GET_USER_FUNC(ScrollDC);
115         GET_USER_FUNC(SetCapture);
116         GET_USER_FUNC(SetFocus);
117         GET_USER_FUNC(SetParent);
118         GET_USER_FUNC(SetWindowPos);
119         GET_USER_FUNC(SetWindowRgn);
120         GET_USER_FUNC(SetWindowIcon);
121         GET_USER_FUNC(SetWindowStyle);
122         GET_USER_FUNC(SetWindowText);
123         GET_USER_FUNC(SysCommand);
124         GET_USER_FUNC(WindowMessage);
125 #undef GET_USER_FUNC
126     }
127
128     prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver );
129     if (prev != &lazy_load_driver)
130     {
131         /* another thread beat us to it */
132         HeapFree( GetProcessHeap(), 0, driver );
133         FreeLibrary( graphics_driver );
134         driver = prev;
135     }
136     return driver;
137 }
138
139 /* unload the graphics driver on process exit */
140 void USER_unload_driver(void)
141 {
142     /* make sure we don't try to call the driver after it has been detached */
143     USER_Driver = &null_driver;
144 }
145
146
147 /**********************************************************************
148  * Null user driver
149  *
150  * These are fallbacks for entry points that are not implemented in the real driver.
151  */
152
153 static HKL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags )
154 {
155     return 0;
156 }
157
158 static void nulldrv_Beep(void)
159 {
160 }
161
162 static SHORT nulldrv_GetAsyncKeyState( INT key )
163 {
164     return 0;
165 }
166
167 static INT nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
168 {
169     return 0;
170 }
171
172 static HKL nulldrv_GetKeyboardLayout( DWORD layout )
173 {
174     return 0;
175 }
176
177 static UINT nulldrv_GetKeyboardLayoutList( INT count, HKL *layouts )
178 {
179     return 0;
180 }
181
182 static BOOL nulldrv_GetKeyboardLayoutName( LPWSTR name )
183 {
184     return FALSE;
185 }
186
187 static HKL nulldrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
188 {
189     return 0;
190 }
191
192 static UINT nulldrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
193 {
194     return 0;
195 }
196
197 static UINT nulldrv_SendInput( UINT count, LPINPUT inputs, int size )
198 {
199     return 0;
200 }
201
202 static INT nulldrv_ToUnicodeEx( UINT virt, UINT scan, LPBYTE state, LPWSTR str,
203                                 int size, UINT flags, HKL layout )
204 {
205     return 0;
206 }
207
208 static BOOL nulldrv_UnloadKeyboardLayout( HKL layout )
209 {
210     return 0;
211 }
212
213 static SHORT nulldrv_VkKeyScanEx( WCHAR ch, HKL layout )
214 {
215     return -1;
216 }
217
218 static void nulldrv_SetCursor( struct tagCURSORICONINFO *info )
219 {
220 }
221
222 static BOOL nulldrv_GetCursorPos( LPPOINT pt )
223 {
224     return FALSE;
225 }
226
227 static BOOL nulldrv_SetCursorPos( INT x, INT y )
228 {
229     return FALSE;
230 }
231
232 static BOOL nulldrv_ClipCursor( LPCRECT clip )
233 {
234     return FALSE;
235 }
236
237 static BOOL nulldrv_GetScreenSaveActive(void)
238 {
239     return FALSE;
240 }
241
242 static void nulldrv_SetScreenSaveActive( BOOL on )
243 {
244 }
245
246 static INT nulldrv_AcquireClipboard( HWND hwnd )
247 {
248     return 0;
249 }
250
251 static BOOL nulldrv_CountClipboardFormats(void)
252 {
253     return 0;
254 }
255
256 static void nulldrv_EmptyClipboard( BOOL keepunowned )
257 {
258 }
259
260 static void nulldrv_EndClipboardUpdate(void)
261 {
262 }
263
264 static UINT nulldrv_EnumClipboardFormats( UINT format )
265 {
266     return 0;
267 }
268
269 static BOOL nulldrv_GetClipboardData( UINT format, HANDLE16 *h16, HANDLE *h32 )
270 {
271     return FALSE;
272 }
273
274 static INT nulldrv_GetClipboardFormatName( UINT format, LPWSTR buffer, UINT len )
275 {
276     return FALSE;
277 }
278
279 static BOOL nulldrv_IsClipboardFormatAvailable( UINT format )
280 {
281     return FALSE;
282 }
283
284 static UINT nulldrv_RegisterClipboardFormat( LPCWSTR name )
285 {
286     return 0;
287 }
288
289 static BOOL nulldrv_SetClipboardData( UINT format, HANDLE16 h16, HANDLE h32, BOOL owner )
290 {
291     return FALSE;
292 }
293
294 static LONG nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
295                                              DWORD flags, LPVOID lparam )
296 {
297     return DISP_CHANGE_FAILED;
298 }
299
300 static BOOL nulldrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
301 {
302     return FALSE;
303 }
304
305 static BOOL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
306 {
307     return FALSE;
308 }
309
310 static BOOL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
311 {
312     return FALSE;
313 }
314
315 static BOOL nulldrv_CreateDesktopWindow( HWND hwnd )
316 {
317     return TRUE;
318 }
319
320 static BOOL nulldrv_CreateWindow( HWND hwnd )
321 {
322     static int warned;
323     if (warned++)
324         return FALSE;
325
326     MESSAGE( "Application tried to create a window, but no driver could be loaded.\n");
327     switch (driver_load_error)
328     {
329     case ERROR_MOD_NOT_FOUND:
330         MESSAGE( "The X11 driver is missing.  Check your build!\n" );
331         break;
332     case ERROR_DLL_INIT_FAILED:
333         MESSAGE( "Make sure that your X server is running and that $DISPLAY is set correctly.\n" );
334         break;
335     default:
336         MESSAGE( "Unknown error (%d).\n", driver_load_error );
337     }
338
339     return FALSE;
340 }
341
342 static void nulldrv_DestroyWindow( HWND hwnd )
343 {
344 }
345
346 static void nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
347                            const RECT *top_rect, DWORD flags )
348 {
349 }
350
351 static DWORD nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
352                                                   DWORD mask, DWORD flags )
353 {
354     return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
355                                      timeout, flags & MWMO_ALERTABLE );
356 }
357
358 static void nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
359 {
360 }
361
362 static BOOL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
363                               HRGN hrgn, LPRECT update )
364 {
365     return FALSE;
366 }
367
368 static void nulldrv_SetCapture( HWND hwnd, UINT flags )
369 {
370 }
371
372 static void nulldrv_SetFocus( HWND hwnd )
373 {
374 }
375
376 static void nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
377 {
378 }
379
380 static void nulldrv_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
381                                   const RECT *window_rect, const RECT *client_rect,
382                                   const RECT *visible_rect, const RECT *valid_rects )
383 {
384 }
385
386 static int nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
387 {
388     return 1;
389 }
390
391 static void nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
392 {
393 }
394
395 static void nulldrv_SetWindowStyle( HWND hwnd, DWORD old_style )
396 {
397 }
398
399 static void nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
400 {
401 }
402
403 static LRESULT nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
404 {
405     return -1;
406 }
407
408 static LRESULT nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
409 {
410     return 0;
411 }
412
413 static USER_DRIVER null_driver =
414 {
415     /* keyboard functions */
416     nulldrv_ActivateKeyboardLayout,
417     nulldrv_Beep,
418     nulldrv_GetAsyncKeyState,
419     nulldrv_GetKeyNameText,
420     nulldrv_GetKeyboardLayout,
421     nulldrv_GetKeyboardLayoutList,
422     nulldrv_GetKeyboardLayoutName,
423     nulldrv_LoadKeyboardLayout,
424     nulldrv_MapVirtualKeyEx,
425     nulldrv_SendInput,
426     nulldrv_ToUnicodeEx,
427     nulldrv_UnloadKeyboardLayout,
428     nulldrv_VkKeyScanEx,
429     /* mouse functions */
430     nulldrv_SetCursor,
431     nulldrv_GetCursorPos,
432     nulldrv_SetCursorPos,
433     nulldrv_ClipCursor,
434     /* screen saver functions */
435     nulldrv_GetScreenSaveActive,
436     nulldrv_SetScreenSaveActive,
437     /* clipboard functions */
438     nulldrv_AcquireClipboard,
439     nulldrv_CountClipboardFormats,
440     nulldrv_EmptyClipboard,
441     nulldrv_EndClipboardUpdate,
442     nulldrv_EnumClipboardFormats,
443     nulldrv_GetClipboardData,
444     nulldrv_GetClipboardFormatName,
445     nulldrv_IsClipboardFormatAvailable,
446     nulldrv_RegisterClipboardFormat,
447     nulldrv_SetClipboardData,
448     /* display modes */
449     nulldrv_ChangeDisplaySettingsEx,
450     nulldrv_EnumDisplayMonitors,
451     nulldrv_EnumDisplaySettingsEx,
452     nulldrv_GetMonitorInfo,
453     /* windowing functions */
454     nulldrv_CreateDesktopWindow,
455     nulldrv_CreateWindow,
456     nulldrv_DestroyWindow,
457     nulldrv_GetDC,
458     nulldrv_MsgWaitForMultipleObjectsEx,
459     nulldrv_ReleaseDC,
460     nulldrv_ScrollDC,
461     nulldrv_SetCapture,
462     nulldrv_SetFocus,
463     nulldrv_SetParent,
464     nulldrv_SetWindowPos,
465     nulldrv_SetWindowRgn,
466     nulldrv_SetWindowIcon,
467     nulldrv_SetWindowStyle,
468     nulldrv_SetWindowText,
469     nulldrv_SysCommand,
470     nulldrv_WindowMessage
471 };
472
473
474 /**********************************************************************
475  * Lazy loading user driver
476  *
477  * Initial driver used before another driver is loaded.
478  * Each entry point simply loads the real driver and chains to it.
479  */
480
481 static HKL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
482 {
483     return load_driver()->pActivateKeyboardLayout( layout, flags );
484 }
485
486 static void loaderdrv_Beep(void)
487 {
488     load_driver()->pBeep();
489 }
490
491 static SHORT loaderdrv_GetAsyncKeyState( INT key )
492 {
493     return load_driver()->pGetAsyncKeyState( key );
494 }
495
496 static INT loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
497 {
498     return load_driver()->pGetKeyNameText( lparam, buffer, size );
499 }
500
501 static HKL loaderdrv_GetKeyboardLayout( DWORD layout )
502 {
503     return load_driver()->pGetKeyboardLayout( layout );
504 }
505
506 static UINT loaderdrv_GetKeyboardLayoutList( INT count, HKL *layouts )
507 {
508     return load_driver()->pGetKeyboardLayoutList( count, layouts );
509 }
510
511 static BOOL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
512 {
513     return load_driver()->pGetKeyboardLayoutName( name );
514 }
515
516 static HKL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
517 {
518     return load_driver()->pLoadKeyboardLayout( name, flags );
519 }
520
521 static UINT loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
522 {
523     return load_driver()->pMapVirtualKeyEx( code, type, layout );
524 }
525
526 static UINT loaderdrv_SendInput( UINT count, LPINPUT inputs, int size )
527 {
528     return load_driver()->pSendInput( count, inputs, size );
529 }
530
531 static INT loaderdrv_ToUnicodeEx( UINT virt, UINT scan, LPBYTE state, LPWSTR str,
532                                   int size, UINT flags, HKL layout )
533 {
534     return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
535 }
536
537 static BOOL loaderdrv_UnloadKeyboardLayout( HKL layout )
538 {
539     return load_driver()->pUnloadKeyboardLayout( layout );
540 }
541
542 static SHORT loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
543 {
544     return load_driver()->pVkKeyScanEx( ch, layout );
545 }
546
547 static void loaderdrv_SetCursor( struct tagCURSORICONINFO *info )
548 {
549     load_driver()->pSetCursor( info );
550 }
551
552 static BOOL loaderdrv_GetCursorPos( LPPOINT pt )
553 {
554     return load_driver()->pGetCursorPos( pt );
555 }
556
557 static BOOL loaderdrv_SetCursorPos( INT x, INT y )
558 {
559     return load_driver()->pSetCursorPos( x, y );
560 }
561
562 static BOOL loaderdrv_ClipCursor( LPCRECT clip )
563 {
564     return load_driver()->pClipCursor( clip );
565 }
566
567 static BOOL loaderdrv_GetScreenSaveActive(void)
568 {
569     return load_driver()->pGetScreenSaveActive();
570 }
571
572 static void loaderdrv_SetScreenSaveActive( BOOL on )
573 {
574     load_driver()->pSetScreenSaveActive( on );
575 }
576
577 static INT loaderdrv_AcquireClipboard( HWND hwnd )
578 {
579     return load_driver()->pAcquireClipboard( hwnd );
580 }
581
582 static BOOL loaderdrv_CountClipboardFormats(void)
583 {
584     return load_driver()->pCountClipboardFormats();
585 }
586
587 static void loaderdrv_EmptyClipboard( BOOL keepunowned )
588 {
589     load_driver()->pEmptyClipboard( keepunowned );
590 }
591
592 static void loaderdrv_EndClipboardUpdate(void)
593 {
594     load_driver()->pEndClipboardUpdate();
595 }
596
597 static UINT loaderdrv_EnumClipboardFormats( UINT format )
598 {
599     return load_driver()->pEnumClipboardFormats( format );
600 }
601
602 static BOOL loaderdrv_GetClipboardData( UINT format, HANDLE16 *h16, HANDLE *h32 )
603 {
604     return load_driver()->pGetClipboardData( format, h16, h32 );
605 }
606
607 static INT loaderdrv_GetClipboardFormatName( UINT format, LPWSTR buffer, UINT len )
608 {
609     return load_driver()->pGetClipboardFormatName( format, buffer, len );
610 }
611
612 static BOOL loaderdrv_IsClipboardFormatAvailable( UINT format )
613 {
614     return load_driver()->pIsClipboardFormatAvailable( format );
615 }
616
617 static UINT loaderdrv_RegisterClipboardFormat( LPCWSTR name )
618 {
619     return load_driver()->pRegisterClipboardFormat( name );
620 }
621
622 static BOOL loaderdrv_SetClipboardData( UINT format, HANDLE16 h16, HANDLE h32, BOOL owner )
623 {
624     return load_driver()->pSetClipboardData( format, h16, h32, owner );
625 }
626
627 static LONG loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
628                                                DWORD flags, LPVOID lparam )
629 {
630     return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
631 }
632
633 static BOOL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
634 {
635     return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
636 }
637
638 static BOOL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
639 {
640     return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
641 }
642
643 static BOOL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
644 {
645     return load_driver()->pGetMonitorInfo( handle, info );
646 }
647
648 static BOOL loaderdrv_CreateDesktopWindow( HWND hwnd )
649 {
650     return load_driver()->pCreateDesktopWindow( hwnd );
651 }
652
653 static BOOL loaderdrv_CreateWindow( HWND hwnd )
654 {
655     return load_driver()->pCreateWindow( hwnd );
656 }
657
658 static void loaderdrv_DestroyWindow( HWND hwnd )
659 {
660     load_driver()->pDestroyWindow( hwnd );
661 }
662
663 static void loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
664                              const RECT *top_rect, DWORD flags )
665 {
666     load_driver()->pGetDC( hdc, hwnd, top_win, win_rect, top_rect, flags );
667 }
668
669 static DWORD loaderdrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
670                                                     DWORD mask, DWORD flags )
671 {
672     return load_driver()->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
673 }
674
675 static void loaderdrv_ReleaseDC( HWND hwnd, HDC hdc )
676 {
677     load_driver()->pReleaseDC( hwnd, hdc );
678 }
679
680 static BOOL loaderdrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
681                                 HRGN hrgn, LPRECT update )
682 {
683     return load_driver()->pScrollDC( hdc, dx, dy, scroll, clip, hrgn, update );
684 }
685
686 static void loaderdrv_SetCapture( HWND hwnd, UINT flags )
687 {
688     load_driver()->pSetCapture( hwnd, flags );
689 }
690
691 static void loaderdrv_SetFocus( HWND hwnd )
692 {
693     load_driver()->pSetFocus( hwnd );
694 }
695
696 static void loaderdrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
697 {
698     load_driver()->pSetParent( hwnd, parent, old_parent );
699 }
700
701 static void loaderdrv_SetWindowPos( HWND hwnd, HWND insert_after, UINT swp_flags,
702                                     const RECT *window_rect, const RECT *client_rect,
703                                     const RECT *visible_rect, const RECT *valid_rects )
704 {
705     load_driver()->pSetWindowPos( hwnd, insert_after, swp_flags, window_rect,
706                                   client_rect, visible_rect, valid_rects );
707 }
708
709 static int loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
710 {
711     return load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
712 }
713
714 static void loaderdrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
715 {
716     load_driver()->pSetWindowIcon( hwnd, type, icon );
717 }
718
719 static void loaderdrv_SetWindowStyle( HWND hwnd, DWORD old_style )
720 {
721     load_driver()->pSetWindowStyle( hwnd, old_style );
722 }
723
724 static void loaderdrv_SetWindowText( HWND hwnd, LPCWSTR text )
725 {
726     load_driver()->pSetWindowText( hwnd, text );
727 }
728
729 static LRESULT loaderdrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
730 {
731     return load_driver()->pSysCommand( hwnd, wparam, lparam );
732 }
733
734 static LRESULT loaderdrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
735 {
736     return load_driver()->pWindowMessage( hwnd, msg, wparam, lparam );
737 }
738
739 static USER_DRIVER lazy_load_driver =
740 {
741     /* keyboard functions */
742     loaderdrv_ActivateKeyboardLayout,
743     loaderdrv_Beep,
744     loaderdrv_GetAsyncKeyState,
745     loaderdrv_GetKeyNameText,
746     loaderdrv_GetKeyboardLayout,
747     loaderdrv_GetKeyboardLayoutList,
748     loaderdrv_GetKeyboardLayoutName,
749     loaderdrv_LoadKeyboardLayout,
750     loaderdrv_MapVirtualKeyEx,
751     loaderdrv_SendInput,
752     loaderdrv_ToUnicodeEx,
753     loaderdrv_UnloadKeyboardLayout,
754     loaderdrv_VkKeyScanEx,
755     /* mouse functions */
756     loaderdrv_SetCursor,
757     loaderdrv_GetCursorPos,
758     loaderdrv_SetCursorPos,
759     loaderdrv_ClipCursor,
760     /* screen saver functions */
761     loaderdrv_GetScreenSaveActive,
762     loaderdrv_SetScreenSaveActive,
763     /* clipboard functions */
764     loaderdrv_AcquireClipboard,
765     loaderdrv_CountClipboardFormats,
766     loaderdrv_EmptyClipboard,
767     loaderdrv_EndClipboardUpdate,
768     loaderdrv_EnumClipboardFormats,
769     loaderdrv_GetClipboardData,
770     loaderdrv_GetClipboardFormatName,
771     loaderdrv_IsClipboardFormatAvailable,
772     loaderdrv_RegisterClipboardFormat,
773     loaderdrv_SetClipboardData,
774     /* display modes */
775     loaderdrv_ChangeDisplaySettingsEx,
776     loaderdrv_EnumDisplayMonitors,
777     loaderdrv_EnumDisplaySettingsEx,
778     loaderdrv_GetMonitorInfo,
779     /* windowing functions */
780     loaderdrv_CreateDesktopWindow,
781     loaderdrv_CreateWindow,
782     loaderdrv_DestroyWindow,
783     loaderdrv_GetDC,
784     loaderdrv_MsgWaitForMultipleObjectsEx,
785     loaderdrv_ReleaseDC,
786     loaderdrv_ScrollDC,
787     loaderdrv_SetCapture,
788     loaderdrv_SetFocus,
789     loaderdrv_SetParent,
790     loaderdrv_SetWindowPos,
791     loaderdrv_SetWindowRgn,
792     loaderdrv_SetWindowIcon,
793     loaderdrv_SetWindowStyle,
794     loaderdrv_SetWindowText,
795     loaderdrv_SysCommand,
796     loaderdrv_WindowMessage
797 };