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