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