msvcrt: Simplify fseek 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
303     /* HWND_MESSAGE windows don't need a graphics driver */
304     if (GetAncestor( hwnd, GA_PARENT ) == get_user_thread_info()->msg_window) return TRUE;
305     if (warned++) return FALSE;
306
307     MESSAGE( "Application tried to create a window, but no driver could be loaded.\n");
308     switch (driver_load_error)
309     {
310     case ERROR_MOD_NOT_FOUND:
311         MESSAGE( "The graphics driver is missing. Check your build!\n" );
312         break;
313     case ERROR_DLL_INIT_FAILED:
314         MESSAGE( "Make sure that your X server is running and that $DISPLAY is set correctly.\n" );
315         break;
316     default:
317         MESSAGE( "Unknown error (%d).\n", driver_load_error );
318     }
319
320     return FALSE;
321 }
322
323 static void CDECL nulldrv_DestroyWindow( HWND hwnd )
324 {
325 }
326
327 static void CDECL nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
328                                  const RECT *top_rect, DWORD flags )
329 {
330 }
331
332 static DWORD CDECL nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
333                                                         DWORD mask, DWORD flags )
334 {
335     return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
336                                      timeout, flags & MWMO_ALERTABLE );
337 }
338
339 static void CDECL nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
340 {
341 }
342
343 static BOOL CDECL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
344                                     HRGN hrgn, LPRECT update )
345 {
346     return FALSE;
347 }
348
349 static void CDECL nulldrv_SetCapture( HWND hwnd, UINT flags )
350 {
351 }
352
353 static void CDECL nulldrv_SetFocus( HWND hwnd )
354 {
355 }
356
357 static void CDECL nulldrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
358 {
359 }
360
361 static void CDECL nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
362 {
363 }
364
365 static int CDECL nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
366 {
367     return 1;
368 }
369
370 static void CDECL nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
371 {
372 }
373
374 static void CDECL nulldrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
375 {
376 }
377
378 static void CDECL nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
379 {
380 }
381
382 static UINT CDECL nulldrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
383 {
384     return swp;
385 }
386
387 static LRESULT CDECL nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
388 {
389     return -1;
390 }
391
392 static BOOL CDECL nulldrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
393                                                const RECT *window_rect )
394 {
395     return TRUE;
396 }
397
398 static LRESULT CDECL nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
399 {
400     return 0;
401 }
402
403 static void CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
404                                              const RECT *window_rect, const RECT *client_rect,
405                                              RECT *visible_rect, struct window_surface **surface )
406 {
407 }
408
409 static void CDECL nulldrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
410                                             const RECT *window_rect, const RECT *client_rect,
411                                             const RECT *visible_rect, const RECT *valid_rects,
412                                             struct window_surface *surface )
413 {
414 }
415
416 static BOOL CDECL nulldrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
417 {
418     return FALSE;
419 }
420
421 static USER_DRIVER null_driver =
422 {
423     /* keyboard functions */
424     nulldrv_ActivateKeyboardLayout,
425     nulldrv_Beep,
426     nulldrv_GetAsyncKeyState,
427     nulldrv_GetKeyNameText,
428     nulldrv_GetKeyboardLayout,
429     nulldrv_GetKeyboardLayoutName,
430     nulldrv_LoadKeyboardLayout,
431     nulldrv_MapVirtualKeyEx,
432     nulldrv_RegisterHotKey,
433     nulldrv_ToUnicodeEx,
434     nulldrv_UnloadKeyboardLayout,
435     nulldrv_UnregisterHotKey,
436     nulldrv_VkKeyScanEx,
437     /* cursor/icon functions */
438     nulldrv_CreateCursorIcon,
439     nulldrv_DestroyCursorIcon,
440     nulldrv_SetCursor,
441     nulldrv_GetCursorPos,
442     nulldrv_SetCursorPos,
443     nulldrv_ClipCursor,
444     /* clipboard functions */
445     nulldrv_AcquireClipboard,
446     nulldrv_CountClipboardFormats,
447     nulldrv_EmptyClipboard,
448     nulldrv_EndClipboardUpdate,
449     nulldrv_EnumClipboardFormats,
450     nulldrv_GetClipboardData,
451     nulldrv_IsClipboardFormatAvailable,
452     nulldrv_SetClipboardData,
453     /* display modes */
454     nulldrv_ChangeDisplaySettingsEx,
455     nulldrv_EnumDisplayMonitors,
456     nulldrv_EnumDisplaySettingsEx,
457     nulldrv_GetMonitorInfo,
458     /* windowing functions */
459     nulldrv_CreateDesktopWindow,
460     nulldrv_CreateWindow,
461     nulldrv_DestroyWindow,
462     nulldrv_GetDC,
463     nulldrv_MsgWaitForMultipleObjectsEx,
464     nulldrv_ReleaseDC,
465     nulldrv_ScrollDC,
466     nulldrv_SetCapture,
467     nulldrv_SetFocus,
468     nulldrv_SetLayeredWindowAttributes,
469     nulldrv_SetParent,
470     nulldrv_SetWindowRgn,
471     nulldrv_SetWindowIcon,
472     nulldrv_SetWindowStyle,
473     nulldrv_SetWindowText,
474     nulldrv_ShowWindow,
475     nulldrv_SysCommand,
476     nulldrv_UpdateLayeredWindow,
477     nulldrv_WindowMessage,
478     nulldrv_WindowPosChanging,
479     nulldrv_WindowPosChanged,
480     /* system parameters */
481     nulldrv_SystemParametersInfo
482 };
483
484
485 /**********************************************************************
486  * Lazy loading user driver
487  *
488  * Initial driver used before another driver is loaded.
489  * Each entry point simply loads the real driver and chains to it.
490  */
491
492 static HKL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
493 {
494     return load_driver()->pActivateKeyboardLayout( layout, flags );
495 }
496
497 static void CDECL loaderdrv_Beep(void)
498 {
499     load_driver()->pBeep();
500 }
501
502 static SHORT CDECL loaderdrv_GetAsyncKeyState( INT key )
503 {
504     return load_driver()->pGetAsyncKeyState( key );
505 }
506
507 static INT CDECL loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
508 {
509     return load_driver()->pGetKeyNameText( lparam, buffer, size );
510 }
511
512 static HKL CDECL loaderdrv_GetKeyboardLayout( DWORD thread_id )
513 {
514     return load_driver()->pGetKeyboardLayout( thread_id );
515 }
516
517 static BOOL CDECL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
518 {
519     return load_driver()->pGetKeyboardLayoutName( name );
520 }
521
522 static HKL CDECL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
523 {
524     return load_driver()->pLoadKeyboardLayout( name, flags );
525 }
526
527 static UINT CDECL loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
528 {
529     return load_driver()->pMapVirtualKeyEx( code, type, layout );
530 }
531
532 static BOOL CDECL loaderdrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
533 {
534     return load_driver()->pRegisterHotKey( hwnd, modifiers, vk );
535 }
536
537 static INT CDECL loaderdrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
538                                   int size, UINT flags, HKL layout )
539 {
540     return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
541 }
542
543 static BOOL CDECL loaderdrv_UnloadKeyboardLayout( HKL layout )
544 {
545     return load_driver()->pUnloadKeyboardLayout( layout );
546 }
547
548 static void CDECL loaderdrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
549 {
550     load_driver()->pUnregisterHotKey( hwnd, modifiers, vk );
551 }
552
553 static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
554 {
555     return load_driver()->pVkKeyScanEx( ch, layout );
556 }
557
558 static void CDECL loaderdrv_CreateCursorIcon( HCURSOR cursor )
559 {
560     load_driver()->pCreateCursorIcon( cursor );
561 }
562
563 static void CDECL loaderdrv_DestroyCursorIcon( HCURSOR cursor )
564 {
565     load_driver()->pDestroyCursorIcon( cursor );
566 }
567
568 static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
569 {
570     load_driver()->pSetCursor( cursor );
571 }
572
573 static BOOL CDECL loaderdrv_GetCursorPos( LPPOINT pt )
574 {
575     return load_driver()->pGetCursorPos( pt );
576 }
577
578 static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
579 {
580     return load_driver()->pSetCursorPos( x, y );
581 }
582
583 static BOOL CDECL loaderdrv_ClipCursor( LPCRECT clip )
584 {
585     return load_driver()->pClipCursor( clip );
586 }
587
588 static INT CDECL loaderdrv_AcquireClipboard( HWND hwnd )
589 {
590     return load_driver()->pAcquireClipboard( hwnd );
591 }
592
593 static BOOL CDECL loaderdrv_CountClipboardFormats(void)
594 {
595     return load_driver()->pCountClipboardFormats();
596 }
597
598 static void CDECL loaderdrv_EmptyClipboard( BOOL keepunowned )
599 {
600     load_driver()->pEmptyClipboard( keepunowned );
601 }
602
603 static void CDECL loaderdrv_EndClipboardUpdate(void)
604 {
605     load_driver()->pEndClipboardUpdate();
606 }
607
608 static UINT CDECL loaderdrv_EnumClipboardFormats( UINT format )
609 {
610     return load_driver()->pEnumClipboardFormats( format );
611 }
612
613 static HANDLE CDECL loaderdrv_GetClipboardData( UINT format )
614 {
615     return load_driver()->pGetClipboardData( format );
616 }
617
618 static BOOL CDECL loaderdrv_IsClipboardFormatAvailable( UINT format )
619 {
620     return load_driver()->pIsClipboardFormatAvailable( format );
621 }
622
623 static BOOL CDECL loaderdrv_SetClipboardData( UINT format, HANDLE handle, BOOL owner )
624 {
625     return load_driver()->pSetClipboardData( format, handle, owner );
626 }
627
628 static LONG CDECL loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
629                                                      DWORD flags, LPVOID lparam )
630 {
631     return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
632 }
633
634 static BOOL CDECL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
635 {
636     return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
637 }
638
639 static BOOL CDECL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
640 {
641     return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
642 }
643
644 static BOOL CDECL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
645 {
646     return load_driver()->pGetMonitorInfo( handle, info );
647 }
648
649 static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
650 {
651     return load_driver()->pCreateDesktopWindow( hwnd );
652 }
653
654 static BOOL CDECL loaderdrv_CreateWindow( HWND hwnd )
655 {
656     return load_driver()->pCreateWindow( hwnd );
657 }
658
659 static void CDECL loaderdrv_DestroyWindow( HWND hwnd )
660 {
661     load_driver()->pDestroyWindow( hwnd );
662 }
663
664 static void CDECL loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
665                                    const RECT *top_rect, DWORD flags )
666 {
667     load_driver()->pGetDC( hdc, hwnd, top_win, win_rect, top_rect, flags );
668 }
669
670 static DWORD CDECL loaderdrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
671                                                           DWORD mask, DWORD flags )
672 {
673     return load_driver()->pMsgWaitForMultipleObjectsEx( count, handles, timeout, mask, flags );
674 }
675
676 static void CDECL loaderdrv_ReleaseDC( HWND hwnd, HDC hdc )
677 {
678     load_driver()->pReleaseDC( hwnd, hdc );
679 }
680
681 static BOOL CDECL loaderdrv_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *scroll, const RECT *clip,
682                                       HRGN hrgn, LPRECT update )
683 {
684     return load_driver()->pScrollDC( hdc, dx, dy, scroll, clip, hrgn, update );
685 }
686
687 static void CDECL loaderdrv_SetCapture( HWND hwnd, UINT flags )
688 {
689     load_driver()->pSetCapture( hwnd, flags );
690 }
691
692 static void CDECL loaderdrv_SetFocus( HWND hwnd )
693 {
694     load_driver()->pSetFocus( hwnd );
695 }
696
697 static void CDECL loaderdrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
698 {
699     load_driver()->pSetLayeredWindowAttributes( hwnd, key, alpha, flags );
700 }
701
702 static void CDECL loaderdrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
703 {
704     load_driver()->pSetParent( hwnd, parent, old_parent );
705 }
706
707 static int CDECL loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
708 {
709     return load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
710 }
711
712 static void CDECL loaderdrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
713 {
714     load_driver()->pSetWindowIcon( hwnd, type, icon );
715 }
716
717 static void CDECL loaderdrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
718 {
719     load_driver()->pSetWindowStyle( hwnd, offset, style );
720 }
721
722 static void CDECL loaderdrv_SetWindowText( HWND hwnd, LPCWSTR text )
723 {
724     load_driver()->pSetWindowText( hwnd, text );
725 }
726
727 static UINT CDECL loaderdrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
728 {
729     return load_driver()->pShowWindow( hwnd, cmd, rect, swp );
730 }
731
732 static LRESULT CDECL loaderdrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
733 {
734     return load_driver()->pSysCommand( hwnd, wparam, lparam );
735 }
736
737 static BOOL CDECL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
738                                                  const RECT *window_rect )
739 {
740     return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
741 }
742
743 static LRESULT CDECL loaderdrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
744 {
745     return load_driver()->pWindowMessage( hwnd, msg, wparam, lparam );
746 }
747
748 static void CDECL loaderdrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
749                                                const RECT *window_rect, const RECT *client_rect,
750                                                RECT *visible_rect, struct window_surface **surface )
751 {
752     load_driver()->pWindowPosChanging( hwnd, insert_after, swp_flags,
753                                        window_rect, client_rect, visible_rect, surface );
754 }
755
756 static void CDECL loaderdrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
757                                               const RECT *window_rect, const RECT *client_rect,
758                                               const RECT *visible_rect, const RECT *valid_rects,
759                                               struct window_surface *surface )
760 {
761     load_driver()->pWindowPosChanged( hwnd, insert_after, swp_flags, window_rect,
762                                       client_rect, visible_rect, valid_rects, surface );
763 }
764
765 static BOOL CDECL loaderdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
766 {
767     return FALSE;  /* don't trigger a driver load */
768 }
769
770 static USER_DRIVER lazy_load_driver =
771 {
772     /* keyboard functions */
773     loaderdrv_ActivateKeyboardLayout,
774     loaderdrv_Beep,
775     loaderdrv_GetAsyncKeyState,
776     loaderdrv_GetKeyNameText,
777     loaderdrv_GetKeyboardLayout,
778     loaderdrv_GetKeyboardLayoutName,
779     loaderdrv_LoadKeyboardLayout,
780     loaderdrv_MapVirtualKeyEx,
781     loaderdrv_RegisterHotKey,
782     loaderdrv_ToUnicodeEx,
783     loaderdrv_UnloadKeyboardLayout,
784     loaderdrv_UnregisterHotKey,
785     loaderdrv_VkKeyScanEx,
786     /* cursor/icon functions */
787     loaderdrv_CreateCursorIcon,
788     loaderdrv_DestroyCursorIcon,
789     loaderdrv_SetCursor,
790     loaderdrv_GetCursorPos,
791     loaderdrv_SetCursorPos,
792     loaderdrv_ClipCursor,
793     /* clipboard functions */
794     loaderdrv_AcquireClipboard,
795     loaderdrv_CountClipboardFormats,
796     loaderdrv_EmptyClipboard,
797     loaderdrv_EndClipboardUpdate,
798     loaderdrv_EnumClipboardFormats,
799     loaderdrv_GetClipboardData,
800     loaderdrv_IsClipboardFormatAvailable,
801     loaderdrv_SetClipboardData,
802     /* display modes */
803     loaderdrv_ChangeDisplaySettingsEx,
804     loaderdrv_EnumDisplayMonitors,
805     loaderdrv_EnumDisplaySettingsEx,
806     loaderdrv_GetMonitorInfo,
807     /* windowing functions */
808     loaderdrv_CreateDesktopWindow,
809     loaderdrv_CreateWindow,
810     loaderdrv_DestroyWindow,
811     loaderdrv_GetDC,
812     loaderdrv_MsgWaitForMultipleObjectsEx,
813     loaderdrv_ReleaseDC,
814     loaderdrv_ScrollDC,
815     loaderdrv_SetCapture,
816     loaderdrv_SetFocus,
817     loaderdrv_SetLayeredWindowAttributes,
818     loaderdrv_SetParent,
819     loaderdrv_SetWindowRgn,
820     loaderdrv_SetWindowIcon,
821     loaderdrv_SetWindowStyle,
822     loaderdrv_SetWindowText,
823     loaderdrv_ShowWindow,
824     loaderdrv_SysCommand,
825     loaderdrv_UpdateLayeredWindow,
826     loaderdrv_WindowMessage,
827     loaderdrv_WindowPosChanging,
828     loaderdrv_WindowPosChanged,
829     /* system parameters */
830     loaderdrv_SystemParametersInfo
831 };