driver.c 22.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * USER driver support
 *
 * Copyright 2000, 2005 Alexandre Julliard
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 22 23 24
 */

#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
25
#include "wingdi.h"
26 27
#include "winuser.h"
#include "wine/debug.h"
28
#include "wine/gdi_driver.h"
29
#include "wine/unicode.h"
30

31
#include "user_private.h"
32
#include "controls.h"
33

34
WINE_DEFAULT_DEBUG_CHANNEL(user);
35
WINE_DECLARE_DEBUG_CHANNEL(winediag);
36

37
static USER_DRIVER null_driver, lazy_load_driver;
38 39

const USER_DRIVER *USER_Driver = &lazy_load_driver;
40 41
static char driver_load_error[80];

42 43
static BOOL CDECL nodrv_CreateWindow( HWND hwnd );

44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
static HMODULE load_desktop_driver( HWND hwnd )
{
    static const WCHAR display_device_guid_propW[] = {
        '_','_','w','i','n','e','_','d','i','s','p','l','a','y','_',
        'd','e','v','i','c','e','_','g','u','i','d',0 };
    static const WCHAR key_pathW[] = {
        'S','y','s','t','e','m','\\',
        'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
        'C','o','n','t','r','o','l','\\',
        'V','i','d','e','o','\\','{',0};
    static const WCHAR displayW[] = {'}','\\','0','0','0','0',0};
    static const WCHAR driverW[] = {'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0};
    HMODULE ret = 0;
    HKEY hkey;
    DWORD size;
    WCHAR path[MAX_PATH];
60
    WCHAR key[ARRAY_SIZE(key_pathW) + ARRAY_SIZE(displayW) + 40];
61 62
    UINT guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));

63 64
    USER_CheckNotLock();

65 66
    strcpy( driver_load_error, "The explorer process failed to start." );  /* default error */

67 68 69 70 71
    if (!guid_atom)
    {
        SendMessageW( hwnd, WM_NULL, 0, 0 );  /* wait for the desktop process to be ready */
        guid_atom = HandleToULong( GetPropW( hwnd, display_device_guid_propW ));
    }
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
    memcpy( key, key_pathW, sizeof(key_pathW) );
    if (!GlobalGetAtomNameW( guid_atom, key + strlenW(key), 40 )) return 0;
    strcatW( key, displayW );
    if (RegOpenKeyW( HKEY_LOCAL_MACHINE, key, &hkey )) return 0;
    size = sizeof(path);
    if (!RegQueryValueExW( hkey, driverW, NULL, NULL, (BYTE *)path, &size ))
    {
        if (!(ret = LoadLibraryW( path ))) ERR( "failed to load %s\n", debugstr_w(path) );
        TRACE( "%s %p\n", debugstr_w(path), ret );
    }
    else
    {
        size = sizeof(driver_load_error);
        RegQueryValueExA( hkey, "DriverError", NULL, NULL, (BYTE *)driver_load_error, &size );
    }
    RegCloseKey( hkey );
    return ret;
}
90 91 92 93 94 95 96 97 98

/* load the graphics driver */
static const USER_DRIVER *load_driver(void)
{
    void *ptr;
    HMODULE graphics_driver;
    USER_DRIVER *driver, *prev;

    driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) );
99
    *driver = null_driver;
100

101
    graphics_driver = load_desktop_driver( GetDesktopWindow() );
102 103
    if (graphics_driver)
    {
104 105 106
#define GET_USER_FUNC(name) \
    do { if ((ptr = GetProcAddress( graphics_driver, #name ))) driver->p##name = ptr; } while(0)

107 108 109 110 111
        GET_USER_FUNC(ActivateKeyboardLayout);
        GET_USER_FUNC(Beep);
        GET_USER_FUNC(GetAsyncKeyState);
        GET_USER_FUNC(GetKeyNameText);
        GET_USER_FUNC(GetKeyboardLayout);
112
        GET_USER_FUNC(GetKeyboardLayoutList);
113 114 115
        GET_USER_FUNC(GetKeyboardLayoutName);
        GET_USER_FUNC(LoadKeyboardLayout);
        GET_USER_FUNC(MapVirtualKeyEx);
116
        GET_USER_FUNC(RegisterHotKey);
117 118
        GET_USER_FUNC(ToUnicodeEx);
        GET_USER_FUNC(UnloadKeyboardLayout);
119
        GET_USER_FUNC(UnregisterHotKey);
120
        GET_USER_FUNC(VkKeyScanEx);
121
        GET_USER_FUNC(DestroyCursorIcon);
122 123 124
        GET_USER_FUNC(SetCursor);
        GET_USER_FUNC(GetCursorPos);
        GET_USER_FUNC(SetCursorPos);
125
        GET_USER_FUNC(ClipCursor);
126
        GET_USER_FUNC(UpdateClipboard);
127
        GET_USER_FUNC(ChangeDisplaySettingsEx);
128
        GET_USER_FUNC(EnumDisplayMonitors);
129
        GET_USER_FUNC(EnumDisplaySettingsEx);
130
        GET_USER_FUNC(GetMonitorInfo);
131 132 133
        GET_USER_FUNC(CreateDesktopWindow);
        GET_USER_FUNC(CreateWindow);
        GET_USER_FUNC(DestroyWindow);
134
        GET_USER_FUNC(FlashWindowEx);
135
        GET_USER_FUNC(GetDC);
136 137 138
        GET_USER_FUNC(MsgWaitForMultipleObjectsEx);
        GET_USER_FUNC(ReleaseDC);
        GET_USER_FUNC(ScrollDC);
139
        GET_USER_FUNC(SetCapture);
140
        GET_USER_FUNC(SetFocus);
141
        GET_USER_FUNC(SetLayeredWindowAttributes);
142 143 144 145 146
        GET_USER_FUNC(SetParent);
        GET_USER_FUNC(SetWindowRgn);
        GET_USER_FUNC(SetWindowIcon);
        GET_USER_FUNC(SetWindowStyle);
        GET_USER_FUNC(SetWindowText);
147
        GET_USER_FUNC(ShowWindow);
148
        GET_USER_FUNC(SysCommand);
149
        GET_USER_FUNC(UpdateLayeredWindow);
150
        GET_USER_FUNC(WindowMessage);
151 152
        GET_USER_FUNC(WindowPosChanging);
        GET_USER_FUNC(WindowPosChanged);
153
        GET_USER_FUNC(SystemParametersInfo);
154
        GET_USER_FUNC(ThreadDetach);
155
#undef GET_USER_FUNC
156
    }
157 158 159 160 161 162 163 164 165 166
    else
    {
        USEROBJECTFLAGS flags;
        HWINSTA winstation;

        winstation = GetProcessWindowStation();
        if (!GetUserObjectInformationA(winstation, UOI_FLAGS, &flags, sizeof(flags), NULL)
            || (flags.dwFlags & WSF_VISIBLE))
            driver->pCreateWindow = nodrv_CreateWindow;
    }
167

168
    prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver );
169 170 171 172 173 174
    if (prev != &lazy_load_driver)
    {
        /* another thread beat us to it */
        HeapFree( GetProcessHeap(), 0, driver );
        driver = prev;
    }
175 176
    else LdrAddRefDll( 0, graphics_driver );

177
    __wine_set_display_driver( graphics_driver );
178 179
    register_builtin_classes();

180 181 182
    return driver;
}

183 184 185
/* unload the graphics driver on process exit */
void USER_unload_driver(void)
{
186
    USER_DRIVER *prev;
187
    /* make sure we don't try to call the driver after it has been detached */
188 189 190
    prev = InterlockedExchangePointer( (void **)&USER_Driver, &null_driver );
    if (prev != &lazy_load_driver && prev != &null_driver)
        HeapFree( GetProcessHeap(), 0, prev );
191 192
}

193 194 195 196 197 198 199

/**********************************************************************
 * Null user driver
 *
 * These are fallbacks for entry points that are not implemented in the real driver.
 */

200 201
#define NULLDRV_DEFAULT_HMONITOR ((HMONITOR)(UINT_PTR)(0x10000 + 1))

202
static HKL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags )
203 204 205 206
{
    return 0;
}

207
static void CDECL nulldrv_Beep(void)
208 209 210
{
}

211
static SHORT CDECL nulldrv_GetAsyncKeyState( INT key )
212
{
213
    return -1;
214 215
}

216 217 218 219 220 221 222 223 224 225 226 227
static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
    HKEY hKeyKeyboard;
    DWORD rc;
    INT count = 0;
    ULONG_PTR baselayout;
    LANGID langid;
    static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};

    baselayout = GetUserDefaultLCID();
    langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
    if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
228
        baselayout = MAKELONG( baselayout, 0xe001 ); /* IME */
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
    else
        baselayout |= baselayout << 16;

    /* Enumerate the Registry */
    rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
    if (rc == ERROR_SUCCESS)
    {
        do {
            WCHAR szKeyName[9];
            HKL layout;
            rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
            if (rc == ERROR_SUCCESS)
            {
                layout = (HKL)(ULONG_PTR)strtoulW(szKeyName,NULL,16);
                if (baselayout != 0 && layout == (HKL)baselayout)
                    baselayout = 0; /* found in the registry do not add again */
                if (size && layouts)
                {
                    if (count >= size ) break;
                    layouts[count] = layout;
                }
                count ++;
            }
        } while (rc == ERROR_SUCCESS);
        RegCloseKey(hKeyKeyboard);
    }

    /* make sure our base layout is on the list */
    if (baselayout != 0)
    {
        if (size && layouts)
        {
            if (count < size)
            {
                layouts[count] = (HKL)baselayout;
                count++;
            }
        }
        else
            count++;
    }

    return count;
}

274
static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
275 276 277 278
{
    return 0;
}

279
static HKL CDECL nulldrv_GetKeyboardLayout( DWORD thread_id )
280 281 282 283
{
    return 0;
}

284
static BOOL CDECL nulldrv_GetKeyboardLayoutName( LPWSTR name )
285 286 287 288
{
    return FALSE;
}

289
static HKL CDECL nulldrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
290 291 292 293
{
    return 0;
}

294
static UINT CDECL nulldrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
295 296 297 298
{
    return 0;
}

299 300 301 302 303
static BOOL CDECL nulldrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
    return TRUE;
}

304 305
static INT CDECL nulldrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
                                      int size, UINT flags, HKL layout )
306 307 308 309
{
    return 0;
}

310
static BOOL CDECL nulldrv_UnloadKeyboardLayout( HKL layout )
311 312 313 314
{
    return 0;
}

315 316 317 318
static void CDECL nulldrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
}

319
static SHORT CDECL nulldrv_VkKeyScanEx( WCHAR ch, HKL layout )
320 321 322 323
{
    return -1;
}

324 325 326 327
static void CDECL nulldrv_DestroyCursorIcon( HCURSOR cursor )
{
}

328
static void CDECL nulldrv_SetCursor( HCURSOR cursor )
329 330 331
{
}

332
static BOOL CDECL nulldrv_GetCursorPos( LPPOINT pt )
333 334 335 336
{
    return FALSE;
}

337
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
338 339 340 341
{
    return FALSE;
}

342
static BOOL CDECL nulldrv_ClipCursor( LPCRECT clip )
343 344 345 346
{
    return FALSE;
}

347 348 349 350
static void CDECL nulldrv_UpdateClipboard(void)
{
}

351
static LONG CDECL nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
352 353 354 355 356
                                             DWORD flags, LPVOID lparam )
{
    return DISP_CHANGE_FAILED;
}

357
static BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
358
{
359 360 361 362 363 364
    RECT r = {0, 0, 640, 480};

    TRACE("(%p, %p, %p, 0x%lx)\n", hdc, rect, proc, lp);

    proc(NULLDRV_DEFAULT_HMONITOR, hdc, &r, lp);
    return TRUE;
365 366
}

367
static BOOL CDECL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
368 369 370 371
{
    return FALSE;
}

372
static BOOL CDECL nulldrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
373
{
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
    RECT r = {0, 0, 640, 480};
    static const WCHAR device[] = {'W','i','n','D','i','s','c',0};

    TRACE("(%p, %p)\n", handle, info);

    if (handle != NULLDRV_DEFAULT_HMONITOR)
    {
        SetLastError(ERROR_INVALID_MONITOR_HANDLE);
        return FALSE;
    }

    info->rcMonitor = r;
    info->rcWork = r;
    info->dwFlags = MONITORINFOF_PRIMARY;
    if (info->cbSize >= sizeof(MONITORINFOEXW))
        lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, device );
    return TRUE;
391 392
}

393
static BOOL CDECL nulldrv_CreateDesktopWindow( HWND hwnd )
394 395 396 397
{
    return TRUE;
}

398
static BOOL CDECL nodrv_CreateWindow( HWND hwnd )
399
{
400
    static int warned;
401
    HWND parent = GetAncestor( hwnd, GA_PARENT );
402 403

    /* HWND_MESSAGE windows don't need a graphics driver */
404
    if (!parent || parent == get_user_thread_info()->msg_window) return TRUE;
405
    if (warned++) return FALSE;
406

407 408
    ERR_(winediag)( "Application tried to create a window, but no driver could be loaded.\n" );
    if (driver_load_error[0]) ERR_(winediag)( "%s\n", driver_load_error );
409
    return FALSE;
410 411
}

412 413 414 415 416
static BOOL CDECL nulldrv_CreateWindow( HWND hwnd )
{
    return TRUE;
}

417
static void CDECL nulldrv_DestroyWindow( HWND hwnd )
418 419 420
{
}

421 422 423 424
static void CDECL nulldrv_FlashWindowEx( FLASHWINFO *info )
{
}

425 426
static void CDECL nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
                                 const RECT *top_rect, DWORD flags )
427 428 429
{
}

430 431
static DWORD CDECL nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
                                                        DWORD mask, DWORD flags )
432 433 434 435 436
{
    return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
                                     timeout, flags & MWMO_ALERTABLE );
}

437
static void CDECL nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
438 439 440
{
}

441
static BOOL CDECL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update )
442
{
443 444 445 446 447
    RECT rect;

    GetClipBox( hdc, &rect );
    return BitBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
                   hdc, rect.left - dx, rect.top - dy, SRCCOPY );
448 449
}

450
static void CDECL nulldrv_SetCapture( HWND hwnd, UINT flags )
451 452 453
{
}

454
static void CDECL nulldrv_SetFocus( HWND hwnd )
455 456 457
{
}

458
static void CDECL nulldrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
459 460 461
{
}

462
static void CDECL nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
463 464 465
{
}

466
static void CDECL nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
467 468 469
{
}

470
static void CDECL nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
471 472 473
{
}

474
static void CDECL nulldrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
475 476 477
{
}

478
static void CDECL nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
479 480 481
{
}

482
static UINT CDECL nulldrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
483 484 485 486
{
    return swp;
}

487
static LRESULT CDECL nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
488
{
489
    return -1;
490 491
}

492 493 494 495 496 497
static BOOL CDECL nulldrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
                                               const RECT *window_rect )
{
    return TRUE;
}

498
static LRESULT CDECL nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
499 500 501 502
{
    return 0;
}

503 504
static void CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
                                             const RECT *window_rect, const RECT *client_rect,
505
                                             RECT *visible_rect, struct window_surface **surface )
506 507 508
{
}

509 510
static void CDECL nulldrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
                                            const RECT *window_rect, const RECT *client_rect,
511 512
                                            const RECT *visible_rect, const RECT *valid_rects,
                                            struct window_surface *surface )
513 514 515
{
}

516 517 518 519 520
static BOOL CDECL nulldrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
{
    return FALSE;
}

521 522 523 524
static void CDECL nulldrv_ThreadDetach( void )
{
}

525
static USER_DRIVER null_driver =
526 527 528 529 530 531 532
{
    /* keyboard functions */
    nulldrv_ActivateKeyboardLayout,
    nulldrv_Beep,
    nulldrv_GetAsyncKeyState,
    nulldrv_GetKeyNameText,
    nulldrv_GetKeyboardLayout,
533
    nulldrv_GetKeyboardLayoutList,
534 535 536
    nulldrv_GetKeyboardLayoutName,
    nulldrv_LoadKeyboardLayout,
    nulldrv_MapVirtualKeyEx,
537
    nulldrv_RegisterHotKey,
538 539
    nulldrv_ToUnicodeEx,
    nulldrv_UnloadKeyboardLayout,
540
    nulldrv_UnregisterHotKey,
541
    nulldrv_VkKeyScanEx,
542 543
    /* cursor/icon functions */
    nulldrv_DestroyCursorIcon,
544 545 546
    nulldrv_SetCursor,
    nulldrv_GetCursorPos,
    nulldrv_SetCursorPos,
547
    nulldrv_ClipCursor,
548
    /* clipboard functions */
549
    nulldrv_UpdateClipboard,
550 551
    /* display modes */
    nulldrv_ChangeDisplaySettingsEx,
552
    nulldrv_EnumDisplayMonitors,
553
    nulldrv_EnumDisplaySettingsEx,
554
    nulldrv_GetMonitorInfo,
555 556 557 558
    /* windowing functions */
    nulldrv_CreateDesktopWindow,
    nulldrv_CreateWindow,
    nulldrv_DestroyWindow,
559
    nulldrv_FlashWindowEx,
560
    nulldrv_GetDC,
561 562 563
    nulldrv_MsgWaitForMultipleObjectsEx,
    nulldrv_ReleaseDC,
    nulldrv_ScrollDC,
564
    nulldrv_SetCapture,
565
    nulldrv_SetFocus,
566
    nulldrv_SetLayeredWindowAttributes,
567 568 569 570 571
    nulldrv_SetParent,
    nulldrv_SetWindowRgn,
    nulldrv_SetWindowIcon,
    nulldrv_SetWindowStyle,
    nulldrv_SetWindowText,
572
    nulldrv_ShowWindow,
573
    nulldrv_SysCommand,
574
    nulldrv_UpdateLayeredWindow,
575 576
    nulldrv_WindowMessage,
    nulldrv_WindowPosChanging,
577 578
    nulldrv_WindowPosChanged,
    /* system parameters */
579 580 581
    nulldrv_SystemParametersInfo,
    /* thread management */
    nulldrv_ThreadDetach
582 583 584 585 586 587 588 589 590 591
};


/**********************************************************************
 * Lazy loading user driver
 *
 * Initial driver used before another driver is loaded.
 * Each entry point simply loads the real driver and chains to it.
 */

592
static HKL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
593 594 595 596
{
    return load_driver()->pActivateKeyboardLayout( layout, flags );
}

597
static void CDECL loaderdrv_Beep(void)
598 599 600 601
{
    load_driver()->pBeep();
}

602
static SHORT CDECL loaderdrv_GetAsyncKeyState( INT key )
603 604 605 606
{
    return load_driver()->pGetAsyncKeyState( key );
}

607
static INT CDECL loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
608 609 610 611
{
    return load_driver()->pGetKeyNameText( lparam, buffer, size );
}

612
static HKL CDECL loaderdrv_GetKeyboardLayout( DWORD thread_id )
613
{
614
    return load_driver()->pGetKeyboardLayout( thread_id );
615 616
}

617 618 619 620 621
static UINT CDECL loaderdrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
    return load_driver()->pGetKeyboardLayoutList( size, layouts );
}

622
static BOOL CDECL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
623 624 625 626
{
    return load_driver()->pGetKeyboardLayoutName( name );
}

627
static HKL CDECL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
628 629 630 631
{
    return load_driver()->pLoadKeyboardLayout( name, flags );
}

632
static UINT CDECL loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
633 634 635 636
{
    return load_driver()->pMapVirtualKeyEx( code, type, layout );
}

637 638 639 640 641
static BOOL CDECL loaderdrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
    return load_driver()->pRegisterHotKey( hwnd, modifiers, vk );
}

642
static INT CDECL loaderdrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
643 644 645 646 647
                                  int size, UINT flags, HKL layout )
{
    return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
}

648
static BOOL CDECL loaderdrv_UnloadKeyboardLayout( HKL layout )
649 650 651 652
{
    return load_driver()->pUnloadKeyboardLayout( layout );
}

653 654 655 656 657
static void CDECL loaderdrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
{
    load_driver()->pUnregisterHotKey( hwnd, modifiers, vk );
}

658
static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
659 660 661 662
{
    return load_driver()->pVkKeyScanEx( ch, layout );
}

663
static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
664
{
665
    load_driver()->pSetCursor( cursor );
666 667
}

668
static BOOL CDECL loaderdrv_GetCursorPos( LPPOINT pt )
669 670 671 672
{
    return load_driver()->pGetCursorPos( pt );
}

673
static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
674 675 676 677
{
    return load_driver()->pSetCursorPos( x, y );
}

678
static BOOL CDECL loaderdrv_ClipCursor( LPCRECT clip )
679 680 681 682
{
    return load_driver()->pClipCursor( clip );
}

683 684 685 686 687
static void CDECL loaderdrv_UpdateClipboard(void)
{
    load_driver()->pUpdateClipboard();
}

688 689
static LONG CDECL loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
                                                     DWORD flags, LPVOID lparam )
690 691 692 693
{
    return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
}

694
static BOOL CDECL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
695 696 697 698
{
    return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
}

699
static BOOL CDECL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
700 701 702 703
{
    return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
}

704
static BOOL CDECL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
705 706 707 708
{
    return load_driver()->pGetMonitorInfo( handle, info );
}

709
static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
710 711 712 713
{
    return load_driver()->pCreateDesktopWindow( hwnd );
}

714
static BOOL CDECL loaderdrv_CreateWindow( HWND hwnd )
715
{
716
    return load_driver()->pCreateWindow( hwnd );
717 718
}

719 720 721 722 723
static void CDECL loaderdrv_FlashWindowEx( FLASHWINFO *info )
{
    load_driver()->pFlashWindowEx( info );
}

724 725
static void CDECL loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
                                   const RECT *top_rect, DWORD flags )
726
{
727
    load_driver()->pGetDC( hdc, hwnd, top_win, win_rect, top_rect, flags );
728 729
}

730
static void CDECL loaderdrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
731 732 733 734
{
    load_driver()->pSetLayeredWindowAttributes( hwnd, key, alpha, flags );
}

735
static void CDECL loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
736
{
737
    load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
738 739
}

740 741 742 743 744 745
static BOOL CDECL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
                                                 const RECT *window_rect )
{
    return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
}

746
static USER_DRIVER lazy_load_driver =
747 748 749 750 751 752 753
{
    /* keyboard functions */
    loaderdrv_ActivateKeyboardLayout,
    loaderdrv_Beep,
    loaderdrv_GetAsyncKeyState,
    loaderdrv_GetKeyNameText,
    loaderdrv_GetKeyboardLayout,
754
    loaderdrv_GetKeyboardLayoutList,
755 756 757
    loaderdrv_GetKeyboardLayoutName,
    loaderdrv_LoadKeyboardLayout,
    loaderdrv_MapVirtualKeyEx,
758
    loaderdrv_RegisterHotKey,
759 760
    loaderdrv_ToUnicodeEx,
    loaderdrv_UnloadKeyboardLayout,
761
    loaderdrv_UnregisterHotKey,
762
    loaderdrv_VkKeyScanEx,
763
    /* cursor/icon functions */
764
    nulldrv_DestroyCursorIcon,
765 766 767
    loaderdrv_SetCursor,
    loaderdrv_GetCursorPos,
    loaderdrv_SetCursorPos,
768
    loaderdrv_ClipCursor,
769
    /* clipboard functions */
770
    loaderdrv_UpdateClipboard,
771 772
    /* display modes */
    loaderdrv_ChangeDisplaySettingsEx,
773
    loaderdrv_EnumDisplayMonitors,
774
    loaderdrv_EnumDisplaySettingsEx,
775
    loaderdrv_GetMonitorInfo,
776 777 778
    /* windowing functions */
    loaderdrv_CreateDesktopWindow,
    loaderdrv_CreateWindow,
779
    nulldrv_DestroyWindow,
780
    loaderdrv_FlashWindowEx,
781
    loaderdrv_GetDC,
782 783 784 785 786
    nulldrv_MsgWaitForMultipleObjectsEx,
    nulldrv_ReleaseDC,
    nulldrv_ScrollDC,
    nulldrv_SetCapture,
    nulldrv_SetFocus,
787
    loaderdrv_SetLayeredWindowAttributes,
788
    nulldrv_SetParent,
789
    loaderdrv_SetWindowRgn,
790 791 792 793 794
    nulldrv_SetWindowIcon,
    nulldrv_SetWindowStyle,
    nulldrv_SetWindowText,
    nulldrv_ShowWindow,
    nulldrv_SysCommand,
795
    loaderdrv_UpdateLayeredWindow,
796 797 798
    nulldrv_WindowMessage,
    nulldrv_WindowPosChanging,
    nulldrv_WindowPosChanged,
799
    /* system parameters */
800 801 802
    nulldrv_SystemParametersInfo,
    /* thread management */
    nulldrv_ThreadDetach
803
};