Avoid the XSync call in X11DRV_expect_error by storing the current

request number and checking that on errors.
Moved the XSync call from X11DRV_check_error into the callers so that
it can be avoided for requests that already wait for a reply.
This commit is contained in:
Alexandre Julliard 2003-11-09 00:34:43 +00:00
parent a34a6d84ce
commit 9f514fe239
3 changed files with 7 additions and 3 deletions

View File

@ -419,6 +419,7 @@ static void set_focus( HWND hwnd, Time time )
TRACE( "setting focus to %p (%lx) time=%ld\n", focus, win, time ); TRACE( "setting focus to %p (%lx) time=%ld\n", focus, win, time );
X11DRV_expect_error( display, set_focus_error_handler, NULL ); X11DRV_expect_error( display, set_focus_error_handler, NULL );
XSetInputFocus( display, win, RevertToParent, time ); XSetInputFocus( display, win, RevertToParent, time );
XSync( display, False );
if (X11DRV_check_error()) TRACE("got BadMatch, ignoring\n" ); if (X11DRV_check_error()) TRACE("got BadMatch, ignoring\n" );
} }
} }

View File

@ -91,6 +91,7 @@ static x11drv_error_callback err_callback; /* current callback for error */
static Display *err_callback_display; /* display callback is set for */ static Display *err_callback_display; /* display callback is set for */
static void *err_callback_arg; /* error callback argument */ static void *err_callback_arg; /* error callback argument */
static int err_callback_result; /* error callback result */ static int err_callback_result; /* error callback result */
static unsigned long err_serial; /* serial number of first request */
static int (*old_error_handler)( Display *, XErrorEvent * ); static int (*old_error_handler)( Display *, XErrorEvent * );
#define IS_OPTION_TRUE(ch) \ #define IS_OPTION_TRUE(ch) \
@ -109,11 +110,11 @@ static int (*old_error_handler)( Display *, XErrorEvent * );
void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg ) void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg )
{ {
wine_tsx11_lock(); wine_tsx11_lock();
XSync( display, False );
err_callback = callback; err_callback = callback;
err_callback_display = display; err_callback_display = display;
err_callback_arg = arg; err_callback_arg = arg;
err_callback_result = 0; err_callback_result = 0;
err_serial = NextRequest(display);
} }
@ -122,11 +123,11 @@ void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void
* *
* Check if an expected X11 error occurred; return non-zero if yes. * Check if an expected X11 error occurred; return non-zero if yes.
* Also release the x11 lock obtained in X11DRV_expect_error. * Also release the x11 lock obtained in X11DRV_expect_error.
* The caller is responsible for calling XSync first if necessary.
*/ */
int X11DRV_check_error(void) int X11DRV_check_error(void)
{ {
int ret; int ret;
XSync( err_callback_display, False );
err_callback = NULL; err_callback = NULL;
ret = err_callback_result; ret = err_callback_result;
wine_tsx11_unlock(); wine_tsx11_unlock();
@ -139,7 +140,8 @@ int X11DRV_check_error(void)
*/ */
static int error_handler( Display *display, XErrorEvent *error_evt ) static int error_handler( Display *display, XErrorEvent *error_evt )
{ {
if (err_callback && display == err_callback_display) if (err_callback && display == err_callback_display &&
(long)(error_evt->serial - err_serial) >= 0)
{ {
if ((err_callback_result = err_callback( display, error_evt, err_callback_arg ))) if ((err_callback_result = err_callback( display, error_evt, err_callback_arg )))
{ {

View File

@ -5674,6 +5674,7 @@ static XImage *X11DRV_XShmCreateImage( int width, int height, int bpp,
shminfo->readOnly = FALSE; shminfo->readOnly = FALSE;
X11DRV_expect_error( gdi_display, XShmErrorHandler, NULL ); X11DRV_expect_error( gdi_display, XShmErrorHandler, NULL );
ok = (XShmAttach( gdi_display, shminfo ) != 0); ok = (XShmAttach( gdi_display, shminfo ) != 0);
XSync( gdi_display, False );
if (X11DRV_check_error()) ok = FALSE; if (X11DRV_check_error()) ok = FALSE;
if (ok) if (ok)
{ {