Commit b7d7ff3e authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mike Gabriel

libX11: Extend Event functions to handle IOErrors

To allow for suspend/resume NX has changed _XReadEvents() and _XIOError(). _XIOError() does not simply exit but returns. And _XReadEvents() returns after _XIOError(). But as the original _XReadEvents() is supposed to block until at least one event is there calling functions are not prepared for situations where no event is available. These calling functions have to check that condition., Some of the calling functions already had that check but the UnlockDisplay() call was missing. Fixes https://github.com/ArcticaProject/nx-libs/issues/118
parent e079b0b3
......@@ -73,6 +73,7 @@ XIfEvent (dpy, event, predicate, arg)
prev = NULL;
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0;
}
#endif
......
......@@ -77,6 +77,7 @@ XMaskEvent (dpy, mask, event)
prev = NULL;
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0;
}
#endif
......
......@@ -48,6 +48,12 @@ XNextEvent (dpy, event)
if (dpy->head == NULL)
_XReadEvents(dpy);
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0;
}
#endif
qelt = dpy->head;
*event = qelt->event;
_XDeq(dpy, NULL, qelt);
......
......@@ -46,6 +46,12 @@ XPeekEvent (dpy, event)
LockDisplay(dpy);
if (dpy->head == NULL)
_XReadEvents(dpy);
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 1;
}
#endif
*event = (dpy->head)->event;
UnlockDisplay(dpy);
return 1;
......
......@@ -73,6 +73,7 @@ XPeekIfEvent (dpy, event, predicate, arg)
prev = NULL;
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0;
}
#endif
......
......@@ -79,5 +79,11 @@ XWindowEvent (dpy, w, mask, event)
if (prev && prev->qserial_num != qe_serial)
/* another thread has snatched this event */
prev = NULL;
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0;
}
#endif
}
}
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