Commit 5ee04c24 authored by Ulrich Sibiller's avatar Ulrich Sibiller

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 17f3e3bc
...@@ -73,6 +73,7 @@ XIfEvent (dpy, event, predicate, arg) ...@@ -73,6 +73,7 @@ XIfEvent (dpy, event, predicate, arg)
prev = NULL; prev = NULL;
#ifdef NX_TRANS_SOCKET #ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) { if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0; return 0;
} }
#endif #endif
......
...@@ -77,6 +77,7 @@ XMaskEvent (dpy, mask, event) ...@@ -77,6 +77,7 @@ XMaskEvent (dpy, mask, event)
prev = NULL; prev = NULL;
#ifdef NX_TRANS_SOCKET #ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) { if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0; return 0;
} }
#endif #endif
......
...@@ -48,6 +48,12 @@ XNextEvent (dpy, event) ...@@ -48,6 +48,12 @@ XNextEvent (dpy, event)
if (dpy->head == NULL) if (dpy->head == NULL)
_XReadEvents(dpy); _XReadEvents(dpy);
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0;
}
#endif
qelt = dpy->head; qelt = dpy->head;
*event = qelt->event; *event = qelt->event;
_XDeq(dpy, NULL, qelt); _XDeq(dpy, NULL, qelt);
......
...@@ -46,6 +46,12 @@ XPeekEvent (dpy, event) ...@@ -46,6 +46,12 @@ XPeekEvent (dpy, event)
LockDisplay(dpy); LockDisplay(dpy);
if (dpy->head == NULL) if (dpy->head == NULL)
_XReadEvents(dpy); _XReadEvents(dpy);
#ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 1;
}
#endif
*event = (dpy->head)->event; *event = (dpy->head)->event;
UnlockDisplay(dpy); UnlockDisplay(dpy);
return 1; return 1;
......
...@@ -73,6 +73,7 @@ XPeekIfEvent (dpy, event, predicate, arg) ...@@ -73,6 +73,7 @@ XPeekIfEvent (dpy, event, predicate, arg)
prev = NULL; prev = NULL;
#ifdef NX_TRANS_SOCKET #ifdef NX_TRANS_SOCKET
if (_XGetIOError(dpy)) { if (_XGetIOError(dpy)) {
UnlockDisplay(dpy);
return 0; return 0;
} }
#endif #endif
......
...@@ -79,5 +79,11 @@ XWindowEvent (dpy, w, mask, event) ...@@ -79,5 +79,11 @@ XWindowEvent (dpy, w, mask, event)
if (prev && prev->qserial_num != qe_serial) if (prev && prev->qserial_num != qe_serial)
/* another thread has snatched this event */ /* another thread has snatched this event */
prev = NULL; 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