Commit 1d0fbcc9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move __wine_set_user_driver implementation from user32.

parent 12a6f8d4
......@@ -19,7 +19,6 @@ C_SRCS = \
defwnd.c \
desktop.c \
dialog.c \
driver.c \
edit.c \
exticon.c \
focus.c \
......
......@@ -655,7 +655,7 @@ BOOL WINAPI OpenClipboard( HWND hwnd )
TRACE( "%p\n", hwnd );
USER_Driver->pUpdateClipboard();
NtUserCallNoParam( NtUserUpdateClipboard );
EnterCriticalSection( &clipboard_cs );
......
/*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdio.h>
#include <wchar.h>
#include "user_private.h"
#include "winnls.h"
#include "wine/debug.h"
#include "controls.h"
WINE_DEFAULT_DEBUG_CHANNEL(user);
static struct user_driver_funcs null_driver, lazy_load_driver;
const struct user_driver_funcs *USER_Driver = &lazy_load_driver;
/* load the graphics driver */
static const struct user_driver_funcs *load_driver(void)
{
wait_graphics_driver_ready();
if (USER_Driver == &lazy_load_driver)
{
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 );
}
return USER_Driver;
}
/* unload the graphics driver on process exit */
void USER_unload_driver(void)
{
struct user_driver_funcs *prev;
__wine_set_display_driver( &null_driver, WINE_GDI_DRIVER_VERSION );
/* make sure we don't try to call the driver after it has been detached */
prev = InterlockedExchangePointer( (void **)&USER_Driver, &null_driver );
if (prev != &lazy_load_driver && prev != &null_driver)
HeapFree( GetProcessHeap(), 0, prev );
}
/**********************************************************************
* Null user driver
*
* These are fallbacks for entry points that are not implemented in the real driver.
*/
static void CDECL nulldrv_UpdateClipboard(void)
{
}
/**********************************************************************
* Lazy loading user driver
*
* Initial driver used before another driver is loaded.
* Each entry point simply loads the real driver and chains to it.
*/
static void CDECL loaderdrv_UpdateClipboard(void)
{
load_driver()->pUpdateClipboard();
}
static struct user_driver_funcs lazy_load_driver =
{
{ NULL },
/* keyboard functions */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
/* cursor/icon functions */
NULL,
NULL,
NULL,
NULL,
NULL,
/* clipboard functions */
loaderdrv_UpdateClipboard,
/* display modes */
NULL,
NULL,
NULL,
/* windowing functions */
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
/* system parameters */
NULL,
/* vulkan support */
NULL,
/* opengl support */
NULL,
/* thread management */
NULL,
};
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(UpdateClipboard);
#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 );
driver = prev;
}
__wine_set_display_driver( driver, version );
}
......@@ -839,4 +839,3 @@
# or 'wine_' (for user-visible functions) to avoid namespace conflicts.
#
@ cdecl __wine_set_pixel_format(long long)
@ cdecl __wine_set_user_driver(ptr long)
......@@ -176,7 +176,6 @@ static const struct user_callbacks user_funcs =
register_builtin_classes,
MENU_SetMenu,
SCROLL_SetStandardScrollPainted,
(void *)__wine_set_user_driver,
unpack_dde_message,
register_imm,
unregister_imm,
......@@ -270,7 +269,6 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
thread_detach();
break;
case DLL_PROCESS_DETACH:
USER_unload_driver();
FreeLibrary(imm32_module);
break;
}
......
......@@ -29,7 +29,6 @@
#include "winreg.h"
#include "winternl.h"
#include "hidusage.h"
#include "wine/gdi_driver.h"
#include "wine/heap.h"
#define GET_WORD(ptr) (*(const WORD *)(ptr))
......@@ -39,12 +38,6 @@
#define WINE_MOUSE_HANDLE ((HANDLE)1)
#define WINE_KEYBOARD_HANDLE ((HANDLE)2)
struct window_surface;
extern const struct user_driver_funcs *USER_Driver DECLSPEC_HIDDEN;
extern void USER_unload_driver(void) DECLSPEC_HIDDEN;
struct received_message_info;
/* data to store state for A/W mappings of WM_CHAR */
......
......@@ -928,15 +928,6 @@ static void CDECL nulldrv_ThreadDetach( void )
{
}
static BOOL setup_null_driver(void)
{
if (user_callbacks)
user_callbacks->set_user_driver( &null_user_driver, WINE_GDI_DRIVER_VERSION );
else
__wine_set_display_driver( &null_user_driver, WINE_GDI_DRIVER_VERSION );
return TRUE;
}
static const WCHAR guid_key_prefixW[] =
{
'\\','R','e','g','i','s','t','r','y',
......@@ -993,7 +984,11 @@ static BOOL load_desktop_driver( HWND hwnd )
ret = KeUserModeCallback( NtUserLoadDriver, info->Data, info->DataLength,
&ret_ptr, &ret_len );
}
else ret = setup_null_driver();
else
{
__wine_set_user_driver( &null_user_driver, WINE_GDI_DRIVER_VERSION );
ret = TRUE;
}
}
else if ((size = query_reg_ascii_value( hkey, "DriverError", info, sizeof(buf) )))
{
......@@ -1024,7 +1019,7 @@ static const struct user_driver_funcs *load_driver(void)
|| (flags.dwFlags & WSF_VISIBLE))
null_user_driver.pCreateWindow = nodrv_CreateWindow;
setup_null_driver();
__wine_set_user_driver( &null_user_driver, WINE_GDI_DRIVER_VERSION );
}
return user_driver;
......@@ -1230,10 +1225,12 @@ static const struct user_driver_funcs lazy_load_driver =
const struct user_driver_funcs *user_driver = &lazy_load_driver;
/******************************************************************************
* __wine_set_display_driver (win32u.@)
* __wine_set_user_driver (win32u.@)
*/
void CDECL __wine_set_display_driver( struct user_driver_funcs *driver, UINT version )
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 win32u has %u\n",
......@@ -1241,6 +1238,9 @@ void CDECL __wine_set_display_driver( struct user_driver_funcs *driver, UINT ver
return;
}
driver = malloc( sizeof(*driver) );
*driver = *funcs;
#define SET_USER_FUNC(name) \
do { if (!driver->p##name) driver->p##name = nulldrv_##name; } while(0)
......@@ -1290,7 +1290,13 @@ void CDECL __wine_set_display_driver( struct user_driver_funcs *driver, UINT ver
SET_USER_FUNC(ThreadDetach);
#undef SET_USER_FUNC
InterlockedExchangePointer( (void **)&user_driver, driver );
prev = InterlockedCompareExchangePointer( (void **)&user_driver, driver, (void *)&lazy_load_driver );
if (prev != &lazy_load_driver)
{
/* another thread beat us to it */
free( driver );
driver = prev;
}
}
/******************************************************************************
......
......@@ -1240,7 +1240,7 @@ static struct unix_funcs unix_funcs =
__wine_get_vulkan_driver,
__wine_get_wgl_driver,
__wine_send_input,
__wine_set_display_driver,
__wine_set_user_driver,
};
NTSTATUS gdi_init(void)
......
......@@ -51,7 +51,6 @@ struct user_callbacks
void (CDECL *register_builtin_classes)(void);
BOOL (CDECL *set_menu)( HWND hwnd, HMENU menu );
void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible );
void (CDECL *set_user_driver)( void *, UINT );
BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
void **buffer, size_t size );
BOOL (WINAPI *register_imm)( HWND hwnd );
......
......@@ -4647,6 +4647,9 @@ ULONG_PTR WINAPI NtUserCallNoParam( ULONG code )
case NtUserThreadDetach:
thread_detach();
return 0;
case NtUserUpdateClipboard:
user_driver->pUpdateClipboard();
return 0;
default:
FIXME( "invalid code %u\n", code );
return 0;
......
......@@ -1322,7 +1322,7 @@
# Graphics drivers
@ cdecl __wine_send_input(long ptr ptr)
@ cdecl __wine_set_display_driver(ptr long)
@ cdecl __wine_set_user_driver(ptr long)
# OpenGL
@ cdecl __wine_get_wgl_driver(long long)
......
......@@ -303,7 +303,7 @@ struct unix_funcs
const struct vulkan_funcs * (CDECL *get_vulkan_driver)( UINT version );
struct opengl_funcs * (CDECL *get_wgl_driver)( HDC hdc, UINT version );
BOOL (CDECL *wine_send_input)( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput );
void (CDECL *set_display_driver)( struct user_driver_funcs *funcs, UINT version );
void (CDECL *set_user_driver)( const struct user_driver_funcs *funcs, UINT version );
};
/* clipboard.c */
......
......@@ -1265,12 +1265,12 @@ BOOL CDECL __wine_send_input( HWND hwnd, const INPUT *input, const RAWINPUT *raw
}
/***********************************************************************
* __wine_set_display_driver (win32u.@)
* __wine_set_user_driver (win32u.@)
*/
void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT version )
void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version )
{
if (!unix_funcs) return;
return unix_funcs->set_display_driver( funcs, version );
return unix_funcs->set_user_driver( funcs, version );
}
extern void wrappers_init( unixlib_handle_t handle )
......
......@@ -141,6 +141,7 @@ enum
/* temporary exports */
NtUserExitingThread,
NtUserThreadDetach,
NtUserUpdateClipboard,
};
/* NtUserCallOneParam codes, not compatible with Windows */
......
......@@ -331,7 +331,6 @@ struct user_driver_funcs
};
extern void CDECL __wine_set_user_driver( const struct user_driver_funcs *funcs, UINT version );
extern void CDECL __wine_set_display_driver( struct user_driver_funcs *funcs, UINT version );
extern struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );
extern const struct vulkan_funcs * CDECL __wine_get_vulkan_driver( UINT version );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment