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