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