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