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);
|
|
|
|
|
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;
|
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
|
|
|
{
|
2022-03-09 15:20:48 +01:00
|
|
|
wait_graphics_driver_ready();
|
|
|
|
if (USER_Driver == &lazy_load_driver)
|
2020-02-11 20:45:27 +01:00
|
|
|
{
|
2022-03-09 15:20:48 +01:00
|
|
|
static struct user_driver_funcs empty_funcs;
|
|
|
|
WARN( "failed to load the display driver, falling back to null driver\n" );
|
|
|
|
__wine_set_user_driver( &empty_funcs, WINE_GDI_DRIVER_VERSION );
|
2005-07-18 17:14:56 +02:00
|
|
|
}
|
2012-10-22 15:06:59 +02:00
|
|
|
|
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;
|
2021-11-11 14:13:35 +01:00
|
|
|
__wine_set_display_driver( &null_driver, WINE_GDI_DRIVER_VERSION );
|
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-12-06 03:08:07 +01:00
|
|
|
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y )
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void CDECL nulldrv_UpdateClipboard(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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_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_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
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
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 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
|
|
|
}
|
|
|
|
|
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 */
|
2021-11-17 12:47:04 +01:00
|
|
|
NULL,
|
2022-02-14 14:08:05 +01:00
|
|
|
NULL,
|
2021-11-16 12:35:59 +01:00
|
|
|
NULL,
|
2021-11-17 12:47:38 +01:00
|
|
|
NULL,
|
2021-11-16 12:34:17 +01:00
|
|
|
NULL,
|
2021-11-17 12:46:39 +01:00
|
|
|
NULL,
|
2022-02-24 01:27:57 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2021-11-16 12:33:53 +01:00
|
|
|
NULL,
|
2010-04-20 14:10:46 +02:00
|
|
|
/* cursor/icon functions */
|
2022-02-22 13:53:11 +01:00
|
|
|
NULL,
|
2022-02-23 13:39:35 +01:00
|
|
|
NULL,
|
2022-02-14 14:08:27 +01:00
|
|
|
NULL,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_SetCursorPos,
|
2022-02-25 16:01:15 +01:00
|
|
|
NULL,
|
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 */
|
2021-12-02 01:14:35 +01:00
|
|
|
NULL,
|
2021-12-01 16:02:43 +01:00
|
|
|
NULL,
|
2021-11-30 13:24:28 +01:00
|
|
|
NULL,
|
2005-07-18 17:14:56 +02:00
|
|
|
/* windowing functions */
|
2022-03-09 15:20:48 +01:00
|
|
|
NULL,
|
2005-07-18 17:14:56 +02:00
|
|
|
loaderdrv_CreateWindow,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_DestroyWindow,
|
2022-03-09 15:19:47 +01:00
|
|
|
NULL,
|
2022-03-14 11:43:55 +01:00
|
|
|
NULL,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_MsgWaitForMultipleObjectsEx,
|
2022-03-14 11:43:55 +01:00
|
|
|
NULL,
|
2021-11-17 12:49:37 +01:00
|
|
|
NULL,
|
2022-03-11 14:22:19 +01:00
|
|
|
NULL,
|
2022-03-11 14:22:04 +01:00
|
|
|
NULL,
|
2022-03-10 14:33:11 +01:00
|
|
|
NULL,
|
2022-03-15 14:27:55 +01:00
|
|
|
NULL,
|
2022-03-10 14:31:41 +01:00
|
|
|
NULL,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_SetWindowIcon,
|
2022-03-16 15:35:25 +01:00
|
|
|
NULL,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_SetWindowText,
|
|
|
|
nulldrv_ShowWindow,
|
|
|
|
nulldrv_SysCommand,
|
2022-03-10 14:33:27 +01:00
|
|
|
NULL,
|
2022-02-25 16:01:15 +01:00
|
|
|
NULL,
|
2013-10-23 16:13:17 +02:00
|
|
|
nulldrv_WindowPosChanging,
|
|
|
|
nulldrv_WindowPosChanged,
|
2012-11-15 17:38:21 +01:00
|
|
|
/* system parameters */
|
2021-12-06 03:15:59 +01:00
|
|
|
NULL,
|
2021-12-07 15:30:12 +01:00
|
|
|
/* vulkan support */
|
|
|
|
NULL,
|
2022-03-01 21:59:23 +01:00
|
|
|
/* opengl support */
|
|
|
|
NULL,
|
2016-08-25 14:33:45 +02:00
|
|
|
/* thread management */
|
2022-03-01 21:59:23 +01:00
|
|
|
NULL,
|
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;
|
|
|
|
|
2021-12-06 03:08:07 +01:00
|
|
|
#define SET_USER_FUNC(name) \
|
|
|
|
do { if (!driver->p##name) driver->p##name = nulldrv_##name; } while(0)
|
|
|
|
|
|
|
|
SET_USER_FUNC(SetCursorPos);
|
|
|
|
SET_USER_FUNC(UpdateClipboard);
|
|
|
|
SET_USER_FUNC(CreateWindow);
|
|
|
|
SET_USER_FUNC(DestroyWindow);
|
|
|
|
SET_USER_FUNC(MsgWaitForMultipleObjectsEx);
|
|
|
|
SET_USER_FUNC(SetWindowIcon);
|
|
|
|
SET_USER_FUNC(SetWindowText);
|
|
|
|
SET_USER_FUNC(ShowWindow);
|
|
|
|
SET_USER_FUNC(SysCommand);
|
|
|
|
SET_USER_FUNC(WindowPosChanging);
|
|
|
|
SET_USER_FUNC(WindowPosChanged);
|
|
|
|
#undef SET_USER_FUNC
|
|
|
|
|
2021-11-11 14:13:16 +01:00
|
|
|
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
|
|
|
}
|