From 720af28ea4daab70b198ba9925c60db165890483 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 21 Nov 2003 05:30:34 +0000 Subject: [PATCH] Always ignore BadMatch errors resulting from XSetInputFocus so that we don't need to wait for the reply. --- dlls/x11drv/event.c | 19 +++---------------- dlls/x11drv/x11drv_main.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/dlls/x11drv/event.c b/dlls/x11drv/event.c index 78ee890a97b..061f5856aa2 100644 --- a/dlls/x11drv/event.c +++ b/dlls/x11drv/event.c @@ -381,17 +381,6 @@ inline static BOOL can_activate_window( HWND hwnd ) } -/********************************************************************** - * set_focus_error_handler - * - * Handler for X errors happening during XSetInputFocus call. - */ -static int set_focus_error_handler( Display *display, XErrorEvent *event, void *arg ) -{ - return (event->error_code == BadMatch); -} - - /********************************************************************** * set_focus */ @@ -409,12 +398,10 @@ static void set_focus( HWND hwnd, Time time ) if (win) { - Display *display = thread_display(); TRACE( "setting focus to %p (%lx) time=%ld\n", focus, win, time ); - X11DRV_expect_error( display, set_focus_error_handler, NULL ); - XSetInputFocus( display, win, RevertToParent, time ); - XSync( display, False ); - if (X11DRV_check_error()) TRACE("got BadMatch, ignoring\n" ); + wine_tsx11_lock(); + XSetInputFocus( thread_display(), win, RevertToParent, time ); + wine_tsx11_unlock(); } } diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c index d2c196c86d2..77baba1786a 100644 --- a/dlls/x11drv/x11drv_main.c +++ b/dlls/x11drv/x11drv_main.c @@ -38,6 +38,18 @@ #include #endif +#define BOOL X_BOOL +#define BYTE X_BYTE +#define INT8 X_INT8 +#define INT16 X_INT16 +#define INT32 X_INT32 +#include +#undef BOOL +#undef BYTE +#undef INT8 +#undef INT16 +#undef INT32 + #include "windef.h" #include "winbase.h" #include "wine/winbase16.h" @@ -99,6 +111,18 @@ static int (*old_error_handler)( Display *, XErrorEvent * ); #define IS_OPTION_FALSE(ch) \ ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0') +/*********************************************************************** + * ignore_error + * + * Check if the X error is one we can ignore. + */ +static inline BOOL ignore_error( Display *display, XErrorEvent *event ) +{ + if (event->request_code == X_SetInputFocus && event->error_code == BadMatch) return TRUE; + return FALSE; +} + + /*********************************************************************** * X11DRV_expect_error * @@ -145,10 +169,17 @@ static int error_handler( Display *display, XErrorEvent *error_evt ) { if ((err_callback_result = err_callback( display, error_evt, err_callback_arg ))) { - TRACE( "got expected error\n" ); + TRACE( "got expected error %d req %d\n", + error_evt->error_code, error_evt->request_code ); return 0; } } + if (ignore_error( display, error_evt )) + { + TRACE( "got ignored error %d req %d\n", + error_evt->error_code, error_evt->request_code ); + return 0; + } if (synchronous) DebugBreak(); /* force an entry in the debugger */ old_error_handler( display, error_evt ); return 0;