wininet: Remove the custom thread pool implementation and use QueueUserWorkItem instead.
[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 const 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     memcpy( driver, &null_driver, sizeof(*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(GetScreenSaveActive);
92         GET_USER_FUNC(SetScreenSaveActive);
93         GET_USER_FUNC(AcquireClipboard);
94         GET_USER_FUNC(EmptyClipboard);
95         GET_USER_FUNC(SetClipboardData);
96         GET_USER_FUNC(GetClipboardData);
97         GET_USER_FUNC(CountClipboardFormats);
98         GET_USER_FUNC(EnumClipboardFormats);
99         GET_USER_FUNC(IsClipboardFormatAvailable);
100         GET_USER_FUNC(RegisterClipboardFormat);
101         GET_USER_FUNC(GetClipboardFormatName);
102         GET_USER_FUNC(EndClipboardUpdate);
103         GET_USER_FUNC(ChangeDisplaySettingsEx);
104         GET_USER_FUNC(EnumDisplayMonitors);
105         GET_USER_FUNC(EnumDisplaySettingsEx);
106         GET_USER_FUNC(GetMonitorInfo);
107         GET_USER_FUNC(CreateDesktopWindow);
108         GET_USER_FUNC(CreateWindow);
109         GET_USER_FUNC(DestroyWindow);
110         GET_USER_FUNC(GetDCEx);
111         GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
112         GET_USER_FUNC(ReleaseDC);
113         GET_USER_FUNC(ScrollDC);
114         GET_USER_FUNC(SetFocus);
115         GET_USER_FUNC(SetParent);
116         GET_USER_FUNC(SetWindowPos);
117         GET_USER_FUNC(SetWindowRgn);
118         GET_USER_FUNC(SetWindowIcon);
119         GET_USER_FUNC(SetWindowStyle);
120         GET_USER_FUNC(SetWindowText);
121         GET_USER_FUNC(ShowWindow);
122         GET_USER_FUNC(SysCommandSizeMove);
123         GET_USER_FUNC(WindowFromDC);
124         GET_USER_FUNC(WindowMessage);
125 #undef GET_USER_FUNC
126     }
127
128     prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, (void *)&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_GetScreenSaveActive(void)
233 {
234     return FALSE;
235 }
236
237 static void nulldrv_SetScreenSaveActive( BOOL on )
238 {
239 }
240
241 static INT nulldrv_AcquireClipboard( HWND hwnd )
242 {
243     return 0;
244 }
245
246 static BOOL nulldrv_CountClipboardFormats(void)
247 {
248     return 0;
249 }
250
251 static void nulldrv_EmptyClipboard( BOOL keepunowned )
252 {
253 }
254
255 static void nulldrv_EndClipboardUpdate(void)
256 {
257 }
258
259 static UINT nulldrv_EnumClipboardFormats( UINT format )
260 {
261     return 0;
262 }
263
264 static BOOL nulldrv_GetClipboardData( UINT format, HANDLE16 *h16, HANDLE *h32 )
265 {
266     return FALSE;
267 }
268
269 static INT nulldrv_GetClipboardFormatName( UINT format, LPWSTR buffer, UINT len )
270 {
271     return FALSE;
272 }
273
274 static BOOL nulldrv_IsClipboardFormatAvailable( UINT format )
275 {
276     return FALSE;
277 }
278
279 static UINT nulldrv_RegisterClipboardFormat( LPCWSTR name )
280 {
281     return 0;
282 }
283
284 static BOOL nulldrv_SetClipboardData( UINT format, HANDLE16 h16, HANDLE h32, BOOL owner )
285 {
286     return FALSE;
287 }
288
289 static LONG nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
290                                              DWORD flags, LPVOID lparam )
291 {
292     return DISP_CHANGE_FAILED;
293 }
294
295 static BOOL nulldrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
296 {
297     return FALSE;
298 }
299
300 static BOOL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
301 {
302     return FALSE;
303 }
304
305 static BOOL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
306 {
307     return FALSE;
308 }
309
310 static BOOL nulldrv_CreateDesktopWindow( HWND hwnd )
311 {
312     return TRUE;
313 }
314
315 static BOOL nulldrv_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
316 {
317     static int warned;
318     if (warned++)
319         return FALSE;
320
321     MESSAGE( "Application tried to create a window, but no driver could be loaded.\n");
322     switch (driver_load_error)
323     {
324     case ERROR_MOD_NOT_FOUND:
325         MESSAGE( "The X11 driver is missing.  Check your build!\n" );
326         break;
327     case ERROR_DLL_INIT_FAILED:
328         MESSAGE( "Make sure that your X server is running and that $DISPLAY is set correctly.\n" );
329         break;
330     default:
331         MESSAGE( "Unknown error (%d).\n", driver_load_error );
332     }
333
334     return FALSE;
335 }
336
337 static void nulldrv_DestroyWindow( HWND hwnd )
338 {
339 }
340
341 static HDC nulldrv_GetDCEx( HWND hwnd, HRGN hrgn, DWORD flags )
342 {
343     return 0;
344 }
345
346 static DWORD nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
347                                                   DWORD mask, DWORD flags )
348 {
349     return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
350                                      timeout, flags & MWMO_ALERTABLE );
351 }
352
353 static INT nulldrv_ReleaseDC( HWND hwnd, HDC hdc, BOOL end_paint )
354 {
355     return 0;
356 }
357
358 static BOOL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
359                               HRGN hrgn, LPRECT update )
360 {
361     return FALSE;
362 }
363
364 static void nulldrv_SetFocus( HWND hwnd )
365 {
366 }
367
368 static void nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
369 {
370 }
371
372 static BOOL nulldrv_SetWindowPos( HWND hwnd, HWND insert_after, const RECT *rectWindow,
373                                   const RECT *rectClient, UINT swp_flags, const RECT *valid_rects )
374 {
375     return FALSE;
376 }
377
378 static int nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
379 {
380     return 1;
381 }
382
383 static void nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
384 {
385 }
386
387 static void nulldrv_SetWindowStyle( HWND hwnd, DWORD old_style )
388 {
389 }
390
391 static void nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
392 {
393 }
394
395 static BOOL nulldrv_ShowWindow( HWND hwnd, INT cmd )
396 {
397     return FALSE;
398 }
399
400 static void nulldrv_SysCommandSizeMove( HWND hwnd, WPARAM wparam )
401 {
402 }
403
404 static HWND nulldrv_WindowFromDC( HDC hdc )
405 {
406     return 0;
407 }
408
409 static LRESULT nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
410 {
411     return 0;
412 }
413
414 static const USER_DRIVER null_driver =
415 {
416     /* keyboard functions */
417     nulldrv_ActivateKeyboardLayout,
418     nulldrv_Beep,
419     nulldrv_GetAsyncKeyState,
420     nulldrv_GetKeyNameText,
421     nulldrv_GetKeyboardLayout,
422     nulldrv_GetKeyboardLayoutList,
423     nulldrv_GetKeyboardLayoutName,
424     nulldrv_LoadKeyboardLayout,
425     nulldrv_MapVirtualKeyEx,
426     nulldrv_SendInput,
427     nulldrv_ToUnicodeEx,
428     nulldrv_UnloadKeyboardLayout,
429     nulldrv_VkKeyScanEx,
430     /* mouse functions */
431     nulldrv_SetCursor,
432     nulldrv_GetCursorPos,
433     nulldrv_SetCursorPos,
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_GetDCEx,
458     nulldrv_MsgWaitForMultipleObjectsEx,
459     nulldrv_ReleaseDC,
460     nulldrv_ScrollDC,
461     nulldrv_SetFocus,
462     nulldrv_SetParent,
463     nulldrv_SetWindowPos,
464     nulldrv_SetWindowRgn,
465     nulldrv_SetWindowIcon,
466     nulldrv_SetWindowStyle,
467     nulldrv_SetWindowText,
468     nulldrv_ShowWindow,
469     nulldrv_SysCommandSizeMove,
470     nulldrv_WindowFromDC,
471     nulldrv_WindowMessage
472 };
473
474
475 /**********************************************************************
476  * Lazy loading user driver
477  *
478  * Initial driver used before another driver is loaded.
479  * Each entry point simply loads the real driver and chains to it.
480  */
481
482 static HKL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
483 {
484     return load_driver()->pActivateKeyboardLayout( layout, flags );
485 }
486
487 static void loaderdrv_Beep(void)
488 {
489     load_driver()->pBeep();
490 }
491
492 static SHORT loaderdrv_GetAsyncKeyState( INT key )
493 {
494     return load_driver()->pGetAsyncKeyState( key );
495 }
496
497 static INT loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
498 {
499     return load_driver()->pGetKeyNameText( lparam, buffer, size );
500 }
501
502 static HKL loaderdrv_GetKeyboardLayout( DWORD layout )
503 {
504     return load_driver()->pGetKeyboardLayout( layout );
505 }
506
507 static UINT loaderdrv_GetKeyboardLayoutList( INT count, HKL *layouts )
508 {
509     return load_driver()->pGetKeyboardLayoutList( count, layouts );
510 }
511
512 static BOOL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
513 {
514     return load_driver()->pGetKeyboardLayoutName( name );
515 }
516
517 static HKL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
518 {
519     return load_driver()->pLoadKeyboardLayout( name, flags );
520 }
521
522 static UINT loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
523 {
524     return load_driver()->pMapVirtualKeyEx( code, type, layout );
525 }
526
527 static UINT loaderdrv_SendInput( UINT count, LPINPUT inputs, int size )
528 {
529     return load_driver()->pSendInput( count, inputs, size );
530 }
531
532 static INT loaderdrv_ToUnicodeEx( UINT virt, UINT scan, LPBYTE state, LPWSTR str,
533                                   int size, UINT flags, HKL layout )
534 {
535     return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
536 }
537
538 static BOOL loaderdrv_UnloadKeyboardLayout( HKL layout )
539 {
540     return load_driver()->pUnloadKeyboardLayout( layout );
541 }
542
543 static SHORT loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
544 {
545     return load_driver()->pVkKeyScanEx( ch, layout );
546 }
547
548 static void loaderdrv_SetCursor( struct tagCURSORICONINFO *info )
549 {
550     load_driver()->pSetCursor( info );
551 }
552
553 static BOOL loaderdrv_GetCursorPos( LPPOINT pt )
554 {
555     return load_driver()->pGetCursorPos( pt );
556 }
557
558 static BOOL loaderdrv_SetCursorPos( INT x, INT y )
559 {
560     return load_driver()->pSetCursorPos( x, y );
561 }
562
563 static BOOL loaderdrv_GetScreenSaveActive(void)
564 {
565     return load_driver()->pGetScreenSaveActive();
566 }
567
568 static void loaderdrv_SetScreenSaveActive( BOOL on )
569 {
570     load_driver()->pSetScreenSaveActive( on );
571 }
572
573 static INT loaderdrv_AcquireClipboard( HWND hwnd )
574 {
575     return load_driver()->pAcquireClipboard( hwnd );
576 }
577
578 static BOOL loaderdrv_CountClipboardFormats(void)
579 {
580     return load_driver()->pCountClipboardFormats();
581 }
582
583 static void loaderdrv_EmptyClipboard( BOOL keepunowned )
584 {
585     load_driver()->pEmptyClipboard( keepunowned );
586 }
587
588 static void loaderdrv_EndClipboardUpdate(void)
589 {
590     load_driver()->pEndClipboardUpdate();
591 }
592
593 static UINT loaderdrv_EnumClipboardFormats( UINT format )
594 {
595     return load_driver()->pEnumClipboardFormats( format );
596 }
597
598 static BOOL loaderdrv_GetClipboardData( UINT format, HANDLE16 *h16, HANDLE *h32 )
599 {
600     return load_driver()->pGetClipboardData( format, h16, h32 );
601 }
602
603 static INT loaderdrv_GetClipboardFormatName( UINT format, LPWSTR buffer, UINT len )
604 {
605     return load_driver()->pGetClipboardFormatName( format, buffer, len );
606 }
607
608 static BOOL loaderdrv_IsClipboardFormatAvailable( UINT format )
609 {
610     return load_driver()->pIsClipboardFormatAvailable( format );
611 }
612
613 static UINT loaderdrv_RegisterClipboardFormat( LPCWSTR name )
614 {
615     return load_driver()->pRegisterClipboardFormat( name );
616 }
617
618 static BOOL loaderdrv_SetClipboardData( UINT format, HANDLE16 h16, HANDLE h32, BOOL owner )
619 {
620     return load_driver()->pSetClipboardData( format, h16, h32, owner );
621 }
622
623 static LONG loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
624                                                DWORD flags, LPVOID lparam )
625 {
626     return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
627 }
628
629 static BOOL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
630 {
631     return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
632 }
633
634 static BOOL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
635 {
636     return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
637 }
638
639 static BOOL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
640 {
641     return load_driver()->pGetMonitorInfo( handle, info );
642 }
643
644 static BOOL loaderdrv_CreateDesktopWindow( HWND hwnd )
645 {
646     return load_driver()->pCreateDesktopWindow( hwnd );
647 }
648
649 static BOOL loaderdrv_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
650 {
651     return load_driver()->pCreateWindow( hwnd, cs, unicode );
652 }
653
654 static void loaderdrv_DestroyWindow( HWND hwnd )
655 {
656     load_driver()->pDestroyWindow( hwnd );
657 }
658
659 static HDC loaderdrv_GetDCEx( HWND hwnd, HRGN hrgn, DWORD flags )
660 {
661     return load_driver()->pGetDCEx( hwnd, hrgn, flags );
662 }
663
664 static DWORD loaderdrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
665                                                     DWORD mask, DWORD flags )
666 {
667     return load_driver()->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
668 }
669
670 static INT loaderdrv_ReleaseDC( HWND hwnd, HDC hdc, BOOL end_paint )
671 {
672     return load_driver()->pReleaseDC( hwnd, hdc, end_paint );
673 }
674
675 static BOOL loaderdrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
676                                 HRGN hrgn, LPRECT update )
677 {
678     return load_driver()->pScrollDC( hdc, dx, dy, scroll, clip, hrgn, update );
679 }
680
681 static void loaderdrv_SetFocus( HWND hwnd )
682 {
683     load_driver()->pSetFocus( hwnd );
684 }
685
686 static void loaderdrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
687 {
688     load_driver()->pSetParent( hwnd, parent, old_parent );
689 }
690
691 static BOOL loaderdrv_SetWindowPos( HWND hwnd, HWND insert_after, const RECT *rectWindow,
692                                     const RECT *rectClient, UINT swp_flags, const RECT *valid_rects )
693 {
694     return load_driver()->pSetWindowPos( hwnd, insert_after, rectWindow, rectClient, swp_flags, valid_rects );
695 }
696
697 static int loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
698 {
699     return load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
700 }
701
702 static void loaderdrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
703 {
704     load_driver()->pSetWindowIcon( hwnd, type, icon );
705 }
706
707 static void loaderdrv_SetWindowStyle( HWND hwnd, DWORD old_style )
708 {
709     load_driver()->pSetWindowStyle( hwnd, old_style );
710 }
711
712 static void loaderdrv_SetWindowText( HWND hwnd, LPCWSTR text )
713 {
714     load_driver()->pSetWindowText( hwnd, text );
715 }
716
717 static BOOL loaderdrv_ShowWindow( HWND hwnd, INT cmd )
718 {
719     return load_driver()->pShowWindow( hwnd, cmd );
720 }
721
722 static void loaderdrv_SysCommandSizeMove( HWND hwnd, WPARAM wparam )
723 {
724     load_driver()->pSysCommandSizeMove( hwnd, wparam );
725 }
726
727 static HWND loaderdrv_WindowFromDC( HDC hdc )
728 {
729     return load_driver()->pWindowFromDC( hdc );
730 }
731
732 static LRESULT loaderdrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
733 {
734     return load_driver()->pWindowMessage( hwnd, msg, wparam, lparam );
735 }
736
737 static const USER_DRIVER lazy_load_driver =
738 {
739     /* keyboard functions */
740     loaderdrv_ActivateKeyboardLayout,
741     loaderdrv_Beep,
742     loaderdrv_GetAsyncKeyState,
743     loaderdrv_GetKeyNameText,
744     loaderdrv_GetKeyboardLayout,
745     loaderdrv_GetKeyboardLayoutList,
746     loaderdrv_GetKeyboardLayoutName,
747     loaderdrv_LoadKeyboardLayout,
748     loaderdrv_MapVirtualKeyEx,
749     loaderdrv_SendInput,
750     loaderdrv_ToUnicodeEx,
751     loaderdrv_UnloadKeyboardLayout,
752     loaderdrv_VkKeyScanEx,
753     /* mouse functions */
754     loaderdrv_SetCursor,
755     loaderdrv_GetCursorPos,
756     loaderdrv_SetCursorPos,
757     /* screen saver functions */
758     loaderdrv_GetScreenSaveActive,
759     loaderdrv_SetScreenSaveActive,
760     /* clipboard functions */
761     loaderdrv_AcquireClipboard,
762     loaderdrv_CountClipboardFormats,
763     loaderdrv_EmptyClipboard,
764     loaderdrv_EndClipboardUpdate,
765     loaderdrv_EnumClipboardFormats,
766     loaderdrv_GetClipboardData,
767     loaderdrv_GetClipboardFormatName,
768     loaderdrv_IsClipboardFormatAvailable,
769     loaderdrv_RegisterClipboardFormat,
770     loaderdrv_SetClipboardData,
771     /* display modes */
772     loaderdrv_ChangeDisplaySettingsEx,
773     loaderdrv_EnumDisplayMonitors,
774     loaderdrv_EnumDisplaySettingsEx,
775     loaderdrv_GetMonitorInfo,
776     /* windowing functions */
777     loaderdrv_CreateDesktopWindow,
778     loaderdrv_CreateWindow,
779     loaderdrv_DestroyWindow,
780     loaderdrv_GetDCEx,
781     loaderdrv_MsgWaitForMultipleObjectsEx,
782     loaderdrv_ReleaseDC,
783     loaderdrv_ScrollDC,
784     loaderdrv_SetFocus,
785     loaderdrv_SetParent,
786     loaderdrv_SetWindowPos,
787     loaderdrv_SetWindowRgn,
788     loaderdrv_SetWindowIcon,
789     loaderdrv_SetWindowStyle,
790     loaderdrv_SetWindowText,
791     loaderdrv_ShowWindow,
792     loaderdrv_SysCommandSizeMove,
793     loaderdrv_WindowFromDC,
794     loaderdrv_WindowMessage
795 };