Commit 9f514fe2 authored by Alexandre Julliard's avatar Alexandre Julliard

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.
parent a34a6d84
......@@ -419,6 +419,7 @@ static void set_focus( HWND hwnd, Time time )
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" );
}
}
......
......@@ -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 void *err_callback_arg; /* error callback argument */
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 * );
#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 )
{
wine_tsx11_lock();
XSync( display, False );
err_callback = callback;
err_callback_display = display;
err_callback_arg = arg;
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.
* 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 ret;
XSync( err_callback_display, False );
err_callback = NULL;
ret = err_callback_result;
wine_tsx11_unlock();
......@@ -139,7 +140,8 @@ int X11DRV_check_error(void)
*/
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 )))
{
......
......@@ -5674,6 +5674,7 @@ static XImage *X11DRV_XShmCreateImage( int width, int height, int bpp,
shminfo->readOnly = FALSE;
X11DRV_expect_error( gdi_display, XShmErrorHandler, NULL );
ok = (XShmAttach( gdi_display, shminfo ) != 0);
XSync( gdi_display, False );
if (X11DRV_check_error()) ok = FALSE;
if (ok)
{
......
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