2005-07-18 17:14:56 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-07-18 17:14:56 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
2020-09-21 13:53:21 +02:00
|
|
|
#include <wchar.h>
|
|
|
|
|
2021-11-11 14:12:44 +01:00
|
|
|
#include "user_private.h"
|
2020-09-21 13:53:21 +02:00
|
|
|
#include "winnls.h"
|
2005-07-18 17:14:56 +02:00
|
|
|
#include "wine/debug.h"
|
2013-10-24 17:40:37 +02:00
|
|
|
#include "controls.h"
|
2005-07-18 17:14:56 +02:00
|
|
|
|
2013-10-29 12:12:21 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(user);
|
2015-11-16 21:31:11 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(winediag);
|
2013-10-29 12:12:21 +01:00
|
|
|
|
2021-11-11 14:12:44 +01:00
|
|
|
static struct user_driver_funcs null_driver, lazy_load_driver;
|
2005-07-18 17:14:56 +02:00
|
|
|
|
2021-11-11 14:12:44 +01:00
|
|
|
const struct user_driver_funcs *USER_Driver = &lazy_load_driver;
|
2013-10-29 12:12:21 +01:00
|
|
|
static char driver_load_error[80];
|
|
|
|
|
2017-02-09 15:12:58 +01:00
|
|
|
static BOOL CDECL nodrv_CreateWindow( HWND hwnd );
|
|
|
|
|
2021-11-11 14:13:29 +01:00
|
|
|
static BOOL load_desktop_driver( HWND hwnd )
|
2013-10-29 12:12:21 +01:00
|
|
|
{
|
2020-02-11 20:45:27 +01:00
|
|
|
BOOL ret = FALSE;
|
2013-10-29 12:12:21 +01:00
|
|
|
HKEY hkey;
|
|
|
|
DWORD size;
|
|
|
|
WCHAR path[MAX_PATH];
|
2020-09-21 16:31:11 +02:00
|
|
|
WCHAR key[ARRAY_SIZE(L"System\\CurrentControlSet\\Control\\Video\\{}\\0000") + 40];
|
2020-09-01 09:03:26 +02:00
|
|
|
UINT guid_atom;
|
2013-10-29 12:12:21 +01:00
|
|
|
|
2014-01-30 21:49:32 +01:00
|
|
|
USER_CheckNotLock();
|
|
|
|
|
2013-10-29 12:12:21 +01:00
|
|
|
strcpy( driver_load_error, "The explorer process failed to start." ); /* default error */
|
2021-05-13 12:35:38 +02:00
|
|
|
wait_graphics_driver_ready();
|
2013-10-29 12:12:21 +01:00
|
|
|
|
2020-09-21 16:31:11 +02:00
|
|
|
guid_atom = HandleToULong( GetPropW( hwnd, L"__wine_display_device_guid" ));
|
|
|
|
lstrcpyW( key, L"System\\CurrentControlSet\\Control\\Video\\{" );
|
2020-09-21 13:53:21 +02:00
|
|
|
if (!GlobalGetAtomNameW( guid_atom, key + lstrlenW(key), 40 )) return 0;
|
2020-09-21 16:31:11 +02:00
|
|
|
lstrcatW( key, L"}\\0000" );
|
2013-10-29 12:12:21 +01:00
|
|
|
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, key, &hkey )) return 0;
|
|
|
|
size = sizeof(path);
|
2020-09-21 16:31:11 +02:00
|
|
|
if (!RegQueryValueExW( hkey, L"GraphicsDriver", NULL, NULL, (BYTE *)path, &size ))
|
2013-10-29 12:12:21 +01:00
|
|
|
{
|
2021-11-11 14:13:16 +01:00
|
|
|
if (wcscmp( path, L"null" ))
|
|
|
|
{
|
2021-11-11 14:13:29 +01:00
|
|
|
ret = LoadLibraryW( path ) != NULL;
|
2021-11-11 14:13:16 +01:00
|
|
|
if (!ret) ERR( "failed to load %s\n", debugstr_w(path) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
__wine_set_user_driver( &null_driver, WINE_GDI_DRIVER_VERSION );
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
2021-11-11 14:13:29 +01:00
|
|
|
TRACE( "%s\n", debugstr_w(path) );
|
2013-10-29 12:12:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
size = sizeof(driver_load_error);
|
|
|
|
RegQueryValueExA( hkey, "DriverError", NULL, NULL, (BYTE *)driver_load_error, &size );
|
|
|
|
}
|
|
|
|
RegCloseKey( hkey );
|
|
|
|
return ret;
|
|
|
|
}
|
2005-07-18 17:14:56 +02:00
|
|
|
|
|
|
|
/* load the graphics driver */
|
2021-11-11 14:12:44 +01:00
|
|
|
static const struct user_driver_funcs *load_driver(void)
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-11-11 14:13:16 +01:00
|
|
|
struct user_driver_funcs driver;
|
|
|
|
USEROBJECTFLAGS flags;
|
|
|
|
HWINSTA winstation;
|
2005-07-18 17:14:56 +02:00
|
|
|
|
2021-11-11 14:13:29 +01:00
|
|
|
if (!load_desktop_driver( GetDesktopWindow() ) || USER_Driver == &lazy_load_driver)
|
2020-02-11 20:45:27 +01:00
|
|
|
{
|
2021-11-11 14:13:16 +01:00
|
|
|
memset( &driver, 0, sizeof(driver) );
|
2021-10-13 14:52:53 +02:00
|
|
|
winstation = NtUserGetProcessWindowStation();
|
2021-11-11 14:13:16 +01:00
|
|
|
if (!NtUserGetObjectInformation( winstation, UOI_FLAGS, &flags, sizeof(flags), NULL )
|
2020-02-11 20:45:27 +01:00
|
|
|
|| (flags.dwFlags & WSF_VISIBLE))
|
2021-11-11 14:13:16 +01:00
|
|
|
driver.pCreateWindow = nodrv_CreateWindow;
|
2005-07-18 17:14:56 +02:00
|
|
|
|
2021-11-11 14:13:16 +01:00
|
|
|
__wine_set_user_driver( &driver, WINE_GDI_DRIVER_VERSION );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
2012-10-22 15:06:59 +02:00
|
|
|
|
2013-10-24 17:40:37 +02:00
|
|
|
register_builtin_classes();
|
2021-11-11 14:13:16 +01:00
|
|
|
return USER_Driver;
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2005-08-10 11:56:23 +02:00
|
|
|
/* unload the graphics driver on process exit */
|
|
|
|
void USER_unload_driver(void)
|
|
|
|
{
|
2021-11-11 14:12:44 +01:00
|
|
|
struct user_driver_funcs *prev;
|
2005-08-10 11:56:23 +02:00
|
|
|
/* make sure we don't try to call the driver after it has been detached */
|
2009-01-10 21:56:21 +01:00
|
|
|
prev = InterlockedExchangePointer( (void **)&USER_Driver, &null_driver );
|
|
|
|
if (prev != &lazy_load_driver && prev != &null_driver)
|
|
|
|
HeapFree( GetProcessHeap(), 0, prev );
|
2005-08-10 11:56:23 +02:00
|
|
|
}
|
|
|
|
|
2005-07-18 17:14:56 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Null user driver
|
|
|
|
*
|
|
|
|
* These are fallbacks for entry points that are not implemented in the real driver.
|
|
|
|
*/
|
|
|
|
|
2021-05-05 11:46:50 +02:00
|
|
|
static BOOL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-05-05 11:46:50 +02:00
|
|
|
return TRUE;
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_Beep(void)
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-11-20 16:30:33 +01:00
|
|
|
static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
|
|
|
|
{
|
2021-04-30 10:43:58 +02:00
|
|
|
return ~0; /* use default implementation */
|
2013-11-20 16:30:33 +01:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-04-30 10:43:56 +02:00
|
|
|
return -1; /* use default implementation */
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static UINT CDECL nulldrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-04-30 10:43:55 +02:00
|
|
|
return -1; /* use default implementation */
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
static BOOL CDECL nulldrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static INT CDECL nulldrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
|
|
|
|
int size, UINT flags, HKL layout )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-04-29 09:53:52 +02:00
|
|
|
return -2; /* use default implementation */
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
static void CDECL nulldrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static SHORT CDECL nulldrv_VkKeyScanEx( WCHAR ch, HKL layout )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-04-30 10:43:57 +02:00
|
|
|
return -256; /* use default implementation */
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2010-04-20 14:10:46 +02:00
|
|
|
static void CDECL nulldrv_DestroyCursorIcon( HCURSOR cursor )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-04-20 21:14:31 +02:00
|
|
|
static void CDECL nulldrv_SetCursor( HCURSOR cursor )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL nulldrv_GetCursorPos( LPPOINT pt )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-05-06 12:03:16 +02:00
|
|
|
return TRUE;
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-05-06 12:03:16 +02:00
|
|
|
return TRUE;
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL nulldrv_ClipCursor( LPCRECT clip )
|
2007-01-04 20:24:50 +01:00
|
|
|
{
|
2021-05-06 12:03:16 +02:00
|
|
|
return TRUE;
|
2007-01-04 20:24:50 +01:00
|
|
|
}
|
|
|
|
|
2016-09-23 07:07:08 +02:00
|
|
|
static void CDECL nulldrv_UpdateClipboard(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static LONG CDECL nulldrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
|
2005-07-18 17:14:56 +02:00
|
|
|
DWORD flags, LPVOID lparam )
|
|
|
|
{
|
|
|
|
return DISP_CHANGE_FAILED;
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL nulldrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL nulldrv_CreateDesktopWindow( HWND hwnd )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2017-02-09 15:12:58 +01:00
|
|
|
static BOOL CDECL nodrv_CreateWindow( HWND hwnd )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2005-10-31 16:54:55 +01:00
|
|
|
static int warned;
|
2013-04-02 12:46:39 +02:00
|
|
|
HWND parent = GetAncestor( hwnd, GA_PARENT );
|
2009-10-23 12:23:51 +02:00
|
|
|
|
|
|
|
/* HWND_MESSAGE windows don't need a graphics driver */
|
2013-04-02 12:46:39 +02:00
|
|
|
if (!parent || parent == get_user_thread_info()->msg_window) return TRUE;
|
2009-10-23 12:23:51 +02:00
|
|
|
if (warned++) return FALSE;
|
2006-04-03 15:46:35 +02:00
|
|
|
|
2015-11-16 21:31:11 +01:00
|
|
|
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 );
|
2005-10-31 16:54:55 +01:00
|
|
|
return FALSE;
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2017-02-09 15:12:58 +01:00
|
|
|
static BOOL CDECL nulldrv_CreateWindow( HWND hwnd )
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_DestroyWindow( HWND hwnd )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-13 07:51:42 +02:00
|
|
|
static void CDECL nulldrv_FlashWindowEx( FLASHWINFO *info )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
|
|
|
|
const RECT *top_rect, DWORD flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static DWORD CDECL nulldrv_MsgWaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, DWORD timeout,
|
|
|
|
DWORD mask, DWORD flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-05-14 13:40:06 +02:00
|
|
|
if (!count && !timeout) return WAIT_TIMEOUT;
|
2005-07-18 17:14:56 +02:00
|
|
|
return WaitForMultipleObjectsEx( count, handles, flags & MWMO_WAITALL,
|
|
|
|
timeout, flags & MWMO_ALERTABLE );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_ReleaseDC( HWND hwnd, HDC hdc )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-04-19 12:27:59 +02:00
|
|
|
static BOOL CDECL nulldrv_ScrollDC( HDC hdc, INT dx, INT dy, HRGN update )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2013-04-19 12:27:59 +02:00
|
|
|
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 );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetCapture( HWND hwnd, UINT flags )
|
2008-03-12 14:55:28 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetFocus( HWND hwnd )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
|
2008-09-12 15:43:27 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetParent( HWND hwnd, HWND parent, HWND old_parent )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-05-01 12:31:14 +02:00
|
|
|
static void CDECL nulldrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_SetWindowText( HWND hwnd, LPCWSTR text )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static UINT CDECL nulldrv_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp )
|
2008-07-30 16:13:28 +02:00
|
|
|
{
|
2021-05-14 13:40:05 +02:00
|
|
|
return ~0; /* use default implementation */
|
2008-07-30 16:13:28 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static LRESULT CDECL nulldrv_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2008-04-10 15:43:24 +02:00
|
|
|
return -1;
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2012-09-27 18:13:01 +02:00
|
|
|
static BOOL CDECL nulldrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
|
|
|
|
const RECT *window_rect )
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static LRESULT CDECL nulldrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-05-14 13:40:09 +02:00
|
|
|
static BOOL CDECL nulldrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags,
|
2008-12-16 15:32:08 +01:00
|
|
|
const RECT *window_rect, const RECT *client_rect,
|
2012-09-06 12:32:52 +02:00
|
|
|
RECT *visible_rect, struct window_surface **surface )
|
2008-07-02 15:40:10 +02:00
|
|
|
{
|
2021-05-14 13:40:09 +02:00
|
|
|
return FALSE;
|
2008-07-02 15:40:10 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL nulldrv_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags,
|
|
|
|
const RECT *window_rect, const RECT *client_rect,
|
2012-09-06 12:32:52 +02:00
|
|
|
const RECT *visible_rect, const RECT *valid_rects,
|
|
|
|
struct window_surface *surface )
|
2008-07-02 15:40:10 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-11-15 17:38:21 +01:00
|
|
|
static BOOL CDECL nulldrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-08-25 14:33:45 +02:00
|
|
|
static void CDECL nulldrv_ThreadDetach( void )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-11-11 14:12:44 +01:00
|
|
|
static struct user_driver_funcs null_driver =
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-11-11 14:12:44 +01:00
|
|
|
{ NULL },
|
2005-07-18 17:14:56 +02:00
|
|
|
/* keyboard functions */
|
|
|
|
nulldrv_ActivateKeyboardLayout,
|
|
|
|
nulldrv_Beep,
|
|
|
|
nulldrv_GetKeyNameText,
|
2013-11-20 16:30:33 +01:00
|
|
|
nulldrv_GetKeyboardLayoutList,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_MapVirtualKeyEx,
|
2011-06-23 19:34:26 +02:00
|
|
|
nulldrv_RegisterHotKey,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_ToUnicodeEx,
|
2011-06-23 19:34:26 +02:00
|
|
|
nulldrv_UnregisterHotKey,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_VkKeyScanEx,
|
2010-04-20 14:10:46 +02:00
|
|
|
/* cursor/icon functions */
|
|
|
|
nulldrv_DestroyCursorIcon,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_SetCursor,
|
|
|
|
nulldrv_GetCursorPos,
|
|
|
|
nulldrv_SetCursorPos,
|
2007-01-04 20:24:50 +01:00
|
|
|
nulldrv_ClipCursor,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* clipboard functions */
|
2016-09-23 07:07:08 +02:00
|
|
|
nulldrv_UpdateClipboard,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* display modes */
|
|
|
|
nulldrv_ChangeDisplaySettingsEx,
|
2006-10-23 13:51:30 +02:00
|
|
|
nulldrv_EnumDisplayMonitors,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_EnumDisplaySettingsEx,
|
2006-10-23 13:51:30 +02:00
|
|
|
nulldrv_GetMonitorInfo,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* windowing functions */
|
|
|
|
nulldrv_CreateDesktopWindow,
|
|
|
|
nulldrv_CreateWindow,
|
|
|
|
nulldrv_DestroyWindow,
|
2015-10-13 07:51:42 +02:00
|
|
|
nulldrv_FlashWindowEx,
|
2008-02-25 15:59:19 +01:00
|
|
|
nulldrv_GetDC,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_MsgWaitForMultipleObjectsEx,
|
|
|
|
nulldrv_ReleaseDC,
|
|
|
|
nulldrv_ScrollDC,
|
2008-03-12 14:55:28 +01:00
|
|
|
nulldrv_SetCapture,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_SetFocus,
|
2008-09-12 15:43:27 +02:00
|
|
|
nulldrv_SetLayeredWindowAttributes,
|
2005-07-18 17:14:56 +02:00
|
|
|
nulldrv_SetParent,
|
|
|
|
nulldrv_SetWindowRgn,
|
|
|
|
nulldrv_SetWindowIcon,
|
|
|
|
nulldrv_SetWindowStyle,
|
|
|
|
nulldrv_SetWindowText,
|
2008-07-30 16:13:28 +02:00
|
|
|
nulldrv_ShowWindow,
|
2008-04-10 15:43:24 +02:00
|
|
|
nulldrv_SysCommand,
|
2012-09-27 18:13:01 +02:00
|
|
|
nulldrv_UpdateLayeredWindow,
|
2008-07-02 15:40:10 +02:00
|
|
|
nulldrv_WindowMessage,
|
|
|
|
nulldrv_WindowPosChanging,
|
2012-11-15 17:38:21 +01:00
|
|
|
nulldrv_WindowPosChanged,
|
|
|
|
/* system parameters */
|
2016-08-25 14:33:45 +02:00
|
|
|
nulldrv_SystemParametersInfo,
|
|
|
|
/* thread management */
|
|
|
|
nulldrv_ThreadDetach
|
2005-07-18 17:14:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* Lazy loading user driver
|
|
|
|
*
|
|
|
|
* Initial driver used before another driver is loaded.
|
|
|
|
* Each entry point simply loads the real driver and chains to it.
|
|
|
|
*/
|
|
|
|
|
2021-05-05 11:46:50 +02:00
|
|
|
static BOOL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pActivateKeyboardLayout( layout, flags );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL loaderdrv_Beep(void)
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
load_driver()->pBeep();
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static INT CDECL loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pGetKeyNameText( lparam, buffer, size );
|
|
|
|
}
|
|
|
|
|
2013-11-20 16:30:33 +01:00
|
|
|
static UINT CDECL loaderdrv_GetKeyboardLayoutList( INT size, HKL *layouts )
|
|
|
|
{
|
|
|
|
return load_driver()->pGetKeyboardLayoutList( size, layouts );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static UINT CDECL loaderdrv_MapVirtualKeyEx( UINT code, UINT type, HKL layout )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pMapVirtualKeyEx( code, type, layout );
|
|
|
|
}
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
static BOOL CDECL loaderdrv_RegisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
|
|
|
|
{
|
|
|
|
return load_driver()->pRegisterHotKey( hwnd, modifiers, vk );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static INT CDECL loaderdrv_ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, LPWSTR str,
|
2005-07-18 17:14:56 +02:00
|
|
|
int size, UINT flags, HKL layout )
|
|
|
|
{
|
|
|
|
return load_driver()->pToUnicodeEx( virt, scan, state, str, size, flags, layout );
|
|
|
|
}
|
|
|
|
|
2011-06-23 19:34:26 +02:00
|
|
|
static void CDECL loaderdrv_UnregisterHotKey( HWND hwnd, UINT modifiers, UINT vk )
|
|
|
|
{
|
|
|
|
load_driver()->pUnregisterHotKey( hwnd, modifiers, vk );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static SHORT CDECL loaderdrv_VkKeyScanEx( WCHAR ch, HKL layout )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pVkKeyScanEx( ch, layout );
|
|
|
|
}
|
|
|
|
|
2010-04-20 21:14:31 +02:00
|
|
|
static void CDECL loaderdrv_SetCursor( HCURSOR cursor )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2010-04-20 21:14:31 +02:00
|
|
|
load_driver()->pSetCursor( cursor );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_GetCursorPos( LPPOINT pt )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pGetCursorPos( pt );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_SetCursorPos( INT x, INT y )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pSetCursorPos( x, y );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_ClipCursor( LPCRECT clip )
|
2007-01-04 20:24:50 +01:00
|
|
|
{
|
|
|
|
return load_driver()->pClipCursor( clip );
|
|
|
|
}
|
|
|
|
|
2016-09-23 07:07:08 +02:00
|
|
|
static void CDECL loaderdrv_UpdateClipboard(void)
|
|
|
|
{
|
|
|
|
load_driver()->pUpdateClipboard();
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static LONG CDECL loaderdrv_ChangeDisplaySettingsEx( LPCWSTR name, LPDEVMODEW mode, HWND hwnd,
|
|
|
|
DWORD flags, LPVOID lparam )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pChangeDisplaySettingsEx( name, mode, hwnd, flags, lparam );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
|
2006-10-23 13:51:30 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pEnumDisplayMonitors( hdc, rect, proc, lp );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_EnumDisplaySettingsEx( LPCWSTR name, DWORD num, LPDEVMODEW mode, DWORD flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pEnumDisplaySettingsEx( name, num, mode, flags );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
|
2006-10-23 13:51:30 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pGetMonitorInfo( handle, info );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_CreateDesktopWindow( HWND hwnd )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
|
|
|
return load_driver()->pCreateDesktopWindow( hwnd );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static BOOL CDECL loaderdrv_CreateWindow( HWND hwnd )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2008-01-24 11:23:09 +01:00
|
|
|
return load_driver()->pCreateWindow( hwnd );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2015-10-13 07:51:42 +02:00
|
|
|
static void CDECL loaderdrv_FlashWindowEx( FLASHWINFO *info )
|
|
|
|
{
|
|
|
|
load_driver()->pFlashWindowEx( info );
|
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL loaderdrv_GetDC( HDC hdc, HWND hwnd, HWND top_win, const RECT *win_rect,
|
|
|
|
const RECT *top_rect, DWORD flags )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2008-02-25 15:59:19 +01:00
|
|
|
load_driver()->pGetDC( hdc, hwnd, top_win, win_rect, top_rect, flags );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2008-12-16 15:32:08 +01:00
|
|
|
static void CDECL loaderdrv_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWORD flags )
|
2008-09-12 15:43:27 +02:00
|
|
|
{
|
|
|
|
load_driver()->pSetLayeredWindowAttributes( hwnd, key, alpha, flags );
|
|
|
|
}
|
|
|
|
|
2014-05-01 12:31:14 +02:00
|
|
|
static void CDECL loaderdrv_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2014-05-01 12:31:14 +02:00
|
|
|
load_driver()->pSetWindowRgn( hwnd, hrgn, redraw );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
|
|
|
|
2012-09-27 18:13:01 +02:00
|
|
|
static BOOL CDECL loaderdrv_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
|
|
|
|
const RECT *window_rect )
|
|
|
|
{
|
|
|
|
return load_driver()->pUpdateLayeredWindow( hwnd, info, window_rect );
|
|
|
|
}
|
|
|
|
|
2021-11-11 14:12:44 +01:00
|
|
|
static struct user_driver_funcs lazy_load_driver =
|
2005-07-18 17:14:56 +02:00
|
|
|
{
|
2021-11-11 14:12:44 +01:00
|
|
|
{ NULL },
|
2005-07-18 17:14:56 +02:00
|
|
|
/* keyboard functions */
|
|
|
|
loaderdrv_ActivateKeyboardLayout,
|
|
|
|
loaderdrv_Beep,
|
|
|
|
loaderdrv_GetKeyNameText,
|
2013-11-20 16:30:33 +01:00
|
|
|
loaderdrv_GetKeyboardLayoutList,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_MapVirtualKeyEx,
|
2011-06-23 19:34:26 +02:00
|
|
|
loaderdrv_RegisterHotKey,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_ToUnicodeEx,
|
2011-06-23 19:34:26 +02:00
|
|
|
loaderdrv_UnregisterHotKey,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_VkKeyScanEx,
|
2010-04-20 14:10:46 +02:00
|
|
|
/* cursor/icon functions */
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_DestroyCursorIcon,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_SetCursor,
|
|
|
|
loaderdrv_GetCursorPos,
|
|
|
|
loaderdrv_SetCursorPos,
|
2007-01-04 20:24:50 +01:00
|
|
|
loaderdrv_ClipCursor,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* clipboard functions */
|
2016-09-23 07:07:08 +02:00
|
|
|
loaderdrv_UpdateClipboard,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* display modes */
|
|
|
|
loaderdrv_ChangeDisplaySettingsEx,
|
2006-10-23 13:51:30 +02:00
|
|
|
loaderdrv_EnumDisplayMonitors,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_EnumDisplaySettingsEx,
|
2006-10-23 13:51:30 +02:00
|
|
|
loaderdrv_GetMonitorInfo,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* windowing functions */
|
|
|
|
loaderdrv_CreateDesktopWindow,
|
|
|
|
loaderdrv_CreateWindow,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_DestroyWindow,
|
2015-10-13 07:51:42 +02:00
|
|
|
loaderdrv_FlashWindowEx,
|
2008-02-25 15:59:19 +01:00
|
|
|
loaderdrv_GetDC,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_MsgWaitForMultipleObjectsEx,
|
|
|
|
nulldrv_ReleaseDC,
|
|
|
|
nulldrv_ScrollDC,
|
|
|
|
nulldrv_SetCapture,
|
|
|
|
nulldrv_SetFocus,
|
2008-09-12 15:43:27 +02:00
|
|
|
loaderdrv_SetLayeredWindowAttributes,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_SetParent,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_SetWindowRgn,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_SetWindowIcon,
|
|
|
|
nulldrv_SetWindowStyle,
|
|
|
|
nulldrv_SetWindowText,
|
|
|
|
nulldrv_ShowWindow,
|
|
|
|
nulldrv_SysCommand,
|
2012-09-27 18:13:01 +02:00
|
|
|
loaderdrv_UpdateLayeredWindow,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_WindowMessage,
|
|
|
|
nulldrv_WindowPosChanging,
|
|
|
|
nulldrv_WindowPosChanged,
|
2012-11-15 17:38:21 +01:00
|
|
|
/* system parameters */
|
2016-08-25 14:33:45 +02:00
|
|
|
nulldrv_SystemParametersInfo,
|
|
|
|
/* thread management */
|
|
|
|
nulldrv_ThreadDetach
|
2005-07-18 17:14:56 +02:00
|
|
|
};
|
2021-11-11 14:13:16 +01:00
|
|
|
|
|
|
|
void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version )
|
|
|
|
{
|
|
|
|
struct user_driver_funcs *driver, *prev;
|
|
|
|
|
|
|
|
if (version != WINE_GDI_DRIVER_VERSION)
|
|
|
|
{
|
|
|
|
ERR( "version mismatch, driver wants %u but user32 has %u\n", version, WINE_GDI_DRIVER_VERSION );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver = HeapAlloc( GetProcessHeap(), 0, sizeof(*driver) );
|
|
|
|
*driver = *funcs;
|
|
|
|
|
|
|
|
#define SET_USER_FUNC(name) \
|
|
|
|
do { if (!driver->p##name) driver->p##name = nulldrv_##name; } while(0)
|
|
|
|
|
|
|
|
SET_USER_FUNC(ActivateKeyboardLayout);
|
|
|
|
SET_USER_FUNC(Beep);
|
|
|
|
SET_USER_FUNC(GetKeyNameText);
|
|
|
|
SET_USER_FUNC(GetKeyboardLayoutList);
|
|
|
|
SET_USER_FUNC(MapVirtualKeyEx);
|
|
|
|
SET_USER_FUNC(RegisterHotKey);
|
|
|
|
SET_USER_FUNC(ToUnicodeEx);
|
|
|
|
SET_USER_FUNC(UnregisterHotKey);
|
|
|
|
SET_USER_FUNC(VkKeyScanEx);
|
|
|
|
SET_USER_FUNC(DestroyCursorIcon);
|
|
|
|
SET_USER_FUNC(SetCursor);
|
|
|
|
SET_USER_FUNC(GetCursorPos);
|
|
|
|
SET_USER_FUNC(SetCursorPos);
|
|
|
|
SET_USER_FUNC(ClipCursor);
|
|
|
|
SET_USER_FUNC(UpdateClipboard);
|
|
|
|
SET_USER_FUNC(ChangeDisplaySettingsEx);
|
|
|
|
SET_USER_FUNC(EnumDisplayMonitors);
|
|
|
|
SET_USER_FUNC(EnumDisplaySettingsEx);
|
|
|
|
SET_USER_FUNC(GetMonitorInfo);
|
|
|
|
SET_USER_FUNC(CreateDesktopWindow);
|
|
|
|
SET_USER_FUNC(CreateWindow);
|
|
|
|
SET_USER_FUNC(DestroyWindow);
|
|
|
|
SET_USER_FUNC(FlashWindowEx);
|
|
|
|
SET_USER_FUNC(GetDC);
|
|
|
|
SET_USER_FUNC(MsgWaitForMultipleObjectsEx);
|
|
|
|
SET_USER_FUNC(ReleaseDC);
|
|
|
|
SET_USER_FUNC(ScrollDC);
|
|
|
|
SET_USER_FUNC(SetCapture);
|
|
|
|
SET_USER_FUNC(SetFocus);
|
|
|
|
SET_USER_FUNC(SetLayeredWindowAttributes);
|
|
|
|
SET_USER_FUNC(SetParent);
|
|
|
|
SET_USER_FUNC(SetWindowRgn);
|
|
|
|
SET_USER_FUNC(SetWindowIcon);
|
|
|
|
SET_USER_FUNC(SetWindowStyle);
|
|
|
|
SET_USER_FUNC(SetWindowText);
|
|
|
|
SET_USER_FUNC(ShowWindow);
|
|
|
|
SET_USER_FUNC(SysCommand);
|
|
|
|
SET_USER_FUNC(UpdateLayeredWindow);
|
|
|
|
SET_USER_FUNC(WindowMessage);
|
|
|
|
SET_USER_FUNC(WindowPosChanging);
|
|
|
|
SET_USER_FUNC(WindowPosChanged);
|
|
|
|
SET_USER_FUNC(SystemParametersInfo);
|
|
|
|
SET_USER_FUNC(ThreadDetach);
|
|
|
|
#undef SET_USER_FUNC
|
|
|
|
|
|
|
|
prev = InterlockedCompareExchangePointer( (void **)&USER_Driver, driver, &lazy_load_driver );
|
|
|
|
if (prev != &lazy_load_driver)
|
|
|
|
{
|
|
|
|
/* another thread beat us to it */
|
|
|
|
HeapFree( GetProcessHeap(), 0, driver );
|
2021-11-11 14:13:29 +01:00
|
|
|
driver = prev;
|
2021-11-11 14:13:16 +01:00
|
|
|
}
|
2021-11-11 14:13:29 +01:00
|
|
|
|
|
|
|
__wine_set_display_driver( driver, version );
|
2021-11-11 14:13:16 +01:00
|
|
|
}
|