Commit 6f825503 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winex11: Use ClipboardWindowProc driver entry point for clipboard manager.

parent d8a74e5c
......@@ -2215,7 +2215,7 @@ static void xfixes_init(void)
/**************************************************************************
* clipboard_thread
* clipboard_init
*
* Thread running inside the desktop process to manage the clipboard
*/
......@@ -2250,20 +2250,18 @@ static BOOL clipboard_init( HWND hwnd )
/**************************************************************************
* x11drv_clipboard_message
*/
NTSTATUS x11drv_clipboard_message( void *arg )
LRESULT X11DRV_ClipboardWindowProc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
{
struct clipboard_message_params *params = arg;
switch (params->msg)
switch (msg)
{
case WM_NCCREATE:
return clipboard_init( params->hwnd );
return clipboard_init( hwnd );
case WM_CLIPBOARDUPDATE:
if (is_clipboard_owner) break; /* ignore our own changes */
acquire_selection( thread_init_display() );
break;
case WM_RENDERFORMAT:
if (render_format( params->wparam )) rendered_formats++;
if (render_format( wparam )) rendered_formats++;
break;
case WM_TIMER:
if (!is_clipboard_owner) break;
......@@ -2272,12 +2270,11 @@ NTSTATUS x11drv_clipboard_message( void *arg )
case WM_DESTROYCLIPBOARD:
TRACE( "WM_DESTROYCLIPBOARD: lost ownership\n" );
is_clipboard_owner = FALSE;
NtUserKillTimer( params->hwnd, 1 );
NtUserKillTimer( hwnd, 1 );
break;
}
return NtUserMessageCall( params->hwnd, params->msg, params->wparam, params->lparam,
NULL, NtUserDefWindowProc, FALSE );
return NtUserMessageCall( hwnd, msg, wparam, lparam, NULL, NtUserDefWindowProc, FALSE );
}
......
......@@ -21,112 +21,11 @@
#include "x11drv_dll.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
HMODULE x11drv_module = 0;
static unixlib_handle_t x11drv_handle;
NTSTATUS (CDECL *x11drv_unix_call)( enum x11drv_funcs code, void *params );
/**************************************************************************
* wait_clipboard_mutex
*
* Make sure that there's only one clipboard thread per window station.
*/
static BOOL wait_clipboard_mutex(void)
{
static const WCHAR prefix[] = {'_','_','w','i','n','e','_','c','l','i','p','b','o','a','r','d','_'};
WCHAR buffer[MAX_PATH + ARRAY_SIZE( prefix )];
HANDLE mutex;
memcpy( buffer, prefix, sizeof(prefix) );
if (!GetUserObjectInformationW( GetProcessWindowStation(), UOI_NAME,
buffer + ARRAY_SIZE( prefix ),
sizeof(buffer) - sizeof(prefix), NULL ))
{
ERR( "failed to get winstation name\n" );
return FALSE;
}
mutex = CreateMutexW( NULL, TRUE, buffer );
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
TRACE( "waiting for mutex %s\n", debugstr_w( buffer ));
WaitForSingleObject( mutex, INFINITE );
}
return TRUE;
}
/**************************************************************************
* clipboard_wndproc
*
* Window procedure for the clipboard manager.
*/
static LRESULT CALLBACK clipboard_wndproc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
{
struct clipboard_message_params params;
switch (msg)
{
case WM_NCCREATE:
case WM_CLIPBOARDUPDATE:
case WM_RENDERFORMAT:
case WM_TIMER:
case WM_DESTROYCLIPBOARD:
params.hwnd = hwnd;
params.msg = msg;
params.wparam = wp;
params.lparam = lp;
return X11DRV_CALL( clipboard_message, &params );
}
return DefWindowProcW( hwnd, msg, wp, lp );
}
/**************************************************************************
* clipboard_thread
*
* Thread running inside the desktop process to manage the clipboard
*/
static DWORD WINAPI clipboard_thread( void *arg )
{
static const WCHAR clipboard_classname[] = {'_','_','w','i','n','e','_','c','l','i','p','b','o','a','r','d','_','m','a','n','a','g','e','r',0};
WNDCLASSW class;
MSG msg;
if (!wait_clipboard_mutex()) return 0;
memset( &class, 0, sizeof(class) );
class.lpfnWndProc = clipboard_wndproc;
class.lpszClassName = clipboard_classname;
if (!RegisterClassW( &class ) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS)
{
ERR( "could not register clipboard window class err %u\n", GetLastError() );
return 0;
}
if (!CreateWindowW( clipboard_classname, NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, 0, NULL ))
{
ERR( "failed to create clipboard window err %u\n", GetLastError() );
return 0;
}
while (GetMessageW( &msg, 0, 0, 0 )) DispatchMessageW( &msg );
return 0;
}
static NTSTATUS x11drv_clipboard_init( UINT arg )
{
DWORD id;
HANDLE thread = CreateThread( NULL, 0, clipboard_thread, NULL, 0, &id );
if (thread) CloseHandle( thread );
else ERR( "failed to create clipboard thread\n" );
return 0;
}
static NTSTATUS x11drv_load_icon( UINT id )
{
......@@ -137,7 +36,6 @@ static NTSTATUS x11drv_load_icon( UINT id )
typedef NTSTATUS (*callback_func)( UINT arg );
static const callback_func callback_funcs[] =
{
x11drv_clipboard_init,
x11drv_dnd_drop_event,
x11drv_dnd_leave_event,
x11drv_ime_get_cursor_pos,
......
......@@ -425,6 +425,7 @@ static const struct user_driver_funcs x11drv_funcs =
.pSetWindowText = X11DRV_SetWindowText,
.pShowWindow = X11DRV_ShowWindow,
.pSysCommand = X11DRV_SysCommand,
.pClipboardWindowProc = X11DRV_ClipboardWindowProc,
.pUpdateClipboard = X11DRV_UpdateClipboard,
.pUpdateLayeredWindow = X11DRV_UpdateLayeredWindow,
.pWindowMessage = X11DRV_WindowMessage,
......
......@@ -21,7 +21,6 @@
enum x11drv_funcs
{
unix_clipboard_message,
unix_create_desktop,
unix_init,
unix_systray_clear,
......@@ -41,15 +40,6 @@ enum x11drv_funcs
extern NTSTATUS (CDECL *x11drv_unix_call)( enum x11drv_funcs code, void *params ) DECLSPEC_HIDDEN;
#define X11DRV_CALL(func, params) x11drv_unix_call( unix_ ## func, params )
/* x11drv_clipboard_message params */
struct clipboard_message_params
{
HWND hwnd;
UINT msg;
WPARAM wparam;
LPARAM lparam;
};
/* x11drv_create_desktop params */
struct create_desktop_params
{
......@@ -108,7 +98,6 @@ C_ASSERT( client_func_last <= NtUserDriverCallbackLast + 1 );
/* simplified interface for client callbacks requiring only a single UINT parameter */
enum client_callback
{
client_clipboard_init,
client_dnd_drop_event,
client_dnd_leave_event,
client_ime_get_cursor_pos,
......
......@@ -1913,7 +1913,6 @@ BOOL X11DRV_CreateWindow( HWND hwnd )
CWOverrideRedirect | CWEventMask, &attr );
XFlush( data->display );
NtUserSetProp( hwnd, clip_window_prop, (HANDLE)data->clip_window );
x11drv_client_call( client_clipboard_init, 0 );
X11DRV_DisplayDevices_RegisterEventHandlers();
}
return TRUE;
......
......@@ -238,6 +238,7 @@ extern void X11DRV_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style ) D
extern void X11DRV_SetWindowText( HWND hwnd, LPCWSTR text ) DECLSPEC_HIDDEN;
extern UINT X11DRV_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp ) DECLSPEC_HIDDEN;
extern LRESULT X11DRV_SysCommand( HWND hwnd, WPARAM wparam, LPARAM lparam ) DECLSPEC_HIDDEN;
extern LRESULT X11DRV_ClipboardWindowProc( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp ) DECLSPEC_HIDDEN;
extern void X11DRV_UpdateClipboard(void) DECLSPEC_HIDDEN;
extern BOOL X11DRV_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info,
const RECT *window_rect ) DECLSPEC_HIDDEN;
......@@ -833,7 +834,6 @@ static inline BOOL is_window_rect_mapped( const RECT *rect )
/* unixlib interface */
extern NTSTATUS x11drv_clipboard_message( void *arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_create_desktop( void *arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_systray_clear( void *arg ) DECLSPEC_HIDDEN;
extern NTSTATUS x11drv_systray_dock( void *arg ) DECLSPEC_HIDDEN;
......
......@@ -1302,7 +1302,6 @@ NTSTATUS x11drv_client_call( enum client_callback func, UINT arg )
const unixlib_entry_t __wine_unix_call_funcs[] =
{
x11drv_clipboard_message,
x11drv_create_desktop,
x11drv_init,
x11drv_systray_clear,
......
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