diff --git a/src/xcb_io.c b/src/xcb_io.c index d40ac102..ebb9d028 100644 --- a/src/xcb_io.c +++ b/src/xcb_io.c @@ -186,6 +186,8 @@ static void process_responses(Display *dpy, int wait_for_first_event, xcb_generi int _XEventsQueued(Display *dpy, int mode) { + if(dpy->flags & XlibDisplayIOError) + return 0; if(dpy->xcb->event_owner != XlibOwnsEventQueue) return 0; @@ -202,6 +204,8 @@ int _XEventsQueued(Display *dpy, int mode) */ void _XReadEvents(Display *dpy) { + if(dpy->flags & XlibDisplayIOError) + return; _XSend(dpy, 0, 0); if(dpy->xcb->event_owner != XlibOwnsEventQueue) return; @@ -219,6 +223,8 @@ void _XReadEvents(Display *dpy) void _XSend(Display *dpy, const char *data, long size) { xcb_connection_t *c = dpy->xcb->connection; + if(dpy->flags & XlibDisplayIOError) + return; assert(!dpy->xcb->request_extra); dpy->xcb->request_extra = data; @@ -356,6 +362,9 @@ Status _XReply(Display *dpy, xReply *rep, int extra, Bool discard) assert(!dpy->xcb->reply_data); + if(dpy->flags & XlibDisplayIOError) + return 0; + /* Internals of UnlockDisplay done by hand here, so that we can insert_pending_request *after* we _XPutXCBBuffer, but before we unlock the display. */ diff --git a/src/xcb_lock.c b/src/xcb_lock.c index 96386f31..0f661c53 100644 --- a/src/xcb_lock.c +++ b/src/xcb_lock.c @@ -19,18 +19,22 @@ static void _XCBLockDisplay(Display *dpy) dpy->xcb->lock_fns.lock_display(dpy); if(!dpy->lock || dpy->lock->locking_level == 0) xcb_xlib_lock(dpy->xcb->connection); - _XGetXCBBuffer(dpy); + if(!(dpy->flags & XlibDisplayIOError)) + _XGetXCBBuffer(dpy); } static void _XCBUnlockDisplay(Display *dpy) { - _XPutXCBBuffer(dpy); - assert(dpy->xcb->partial_request == 0); - assert(xcb_get_request_sent(dpy->xcb->connection) == dpy->request); + if(!(dpy->flags & XlibDisplayIOError)) + { + _XPutXCBBuffer(dpy); + assert(dpy->xcb->partial_request == 0); + assert(xcb_get_request_sent(dpy->xcb->connection) == dpy->request); - /* Traditional Xlib does this in _XSend; see the Xlib/XCB version - * of that function for why we do it here instead. */ - _XSetSeqSyncFunction(dpy); + /* Traditional Xlib does this in _XSend; see the Xlib/XCB version + * of that function for why we do it here instead. */ + _XSetSeqSyncFunction(dpy); + } if(!dpy->lock || dpy->lock->locking_level == 0) xcb_xlib_unlock(dpy->xcb->connection);