winex11: Ignore X11 errors happening on the clipboard display connection.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2016-09-26 21:06:14 +09:00
parent a52d09198d
commit 4bbe8f90d4
3 changed files with 9 additions and 12 deletions

View File

@ -203,6 +203,8 @@ static ULONG64 last_clipboard_update;
static struct clipboard_format **current_x11_formats;
static unsigned int nb_current_x11_formats;
Display *clipboard_display = NULL;
static const char *debugstr_format( UINT id )
{
WCHAR buffer[256];
@ -259,11 +261,6 @@ static int is_atom_error( Display *display, XErrorEvent *event, void *arg )
return (event->error_code == BadAtom);
}
static int is_window_error( Display *display, XErrorEvent *event, void *arg )
{
return (event->error_code == BadWindow);
}
/**************************************************************************
* find_win32_format
@ -2007,12 +2004,12 @@ static DWORD WINAPI clipboard_thread( void *arg )
XSetWindowAttributes attr;
WNDCLASSW class;
MSG msg;
Display *display = thread_init_display();
if (!wait_clipboard_mutex()) return 0;
clipboard_display = thread_init_display();
attr.event_mask = PropertyChangeMask;
import_window = XCreateWindow( display, root_window, 0, 0, 1, 1, 0, CopyFromParent,
import_window = XCreateWindow( clipboard_display, root_window, 0, 0, 1, 1, 0, CopyFromParent,
InputOutput, CopyFromParent, CWEventMask, &attr );
if (!import_window)
{
@ -2039,7 +2036,7 @@ static DWORD WINAPI clipboard_thread( void *arg )
clipboard_thread_id = GetCurrentThreadId();
AddClipboardFormatListener( clipboard_hwnd );
register_builtin_formats();
grab_win32_clipboard( display );
grab_win32_clipboard( clipboard_display );
TRACE( "clipboard thread %04x running\n", GetCurrentThreadId() );
while (GetMessageW( &msg, 0, 0, 0 )) DispatchMessageW( &msg );
@ -2075,8 +2072,6 @@ BOOL X11DRV_SelectionRequest( HWND hwnd, XEvent *xev )
XEvent result;
Atom rprop = None;
X11DRV_expect_error( display, is_window_error, NULL );
TRACE( "got request on %lx for selection %s target %s win %lx prop %s\n",
event->owner, debugstr_xatom( event->selection ), debugstr_xatom( event->target ),
event->requestor, debugstr_xatom( event->property ));
@ -2105,8 +2100,6 @@ done:
result.xselection.time = event->time;
TRACE( "sending SelectionNotify for %s to %lx\n", debugstr_xatom( rprop ), event->requestor );
XSendEvent( display, event->requestor, False, NoEventMask, &result );
XSync( display, False );
if (X11DRV_check_error()) WARN( "requestor %lx is no longer valid\n", event->requestor );
return FALSE;
}

View File

@ -385,6 +385,7 @@ extern int copy_default_colors DECLSPEC_HIDDEN;
extern int alloc_system_colors DECLSPEC_HIDDEN;
extern int xrender_error_base DECLSPEC_HIDDEN;
extern HMODULE x11drv_module DECLSPEC_HIDDEN;
extern Display *clipboard_display DECLSPEC_HIDDEN;
/* atoms */

View File

@ -210,6 +210,9 @@ static inline BOOL ignore_error( Display *display, XErrorEvent *event )
if ((event->request_code == X_SetInputFocus || event->request_code == X_ChangeWindowAttributes) &&
(event->error_code == BadMatch || event->error_code == BadWindow)) return TRUE;
/* the clipboard display interacts with external windows, ignore all errors */
if (display == clipboard_display) return TRUE;
/* ignore a number of errors on gdi display caused by creating/destroying windows */
if (display == gdi_display)
{