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