aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11/PutBEvent.c
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/lib/X11/PutBEvent.c')
-rw-r--r--nx-X11/lib/X11/PutBEvent.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/nx-X11/lib/X11/PutBEvent.c b/nx-X11/lib/X11/PutBEvent.c
index 63c92e627..f9d4c29bd 100644
--- a/nx-X11/lib/X11/PutBEvent.c
+++ b/nx-X11/lib/X11/PutBEvent.c
@@ -34,10 +34,11 @@ from The Open Group.
int
_XPutBackEvent (
- register Display *dpy,
+ register Display *dpy,
register XEvent *event)
{
register _XQEvent *qelt;
+ XEvent store = *event;
if (!dpy->qfree) {
if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
@@ -45,11 +46,26 @@ _XPutBackEvent (
}
dpy->qfree->next = NULL;
}
+
+ /* unclaimed cookie? */
+ if (_XIsEventCookie(dpy, event))
+ {
+ XEvent copy = {0};
+ /* if not claimed, then just fetch and store again */
+ if (!event->xcookie.data) {
+ _XFetchEventCookie(dpy, &event->xcookie);
+ store = *event;
+ } else { /* if claimed, copy, client must free */
+ _XCopyEventCookie(dpy, &event->xcookie, &copy.xcookie);
+ store = copy;
+ }
+ }
+
qelt = dpy->qfree;
dpy->qfree = qelt->next;
qelt->qserial_num = dpy->next_event_serial_num++;
qelt->next = dpy->head;
- qelt->event = *event;
+ qelt->event = store;
dpy->head = qelt;
if (dpy->tail == NULL)
dpy->tail = qelt;
@@ -59,7 +75,7 @@ _XPutBackEvent (
int
XPutBackEvent (
- register Display * dpy,
+ register Display * dpy,
register XEvent *event)
{
int ret;