diff --git a/boilerplate/cairo-boilerplate-xcb.c b/boilerplate/cairo-boilerplate-xcb.c index 67c8163c0..e45a2dc18 100644 --- a/boilerplate/cairo-boilerplate-xcb.c +++ b/boilerplate/cairo-boilerplate-xcb.c @@ -78,6 +78,13 @@ _cairo_boilerplate_xcb_handle_errors (xcb_target_closure_t *xtc) return CAIRO_STATUS_SUCCESS; } +static void +_cairo_boilerplate_xcb_sync_server (xcb_target_closure_t *xtc) +{ + free (xcb_get_input_focus_reply (xtc->c, + xcb_get_input_focus (xtc->c), NULL)); +} + static void _cairo_boilerplate_xcb_cleanup (void *closure) { @@ -93,6 +100,9 @@ _cairo_boilerplate_xcb_cleanup (void *closure) cairo_device_finish (xtc->device); cairo_device_destroy (xtc->device); + /* First synchronize with the X server to make sure there are no more errors + * in-flight which we would miss otherwise */ + _cairo_boilerplate_xcb_sync_server (xtc); status = _cairo_boilerplate_xcb_handle_errors (xtc); assert (status == CAIRO_STATUS_SUCCESS); @@ -637,6 +647,9 @@ _cairo_boilerplate_xcb_finish_surface (cairo_surface_t *surface) if (cairo_surface_status (surface)) return cairo_surface_status (surface); + /* First synchronize with the X server to make sure there are no more errors + * in-flight which we would miss otherwise */ + _cairo_boilerplate_xcb_sync_server (xtc); status = _cairo_boilerplate_xcb_handle_errors (xtc); if (status) return status;