aboutsummaryrefslogtreecommitdiff
path: root/libX11/src
diff options
context:
space:
mode:
Diffstat (limited to 'libX11/src')
-rw-r--r--libX11/src/ChkIfEv.c1
-rw-r--r--libX11/src/ChkMaskEv.c4
-rw-r--r--libX11/src/ChkTypEv.c4
-rw-r--r--libX11/src/ChkTypWEv.c4
-rw-r--r--libX11/src/ChkWinEv.c4
-rw-r--r--libX11/src/FreeEventData.c42
-rw-r--r--libX11/src/GetEventData.c42
-rw-r--r--libX11/src/IfEvent.c1
-rw-r--r--libX11/src/InitExt.c43
-rw-r--r--libX11/src/Makefile.am5
-rw-r--r--libX11/src/Makefile.in229
-rw-r--r--libX11/src/MaskEvent.c4
-rw-r--r--libX11/src/NextEvent.c4
-rw-r--r--libX11/src/OpenDis.c11
-rw-r--r--libX11/src/PeekEvent.c5
-rw-r--r--libX11/src/PeekIfEv.c5
-rw-r--r--libX11/src/PutBEvent.c18
-rw-r--r--libX11/src/WinEvent.c4
-rw-r--r--libX11/src/XlibInt.c183
-rw-r--r--libX11/src/makefile2
-rw-r--r--libX11/src/utlist.h116
21 files changed, 614 insertions, 117 deletions
diff --git a/libX11/src/ChkIfEv.c b/libX11/src/ChkIfEv.c
index 9bef64f89..66f0c3c98 100644
--- a/libX11/src/ChkIfEv.c
+++ b/libX11/src/ChkIfEv.c
@@ -62,6 +62,7 @@ Bool XCheckIfEvent (
&& (*predicate)(dpy, &qelt->event, arg)) {
*event = qelt->event;
_XDeq(dpy, prev, qelt);
+ _XStoreEventCookie(dpy, event);
UnlockDisplay(dpy);
return True;
}
diff --git a/libX11/src/ChkMaskEv.c b/libX11/src/ChkMaskEv.c
index bc1a279f1..6fb71c9e0 100644
--- a/libX11/src/ChkMaskEv.c
+++ b/libX11/src/ChkMaskEv.c
@@ -54,6 +54,10 @@ Bool XCheckMaskEvent (
int n; /* time through count */
LockDisplay(dpy);
+
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
prev = NULL;
for (n = 3; --n >= 0;) {
for (qelt = prev ? prev->next : dpy->head;
diff --git a/libX11/src/ChkTypEv.c b/libX11/src/ChkTypEv.c
index fc4c7d187..f64ebd335 100644
--- a/libX11/src/ChkTypEv.c
+++ b/libX11/src/ChkTypEv.c
@@ -48,6 +48,10 @@ Bool XCheckTypedEvent (
int n; /* time through count */
LockDisplay(dpy);
+
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
prev = NULL;
for (n = 3; --n >= 0;) {
for (qelt = prev ? prev->next : dpy->head;
diff --git a/libX11/src/ChkTypWEv.c b/libX11/src/ChkTypWEv.c
index 6214c3654..d791eb255 100644
--- a/libX11/src/ChkTypWEv.c
+++ b/libX11/src/ChkTypWEv.c
@@ -49,6 +49,10 @@ Bool XCheckTypedWindowEvent (
int n; /* time through count */
LockDisplay(dpy);
+
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
prev = NULL;
for (n = 3; --n >= 0;) {
for (qelt = prev ? prev->next : dpy->head;
diff --git a/libX11/src/ChkWinEv.c b/libX11/src/ChkWinEv.c
index 1fd975cda..b753c5fd8 100644
--- a/libX11/src/ChkWinEv.c
+++ b/libX11/src/ChkWinEv.c
@@ -54,6 +54,10 @@ Bool XCheckWindowEvent (
int n; /* time through count */
LockDisplay(dpy);
+
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
prev = NULL;
for (n = 3; --n >= 0;) {
for (qelt = prev ? prev->next : dpy->head;
diff --git a/libX11/src/FreeEventData.c b/libX11/src/FreeEventData.c
new file mode 100644
index 000000000..e2d40b0db
--- /dev/null
+++ b/libX11/src/FreeEventData.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+void
+XFreeEventData(Display *dpy, XGenericEventCookie *event)
+{
+
+ if (_XIsEventCookie(dpy, (XEvent*)event) && event->data)
+ {
+ XFree(event->data);
+ event->data = NULL;
+ event->cookie = 0;
+ }
+ return;
+}
+
diff --git a/libX11/src/GetEventData.c b/libX11/src/GetEventData.c
new file mode 100644
index 000000000..b93dee6cd
--- /dev/null
+++ b/libX11/src/GetEventData.c
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include "Xlibint.h"
+
+Bool
+XGetEventData(Display *dpy, XGenericEventCookie *event)
+{
+ Bool rc;
+ LockDisplay(dpy);
+
+ rc = _XFetchEventCookie(dpy, event);
+
+ UnlockDisplay(dpy);
+
+ return rc;
+}
+
diff --git a/libX11/src/IfEvent.c b/libX11/src/IfEvent.c
index 05a2b82cb..64c8f465b 100644
--- a/libX11/src/IfEvent.c
+++ b/libX11/src/IfEvent.c
@@ -61,6 +61,7 @@ XIfEvent (
&& (*predicate)(dpy, &qelt->event, arg)) {
*event = qelt->event;
_XDeq(dpy, prev, qelt);
+ _XStoreEventCookie(dpy, event);
UnlockDisplay(dpy);
return 0;
}
diff --git a/libX11/src/InitExt.c b/libX11/src/InitExt.c
index 92fc44afa..0e6c94ee6 100644
--- a/libX11/src/InitExt.c
+++ b/libX11/src/InitExt.c
@@ -253,6 +253,49 @@ WireToEventType XESetWireToEvent(
return (WireToEventType)oldproc;
}
+typedef Bool (*WireToEventCookieType) (
+ Display* /* display */,
+ XGenericEventCookie* /* re */,
+ xEvent* /* event */
+);
+
+WireToEventCookieType XESetWireToEventCookie(
+ Display *dpy, /* display */
+ int extension, /* extension major opcode */
+ WireToEventCookieType proc /* routine to call for generic events */
+ )
+{
+ WireToEventCookieType oldproc;
+ if (proc == NULL) proc = (WireToEventCookieType)_XUnknownWireEventCookie;
+ LockDisplay (dpy);
+ oldproc = dpy->generic_event_vec[extension & 0x7F];
+ dpy->generic_event_vec[extension & 0x7F] = proc;
+ UnlockDisplay (dpy);
+ return (WireToEventCookieType)oldproc;
+}
+
+typedef Bool (*CopyEventCookieType) (
+ Display* /* display */,
+ XGenericEventCookie* /* in */,
+ XGenericEventCookie* /* out */
+);
+
+CopyEventCookieType XESetCopyEventCookie(
+ Display *dpy, /* display */
+ int extension, /* extension major opcode */
+ CopyEventCookieType proc /* routine to copy generic events */
+ )
+{
+ CopyEventCookieType oldproc;
+ if (proc == NULL) proc = (CopyEventCookieType)_XUnknownCopyEventCookie;
+ LockDisplay (dpy);
+ oldproc = dpy->generic_event_copy_vec[extension & 0x7F];
+ dpy->generic_event_copy_vec[extension & 0x7F] = proc;
+ UnlockDisplay (dpy);
+ return (CopyEventCookieType)oldproc;
+}
+
+
typedef Status (*EventToWireType) (
Display* /* display */,
XEvent* /* re */,
diff --git a/libX11/src/Makefile.am b/libX11/src/Makefile.am
index 86a846e41..26d8e277f 100644
--- a/libX11/src/Makefile.am
+++ b/libX11/src/Makefile.am
@@ -130,6 +130,7 @@ libX11_la_SOURCES = \
FreeCols.c \
FreeCurs.c \
FreeEData.c \
+ FreeEventData.c \
FreeGC.c \
FreePix.c \
FSSaver.c \
@@ -139,6 +140,7 @@ libX11_la_SOURCES = \
GetAtomNm.c \
GetColor.c \
GetDflt.c \
+ GetEventData.c \
GetFPath.c \
GetFProp.c \
GetGCVals.c \
@@ -297,6 +299,7 @@ libX11_la_SOURCES = \
UnldFont.c \
UnmapSubs.c \
UnmapWin.c \
+ utlist.h \
VisUtil.c \
WarpPtr.c \
Window.c \
@@ -373,7 +376,7 @@ if XKB
USE_XKB_LIBS = $(XKB_LIBS)
endif
-libX11_la_LDFLAGS = -version-number 6:2:0 -no-undefined
+libX11_la_LDFLAGS = -version-number 6:3:0 -no-undefined
libX11_la_LIBADD = \
$(USE_I18N_LIBS) \
diff --git a/libX11/src/Makefile.in b/libX11/src/Makefile.in
index ef4df0a71..1d377c9e0 100644
--- a/libX11/src/Makefile.in
+++ b/libX11/src/Makefile.in
@@ -114,43 +114,43 @@ am__libX11_la_SOURCES_DIST = AllCells.c AllowEv.c AllPlanes.c \
DrRects.c DrSegs.c ErrDes.c ErrHndlr.c evtomask.c EvToWire.c \
FetchName.c FillArc.c FillArcs.c FillPoly.c FillRct.c \
FillRcts.c FilterEv.c Flush.c Font.c FontInfo.c FontNames.c \
- FreeCmap.c FreeCols.c FreeCurs.c FreeEData.c FreeGC.c \
- FreePix.c FSSaver.c FSWrap.c GCMisc.c Geom.c GetAtomNm.c \
- GetColor.c GetDflt.c GetFPath.c GetFProp.c GetGCVals.c \
- GetGeom.c GetHColor.c GetHints.c GetIFocus.c GetImage.c \
- GetKCnt.c GetMoEv.c GetNrmHint.c GetPCnt.c GetPntMap.c \
- GetProp.c GetRGBCMap.c GetSOwner.c GetSSaver.c GetStCmap.c \
- GetTxtProp.c GetWAttrs.c GetWMCMapW.c GetWMProto.c globals.c \
- GrButton.c GrKeybd.c GrKey.c GrPointer.c GrServer.c Host.c \
- Iconify.c IfEvent.c imConv.c ImText16.c ImText.c ImUtil.c \
- InitExt.c InsCmap.c IntAtom.c KeyBind.c Key.h KeysymStr.c \
- KillCl.c LiHosts.c LiICmaps.c LiProps.c ListExt.c LoadFont.c \
- LockDis.c locking.c locking.h LookupCol.c LowerWin.c Macros.c \
- MapRaised.c MapSubs.c MapWindow.c MaskEvent.c Misc.c ModMap.c \
- MoveWin.c NextEvent.c OCWrap.c OMWrap.c OpenDis.c ParseCmd.c \
- ParseCol.c ParseGeom.c PeekEvent.c PeekIfEv.c Pending.c \
- PixFormats.c PmapBgnd.c PmapBord.c poly.h PolyReg.c \
- PolyTxt16.c PolyTxt.c PropAlloc.c PutBEvent.c PutImage.c \
- Quarks.c QuBest.c QuColor.c QuColors.c QuCurShp.c QuExt.c \
- QuKeybd.c QuPntr.c QuStipShp.c QuTextE16.c QuTextExt.c \
- QuTileShp.c QuTree.c RaiseWin.c RdBitF.c RecolorC.c \
- ReconfWin.c ReconfWM.c Region.c RegstFlt.c RepWindow.c \
- RestackWs.c RotProp.c ScrResStr.c SelInput.c SendEvent.c \
- SetBack.c SetClMask.c SetClOrig.c SetCRects.c SetDashes.c \
- SetFont.c SetFore.c SetFPath.c SetFunc.c SetHints.c \
- SetIFocus.c SetLocale.c SetLStyle.c SetNrmHint.c SetPMask.c \
- SetPntMap.c SetRGBCMap.c SetSOwner.c SetSSaver.c SetState.c \
- SetStCmap.c SetStip.c SetTile.c SetTSOrig.c SetTxtProp.c \
- SetWMCMapW.c SetWMProto.c StBytes.c StColor.c StColors.c \
- StName.c StNColor.c StrKeysym.c StrToText.c Sync.c Synchro.c \
- Text16.c Text.c TextExt16.c TextExt.c TextToStr.c TrCoords.c \
- UndefCurs.c UngrabBut.c UngrabKbd.c UngrabKey.c UngrabPtr.c \
- UngrabSvr.c UninsCmap.c UnldFont.c UnmapSubs.c UnmapWin.c \
- VisUtil.c WarpPtr.c Window.c WinEvent.c Withdraw.c WMGeom.c \
- WMProps.c WrBitF.c Xatomtype.h Xintatom.h Xintconn.h \
- XlibAsync.c XlibInt.c Xprivate.h XomGeneric.h Xresinternal.h \
- Xrm.c XrmI.h os2Stubs.c udcInf.c UIThrStubs.c xcb_disp.c \
- xcb_io.c Xxcbint.h ConnDis.c x11_trans.c
+ FreeCmap.c FreeCols.c FreeCurs.c FreeEData.c FreeEventData.c \
+ FreeGC.c FreePix.c FSSaver.c FSWrap.c GCMisc.c Geom.c \
+ GetAtomNm.c GetColor.c GetDflt.c GetEventData.c GetFPath.c \
+ GetFProp.c GetGCVals.c GetGeom.c GetHColor.c GetHints.c \
+ GetIFocus.c GetImage.c GetKCnt.c GetMoEv.c GetNrmHint.c \
+ GetPCnt.c GetPntMap.c GetProp.c GetRGBCMap.c GetSOwner.c \
+ GetSSaver.c GetStCmap.c GetTxtProp.c GetWAttrs.c GetWMCMapW.c \
+ GetWMProto.c globals.c GrButton.c GrKeybd.c GrKey.c \
+ GrPointer.c GrServer.c Host.c Iconify.c IfEvent.c imConv.c \
+ ImText16.c ImText.c ImUtil.c InitExt.c InsCmap.c IntAtom.c \
+ KeyBind.c Key.h KeysymStr.c KillCl.c LiHosts.c LiICmaps.c \
+ LiProps.c ListExt.c LoadFont.c LockDis.c locking.c locking.h \
+ LookupCol.c LowerWin.c Macros.c MapRaised.c MapSubs.c \
+ MapWindow.c MaskEvent.c Misc.c ModMap.c MoveWin.c NextEvent.c \
+ OCWrap.c OMWrap.c OpenDis.c ParseCmd.c ParseCol.c ParseGeom.c \
+ PeekEvent.c PeekIfEv.c Pending.c PixFormats.c PmapBgnd.c \
+ PmapBord.c poly.h PolyReg.c PolyTxt16.c PolyTxt.c PropAlloc.c \
+ PutBEvent.c PutImage.c Quarks.c QuBest.c QuColor.c QuColors.c \
+ QuCurShp.c QuExt.c QuKeybd.c QuPntr.c QuStipShp.c QuTextE16.c \
+ QuTextExt.c QuTileShp.c QuTree.c RaiseWin.c RdBitF.c \
+ RecolorC.c ReconfWin.c ReconfWM.c Region.c RegstFlt.c \
+ RepWindow.c RestackWs.c RotProp.c ScrResStr.c SelInput.c \
+ SendEvent.c SetBack.c SetClMask.c SetClOrig.c SetCRects.c \
+ SetDashes.c SetFont.c SetFore.c SetFPath.c SetFunc.c \
+ SetHints.c SetIFocus.c SetLocale.c SetLStyle.c SetNrmHint.c \
+ SetPMask.c SetPntMap.c SetRGBCMap.c SetSOwner.c SetSSaver.c \
+ SetState.c SetStCmap.c SetStip.c SetTile.c SetTSOrig.c \
+ SetTxtProp.c SetWMCMapW.c SetWMProto.c StBytes.c StColor.c \
+ StColors.c StName.c StNColor.c StrKeysym.c StrToText.c Sync.c \
+ Synchro.c Text16.c Text.c TextExt16.c TextExt.c TextToStr.c \
+ TrCoords.c UndefCurs.c UngrabBut.c UngrabKbd.c UngrabKey.c \
+ UngrabPtr.c UngrabSvr.c UninsCmap.c UnldFont.c UnmapSubs.c \
+ UnmapWin.c utlist.h VisUtil.c WarpPtr.c Window.c WinEvent.c \
+ Withdraw.c WMGeom.c WMProps.c WrBitF.c Xatomtype.h Xintatom.h \
+ Xintconn.h XlibAsync.c XlibInt.c Xprivate.h XomGeneric.h \
+ Xresinternal.h Xrm.c XrmI.h os2Stubs.c udcInf.c UIThrStubs.c \
+ xcb_disp.c xcb_io.c Xxcbint.h ConnDis.c x11_trans.c
@OS2_TRUE@am__objects_1 = os2Stubs.lo
@UDC_TRUE@am__objects_2 = udcInf.lo
@THRSTUBS_TRUE@am__objects_3 = UIThrStubs.lo
@@ -172,44 +172,45 @@ am_libX11_la_OBJECTS = AllCells.lo AllowEv.lo AllPlanes.lo AutoRep.lo \
EvToWire.lo FetchName.lo FillArc.lo FillArcs.lo FillPoly.lo \
FillRct.lo FillRcts.lo FilterEv.lo Flush.lo Font.lo \
FontInfo.lo FontNames.lo FreeCmap.lo FreeCols.lo FreeCurs.lo \
- FreeEData.lo FreeGC.lo FreePix.lo FSSaver.lo FSWrap.lo \
- GCMisc.lo Geom.lo GetAtomNm.lo GetColor.lo GetDflt.lo \
- GetFPath.lo GetFProp.lo GetGCVals.lo GetGeom.lo GetHColor.lo \
- GetHints.lo GetIFocus.lo GetImage.lo GetKCnt.lo GetMoEv.lo \
- GetNrmHint.lo GetPCnt.lo GetPntMap.lo GetProp.lo GetRGBCMap.lo \
- GetSOwner.lo GetSSaver.lo GetStCmap.lo GetTxtProp.lo \
- GetWAttrs.lo GetWMCMapW.lo GetWMProto.lo globals.lo \
- GrButton.lo GrKeybd.lo GrKey.lo GrPointer.lo GrServer.lo \
- Host.lo Iconify.lo IfEvent.lo imConv.lo ImText16.lo ImText.lo \
- ImUtil.lo InitExt.lo InsCmap.lo IntAtom.lo KeyBind.lo \
- KeysymStr.lo KillCl.lo LiHosts.lo LiICmaps.lo LiProps.lo \
- ListExt.lo LoadFont.lo LockDis.lo locking.lo LookupCol.lo \
- LowerWin.lo Macros.lo MapRaised.lo MapSubs.lo MapWindow.lo \
- MaskEvent.lo Misc.lo ModMap.lo MoveWin.lo NextEvent.lo \
- OCWrap.lo OMWrap.lo OpenDis.lo ParseCmd.lo ParseCol.lo \
- ParseGeom.lo PeekEvent.lo PeekIfEv.lo Pending.lo PixFormats.lo \
- PmapBgnd.lo PmapBord.lo PolyReg.lo PolyTxt16.lo PolyTxt.lo \
- PropAlloc.lo PutBEvent.lo PutImage.lo Quarks.lo QuBest.lo \
- QuColor.lo QuColors.lo QuCurShp.lo QuExt.lo QuKeybd.lo \
- QuPntr.lo QuStipShp.lo QuTextE16.lo QuTextExt.lo QuTileShp.lo \
- QuTree.lo RaiseWin.lo RdBitF.lo RecolorC.lo ReconfWin.lo \
- ReconfWM.lo Region.lo RegstFlt.lo RepWindow.lo RestackWs.lo \
- RotProp.lo ScrResStr.lo SelInput.lo SendEvent.lo SetBack.lo \
- SetClMask.lo SetClOrig.lo SetCRects.lo SetDashes.lo SetFont.lo \
- SetFore.lo SetFPath.lo SetFunc.lo SetHints.lo SetIFocus.lo \
- SetLocale.lo SetLStyle.lo SetNrmHint.lo SetPMask.lo \
- SetPntMap.lo SetRGBCMap.lo SetSOwner.lo SetSSaver.lo \
- SetState.lo SetStCmap.lo SetStip.lo SetTile.lo SetTSOrig.lo \
- SetTxtProp.lo SetWMCMapW.lo SetWMProto.lo StBytes.lo \
- StColor.lo StColors.lo StName.lo StNColor.lo StrKeysym.lo \
- StrToText.lo Sync.lo Synchro.lo Text16.lo Text.lo TextExt16.lo \
- TextExt.lo TextToStr.lo TrCoords.lo UndefCurs.lo UngrabBut.lo \
- UngrabKbd.lo UngrabKey.lo UngrabPtr.lo UngrabSvr.lo \
- UninsCmap.lo UnldFont.lo UnmapSubs.lo UnmapWin.lo VisUtil.lo \
- WarpPtr.lo Window.lo WinEvent.lo Withdraw.lo WMGeom.lo \
- WMProps.lo WrBitF.lo XlibAsync.lo XlibInt.lo Xrm.lo \
- $(am__objects_1) $(am__objects_2) $(am__objects_3) \
- $(am__objects_4) $(am__objects_5)
+ FreeEData.lo FreeEventData.lo FreeGC.lo FreePix.lo FSSaver.lo \
+ FSWrap.lo GCMisc.lo Geom.lo GetAtomNm.lo GetColor.lo \
+ GetDflt.lo GetEventData.lo GetFPath.lo GetFProp.lo \
+ GetGCVals.lo GetGeom.lo GetHColor.lo GetHints.lo GetIFocus.lo \
+ GetImage.lo GetKCnt.lo GetMoEv.lo GetNrmHint.lo GetPCnt.lo \
+ GetPntMap.lo GetProp.lo GetRGBCMap.lo GetSOwner.lo \
+ GetSSaver.lo GetStCmap.lo GetTxtProp.lo GetWAttrs.lo \
+ GetWMCMapW.lo GetWMProto.lo globals.lo GrButton.lo GrKeybd.lo \
+ GrKey.lo GrPointer.lo GrServer.lo Host.lo Iconify.lo \
+ IfEvent.lo imConv.lo ImText16.lo ImText.lo ImUtil.lo \
+ InitExt.lo InsCmap.lo IntAtom.lo KeyBind.lo KeysymStr.lo \
+ KillCl.lo LiHosts.lo LiICmaps.lo LiProps.lo ListExt.lo \
+ LoadFont.lo LockDis.lo locking.lo LookupCol.lo LowerWin.lo \
+ Macros.lo MapRaised.lo MapSubs.lo MapWindow.lo MaskEvent.lo \
+ Misc.lo ModMap.lo MoveWin.lo NextEvent.lo OCWrap.lo OMWrap.lo \
+ OpenDis.lo ParseCmd.lo ParseCol.lo ParseGeom.lo PeekEvent.lo \
+ PeekIfEv.lo Pending.lo PixFormats.lo PmapBgnd.lo PmapBord.lo \
+ PolyReg.lo PolyTxt16.lo PolyTxt.lo PropAlloc.lo PutBEvent.lo \
+ PutImage.lo Quarks.lo QuBest.lo QuColor.lo QuColors.lo \
+ QuCurShp.lo QuExt.lo QuKeybd.lo QuPntr.lo QuStipShp.lo \
+ QuTextE16.lo QuTextExt.lo QuTileShp.lo QuTree.lo RaiseWin.lo \
+ RdBitF.lo RecolorC.lo ReconfWin.lo ReconfWM.lo Region.lo \
+ RegstFlt.lo RepWindow.lo RestackWs.lo RotProp.lo ScrResStr.lo \
+ SelInput.lo SendEvent.lo SetBack.lo SetClMask.lo SetClOrig.lo \
+ SetCRects.lo SetDashes.lo SetFont.lo SetFore.lo SetFPath.lo \
+ SetFunc.lo SetHints.lo SetIFocus.lo SetLocale.lo SetLStyle.lo \
+ SetNrmHint.lo SetPMask.lo SetPntMap.lo SetRGBCMap.lo \
+ SetSOwner.lo SetSSaver.lo SetState.lo SetStCmap.lo SetStip.lo \
+ SetTile.lo SetTSOrig.lo SetTxtProp.lo SetWMCMapW.lo \
+ SetWMProto.lo StBytes.lo StColor.lo StColors.lo StName.lo \
+ StNColor.lo StrKeysym.lo StrToText.lo Sync.lo Synchro.lo \
+ Text16.lo Text.lo TextExt16.lo TextExt.lo TextToStr.lo \
+ TrCoords.lo UndefCurs.lo UngrabBut.lo UngrabKbd.lo \
+ UngrabKey.lo UngrabPtr.lo UngrabSvr.lo UninsCmap.lo \
+ UnldFont.lo UnmapSubs.lo UnmapWin.lo VisUtil.lo WarpPtr.lo \
+ Window.lo WinEvent.lo Withdraw.lo WMGeom.lo WMProps.lo \
+ WrBitF.lo XlibAsync.lo XlibInt.lo Xrm.lo $(am__objects_1) \
+ $(am__objects_2) $(am__objects_3) $(am__objects_4) \
+ $(am__objects_5)
libX11_la_OBJECTS = $(am_libX11_la_OBJECTS)
libX11_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
@@ -498,43 +499,43 @@ libX11_la_SOURCES = AllCells.c AllowEv.c AllPlanes.c AutoRep.c \
DrRects.c DrSegs.c ErrDes.c ErrHndlr.c evtomask.c EvToWire.c \
FetchName.c FillArc.c FillArcs.c FillPoly.c FillRct.c \
FillRcts.c FilterEv.c Flush.c Font.c FontInfo.c FontNames.c \
- FreeCmap.c FreeCols.c FreeCurs.c FreeEData.c FreeGC.c \
- FreePix.c FSSaver.c FSWrap.c GCMisc.c Geom.c GetAtomNm.c \
- GetColor.c GetDflt.c GetFPath.c GetFProp.c GetGCVals.c \
- GetGeom.c GetHColor.c GetHints.c GetIFocus.c GetImage.c \
- GetKCnt.c GetMoEv.c GetNrmHint.c GetPCnt.c GetPntMap.c \
- GetProp.c GetRGBCMap.c GetSOwner.c GetSSaver.c GetStCmap.c \
- GetTxtProp.c GetWAttrs.c GetWMCMapW.c GetWMProto.c globals.c \
- GrButton.c GrKeybd.c GrKey.c GrPointer.c GrServer.c Host.c \
- Iconify.c IfEvent.c imConv.c ImText16.c ImText.c ImUtil.c \
- InitExt.c InsCmap.c IntAtom.c KeyBind.c Key.h KeysymStr.c \
- KillCl.c LiHosts.c LiICmaps.c LiProps.c ListExt.c LoadFont.c \
- LockDis.c locking.c locking.h LookupCol.c LowerWin.c Macros.c \
- MapRaised.c MapSubs.c MapWindow.c MaskEvent.c Misc.c ModMap.c \
- MoveWin.c NextEvent.c OCWrap.c OMWrap.c OpenDis.c ParseCmd.c \
- ParseCol.c ParseGeom.c PeekEvent.c PeekIfEv.c Pending.c \
- PixFormats.c PmapBgnd.c PmapBord.c poly.h PolyReg.c \
- PolyTxt16.c PolyTxt.c PropAlloc.c PutBEvent.c PutImage.c \
- Quarks.c QuBest.c QuColor.c QuColors.c QuCurShp.c QuExt.c \
- QuKeybd.c QuPntr.c QuStipShp.c QuTextE16.c QuTextExt.c \
- QuTileShp.c QuTree.c RaiseWin.c RdBitF.c RecolorC.c \
- ReconfWin.c ReconfWM.c Region.c RegstFlt.c RepWindow.c \
- RestackWs.c RotProp.c ScrResStr.c SelInput.c SendEvent.c \
- SetBack.c SetClMask.c SetClOrig.c SetCRects.c SetDashes.c \
- SetFont.c SetFore.c SetFPath.c SetFunc.c SetHints.c \
- SetIFocus.c SetLocale.c SetLStyle.c SetNrmHint.c SetPMask.c \
- SetPntMap.c SetRGBCMap.c SetSOwner.c SetSSaver.c SetState.c \
- SetStCmap.c SetStip.c SetTile.c SetTSOrig.c SetTxtProp.c \
- SetWMCMapW.c SetWMProto.c StBytes.c StColor.c StColors.c \
- StName.c StNColor.c StrKeysym.c StrToText.c Sync.c Synchro.c \
- Text16.c Text.c TextExt16.c TextExt.c TextToStr.c TrCoords.c \
- UndefCurs.c UngrabBut.c UngrabKbd.c UngrabKey.c UngrabPtr.c \
- UngrabSvr.c UninsCmap.c UnldFont.c UnmapSubs.c UnmapWin.c \
- VisUtil.c WarpPtr.c Window.c WinEvent.c Withdraw.c WMGeom.c \
- WMProps.c WrBitF.c Xatomtype.h Xintatom.h Xintconn.h \
- XlibAsync.c XlibInt.c Xprivate.h XomGeneric.h Xresinternal.h \
- Xrm.c XrmI.h $(am__append_1) $(am__append_2) $(am__append_3) \
- $(am__append_4) $(am__append_6)
+ FreeCmap.c FreeCols.c FreeCurs.c FreeEData.c FreeEventData.c \
+ FreeGC.c FreePix.c FSSaver.c FSWrap.c GCMisc.c Geom.c \
+ GetAtomNm.c GetColor.c GetDflt.c GetEventData.c GetFPath.c \
+ GetFProp.c GetGCVals.c GetGeom.c GetHColor.c GetHints.c \
+ GetIFocus.c GetImage.c GetKCnt.c GetMoEv.c GetNrmHint.c \
+ GetPCnt.c GetPntMap.c GetProp.c GetRGBCMap.c GetSOwner.c \
+ GetSSaver.c GetStCmap.c GetTxtProp.c GetWAttrs.c GetWMCMapW.c \
+ GetWMProto.c globals.c GrButton.c GrKeybd.c GrKey.c \
+ GrPointer.c GrServer.c Host.c Iconify.c IfEvent.c imConv.c \
+ ImText16.c ImText.c ImUtil.c InitExt.c InsCmap.c IntAtom.c \
+ KeyBind.c Key.h KeysymStr.c KillCl.c LiHosts.c LiICmaps.c \
+ LiProps.c ListExt.c LoadFont.c LockDis.c locking.c locking.h \
+ LookupCol.c LowerWin.c Macros.c MapRaised.c MapSubs.c \
+ MapWindow.c MaskEvent.c Misc.c ModMap.c MoveWin.c NextEvent.c \
+ OCWrap.c OMWrap.c OpenDis.c ParseCmd.c ParseCol.c ParseGeom.c \
+ PeekEvent.c PeekIfEv.c Pending.c PixFormats.c PmapBgnd.c \
+ PmapBord.c poly.h PolyReg.c PolyTxt16.c PolyTxt.c PropAlloc.c \
+ PutBEvent.c PutImage.c Quarks.c QuBest.c QuColor.c QuColors.c \
+ QuCurShp.c QuExt.c QuKeybd.c QuPntr.c QuStipShp.c QuTextE16.c \
+ QuTextExt.c QuTileShp.c QuTree.c RaiseWin.c RdBitF.c \
+ RecolorC.c ReconfWin.c ReconfWM.c Region.c RegstFlt.c \
+ RepWindow.c RestackWs.c RotProp.c ScrResStr.c SelInput.c \
+ SendEvent.c SetBack.c SetClMask.c SetClOrig.c SetCRects.c \
+ SetDashes.c SetFont.c SetFore.c SetFPath.c SetFunc.c \
+ SetHints.c SetIFocus.c SetLocale.c SetLStyle.c SetNrmHint.c \
+ SetPMask.c SetPntMap.c SetRGBCMap.c SetSOwner.c SetSSaver.c \
+ SetState.c SetStCmap.c SetStip.c SetTile.c SetTSOrig.c \
+ SetTxtProp.c SetWMCMapW.c SetWMProto.c StBytes.c StColor.c \
+ StColors.c StName.c StNColor.c StrKeysym.c StrToText.c Sync.c \
+ Synchro.c Text16.c Text.c TextExt16.c TextExt.c TextToStr.c \
+ TrCoords.c UndefCurs.c UngrabBut.c UngrabKbd.c UngrabKey.c \
+ UngrabPtr.c UngrabSvr.c UninsCmap.c UnldFont.c UnmapSubs.c \
+ UnmapWin.c utlist.h VisUtil.c WarpPtr.c Window.c WinEvent.c \
+ Withdraw.c WMGeom.c WMProps.c WrBitF.c Xatomtype.h Xintatom.h \
+ Xintconn.h XlibAsync.c XlibInt.c Xprivate.h XomGeneric.h \
+ Xresinternal.h Xrm.c XrmI.h $(am__append_1) $(am__append_2) \
+ $(am__append_3) $(am__append_4) $(am__append_6)
x11datadir = @X11_DATADIR@
x11data_DATA = XKeysymDB XErrorDB
EXTRA_DIST = \
@@ -553,7 +554,7 @@ EXTRA_DIST = \
@XLOCALE_TRUE@USE_I18N_LIBS = $(I18N_LIBS)
@XCMS_TRUE@USE_XCMS_LIBS = $(XCMS_LIBS)
@XKB_TRUE@USE_XKB_LIBS = $(XKB_LIBS)
-libX11_la_LDFLAGS = -version-number 6:2:0 -no-undefined
+libX11_la_LDFLAGS = -version-number 6:3:0 -no-undefined
libX11_la_LIBADD = \
$(USE_I18N_LIBS) \
$(USE_XCMS_LIBS) \
@@ -745,6 +746,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeCols.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeCurs.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeEData.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeEventData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreeGC.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FreePix.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GCMisc.Plo@am__quote@
@@ -752,6 +754,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetAtomNm.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetColor.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetDflt.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetEventData.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetFPath.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetFProp.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GetGCVals.Plo@am__quote@
diff --git a/libX11/src/MaskEvent.c b/libX11/src/MaskEvent.c
index acd903f9e..14af00cc0 100644
--- a/libX11/src/MaskEvent.c
+++ b/libX11/src/MaskEvent.c
@@ -53,6 +53,10 @@ XMaskEvent (
unsigned long qe_serial = 0;
LockDisplay(dpy);
+
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
prev = NULL;
while (1) {
for (qelt = prev ? prev->next : dpy->head;
diff --git a/libX11/src/NextEvent.c b/libX11/src/NextEvent.c
index d4f72e773..1dc8384e4 100644
--- a/libX11/src/NextEvent.c
+++ b/libX11/src/NextEvent.c
@@ -46,11 +46,15 @@ XNextEvent (
LockDisplay(dpy);
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
if (dpy->head == NULL)
_XReadEvents(dpy);
qelt = dpy->head;
*event = qelt->event;
_XDeq(dpy, NULL, qelt);
+ _XStoreEventCookie(dpy, event);
UnlockDisplay(dpy);
return 0;
}
diff --git a/libX11/src/OpenDis.c b/libX11/src/OpenDis.c
index 29ac65c6a..230ae561f 100644
--- a/libX11/src/OpenDis.c
+++ b/libX11/src/OpenDis.c
@@ -790,6 +790,17 @@ _XBigReqHandler(
void _XFreeDisplayStructure(Display *dpy)
{
+ /* move all cookies in the EQ to the jar, then free them. */
+ if (dpy->qfree) {
+ _XQEvent *qelt = dpy->qfree;
+ while (qelt) {
+ if (_XIsEventCookie(dpy, &qelt->event))
+ _XStoreEventCookie(dpy, &qelt->event);
+ qelt = qelt->next;
+ }
+ }
+ if (dpy->cookiejar)
+ _XFreeEventCookies(dpy);
while (dpy->ext_procs) {
_XExtension *ext = dpy->ext_procs;
dpy->ext_procs = ext->next;
diff --git a/libX11/src/PeekEvent.c b/libX11/src/PeekEvent.c
index 6eec4a04d..344fe02b2 100644
--- a/libX11/src/PeekEvent.c
+++ b/libX11/src/PeekEvent.c
@@ -43,10 +43,15 @@ XPeekEvent (
register Display *dpy,
register XEvent *event)
{
+ XEvent copy;
LockDisplay(dpy);
if (dpy->head == NULL)
_XReadEvents(dpy);
*event = (dpy->head)->event;
+ if (_XCopyEventCookie(dpy, &event->xcookie, &copy.xcookie)) {
+ _XStoreEventCookie(dpy, &copy);
+ *event = copy;
+ }
UnlockDisplay(dpy);
return 1;
}
diff --git a/libX11/src/PeekIfEv.c b/libX11/src/PeekIfEv.c
index 1d5b1ab9c..5105b6a58 100644
--- a/libX11/src/PeekIfEv.c
+++ b/libX11/src/PeekIfEv.c
@@ -60,7 +60,12 @@ XPeekIfEvent (
prev = qelt, qelt = qelt->next) {
if(qelt->qserial_num > qe_serial
&& (*predicate)(dpy, &qelt->event, arg)) {
+ XEvent copy;
*event = qelt->event;
+ if (_XCopyEventCookie(dpy, &event->xcookie, &copy.xcookie)) {
+ _XStoreEventCookie(dpy, &copy);
+ *event = copy;
+ }
UnlockDisplay(dpy);
return 0;
}
diff --git a/libX11/src/PutBEvent.c b/libX11/src/PutBEvent.c
index eca44f3af..03a9cd266 100644
--- a/libX11/src/PutBEvent.c
+++ b/libX11/src/PutBEvent.c
@@ -41,6 +41,7 @@ _XPutBackEvent (
register XEvent *event)
{
register _XQEvent *qelt;
+ XEvent store = *event;
if (!dpy->qfree) {
if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
@@ -48,11 +49,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;
diff --git a/libX11/src/WinEvent.c b/libX11/src/WinEvent.c
index c6daf2a81..bcdf98148 100644
--- a/libX11/src/WinEvent.c
+++ b/libX11/src/WinEvent.c
@@ -56,6 +56,10 @@ XWindowEvent (
unsigned long qe_serial = 0;
LockDisplay(dpy);
+
+ /* Delete unclaimed cookies */
+ _XFreeEventCookies(dpy);
+
prev = NULL;
while (1) {
for (qelt = prev ? prev->next : dpy->head;
diff --git a/libX11/src/XlibInt.c b/libX11/src/XlibInt.c
index 04935ab39..445b8b010 100644
--- a/libX11/src/XlibInt.c
+++ b/libX11/src/XlibInt.c
@@ -2264,6 +2264,128 @@ void _XEatData(
}
#endif /* !USE_XCB */
+/* Cookie jar implementation
+ dpy->cookiejar is a linked list. _XEnq receives the events but leaves
+ them in the normal EQ. _XStoreEvent returns the cookie event (minus
+ data pointer) and adds it to the cookiejar. _XDeq just removes
+ the entry like any other event but resets the data pointer for
+ cookie events (to avoid double-free, the memory is re-used by Xlib).
+
+ _XFetchEventCookie (called from XGetEventData) removes a cookie from the
+ jar. _XFreeEventCookies removes all unclaimed cookies from the jar
+ (called by XNextEvent).
+
+ _XFreeDisplayStructure calls _XFreeEventCookies for each cookie in the
+ normal EQ.
+ */
+
+#include "utlist.h"
+struct stored_event {
+ XGenericEventCookie ev;
+ struct stored_event *prev;
+ struct stored_event *next;
+};
+
+Bool
+_XIsEventCookie(Display *dpy, XEvent *ev)
+{
+ return (ev->xcookie.type == GenericEvent &&
+ dpy->generic_event_vec[ev->xcookie.extension & 0x7F] != NULL);
+}
+
+/**
+ * Free all events in the event list.
+ */
+void
+_XFreeEventCookies(Display *dpy)
+{
+ struct stored_event **head, *e, *tmp;
+
+ if (!dpy->cookiejar)
+ return;
+
+ head = (struct stored_event**)&dpy->cookiejar;
+
+ DL_FOREACH_SAFE(*head, e, tmp) {
+ XFree(e->ev.data);
+ XFree(e);
+ if (dpy->cookiejar == e)
+ dpy->cookiejar = NULL;
+ }
+}
+
+/**
+ * Add an event to the display's event list. This event must be freed on the
+ * next call to XNextEvent().
+ */
+void
+_XStoreEventCookie(Display *dpy, XEvent *event)
+{
+ XGenericEventCookie* cookie = &event->xcookie;
+ struct stored_event **head, *add;
+
+ if (!_XIsEventCookie(dpy, event))
+ return;
+
+ head = (struct stored_event**)(&dpy->cookiejar);
+
+ add = Xmalloc(sizeof(struct stored_event));
+ if (!add) {
+ ESET(ENOMEM);
+ _XIOError(dpy);
+ }
+ add->ev = *cookie;
+ DL_APPEND(*head, add);
+ cookie->data = NULL; /* don't return data yet, must be claimed */
+}
+
+/**
+ * Return the event with the given cookie and remove it from the list.
+ */
+Bool
+_XFetchEventCookie(Display *dpy, XGenericEventCookie* ev)
+{
+ Bool ret = False;
+ struct stored_event **head, *event;
+ head = (struct stored_event**)&dpy->cookiejar;
+
+ if (!_XIsEventCookie(dpy, (XEvent*)ev))
+ return ret;
+
+ DL_FOREACH(*head, event) {
+ if (event->ev.cookie == ev->cookie &&
+ event->ev.extension == ev->extension &&
+ event->ev.evtype == ev->evtype) {
+ *ev = event->ev;
+ DL_DELETE(*head, event);
+ Xfree(event);
+ ret = True;
+ break;
+ }
+ }
+
+ return ret;
+}
+
+Bool
+_XCopyEventCookie(Display *dpy, XGenericEventCookie *in, XGenericEventCookie *out)
+{
+ Bool ret = False;
+ int extension;
+
+ if (!_XIsEventCookie(dpy, (XEvent*)in) || !out)
+ return ret;
+
+ extension = in->extension & 0x7F;
+
+ if (!dpy->generic_event_copy_vec[extension])
+ return ret;
+
+ ret = ((*dpy->generic_event_copy_vec[extension])(dpy, in, out));
+ out->cookie = ret ? ++dpy->next_cookie : 0;
+ return ret;
+}
+
/*
* _XEnq - Place event packets on the display's queue.
@@ -2275,6 +2397,7 @@ void _XEnq(
register xEvent *event)
{
register _XQEvent *qelt;
+ int type, extension;
if ((qelt = dpy->qfree)) {
/* If dpy->qfree is non-NULL do this, else malloc a new one. */
@@ -2287,8 +2410,29 @@ void _XEnq(
_XIOError(dpy);
}
qelt->next = NULL;
- /* go call through display to find proper event reformatter */
- if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) {
+
+ type = event->u.u.type & 0177;
+ extension = ((xGenericEvent*)event)->extension;
+ /* If an extension has registerd a generic_event_vec handler, then
+ * it can handle event cookies. Otherwise, proceed with the normal
+ * event handlers.
+ *
+ * If the generic_event_vec is called, qelt->event is a event cookie
+ * with the data pointer and the "free" pointer set. Data pointer is
+ * some memory allocated by the extension.
+ */
+ if (type == GenericEvent && dpy->generic_event_vec[extension & 0x7F]) {
+ XGenericEventCookie *cookie = &qelt->event.xcookie;
+ (*dpy->generic_event_vec[extension & 0x7F])(dpy, cookie, event);
+ cookie->cookie = ++dpy->next_cookie;
+
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else if ((*dpy->event_vec[type])(dpy, &qelt->event, event)) {
qelt->qserial_num = dpy->next_event_serial_num++;
if (dpy->tail) dpy->tail->next = qelt;
else dpy->head = qelt;
@@ -2322,6 +2466,13 @@ void _XDeq(
qelt->next = dpy->qfree;
dpy->qfree = qelt;
dpy->qlen--;
+
+ if (_XIsEventCookie(dpy, &qelt->event)) {
+ XGenericEventCookie* cookie = &qelt->event.xcookie;
+ /* dpy->qfree is re-used, reset memory to avoid double free on
+ * _XFreeDisplayStructure */
+ cookie->data = NULL;
+ }
}
/*
@@ -2343,6 +2494,34 @@ _XUnknownWireEvent(
return(False);
}
+Bool
+_XUnknownWireEventCookie(
+ Display *dpy, /* pointer to display structure */
+ XGenericEventCookie *re, /* pointer to where event should be reformatted */
+ xEvent *event) /* wire protocol event */
+{
+#ifdef notdef
+ fprintf(stderr,
+ "Xlib: unhandled wire cookie event! extension number = %d, display = %x\n.",
+ ((xGenericEvent*)event)->extension, dpy);
+#endif
+ return(False);
+}
+
+Bool
+_XUnknownCopyEventCookie(
+ Display *dpy, /* pointer to display structure */
+ XGenericEventCookie *in, /* source */
+ XGenericEventCookie *out) /* destination */
+{
+#ifdef notdef
+ fprintf(stderr,
+ "Xlib: unhandled cookie event copy! extension number = %d, display = %x\n.",
+ in->extension, dpy);
+#endif
+ return(False);
+}
+
/*ARGSUSED*/
Status
_XUnknownNativeEvent(
diff --git a/libX11/src/makefile b/libX11/src/makefile
index 535939c84..f5f9baa7b 100644
--- a/libX11/src/makefile
+++ b/libX11/src/makefile
@@ -83,6 +83,7 @@ CSRCS = \
FreeCols.c \
FreeCurs.c \
FreeEData.c \
+ FreeEventData.c \
FreeGC.c \
FreePix.c \
FSSaver.c \
@@ -92,6 +93,7 @@ CSRCS = \
GetAtomNm.c \
GetColor.c \
GetDflt.c \
+ GetEventData.c \
GetFPath.c \
GetFProp.c \
GetGCVals.c \
diff --git a/libX11/src/utlist.h b/libX11/src/utlist.h
new file mode 100644
index 000000000..215c2c62e
--- /dev/null
+++ b/libX11/src/utlist.h
@@ -0,0 +1,116 @@
+/*
+Copyright (c) 2007-2009, Troy D. Hanson
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef UTLIST_H
+#define UTLIST_H
+
+#define UTLIST_VERSION 1.7
+
+/* From: http://uthash.sourceforge.net/utlist.html */
+/*
+ * This file contains macros to manipulate singly and doubly-linked lists.
+ *
+ * 1. LL_ macros: singly-linked lists.
+ * 2. DL_ macros: doubly-linked lists.
+ * 3. CDL_ macros: circular doubly-linked lists.
+ *
+ * To use singly-linked lists, your structure must have a "next" pointer.
+ * To use doubly-linked lists, your structure must "prev" and "next" pointers.
+ * Either way, the pointer to the head of the list must be initialized to NULL.
+ *
+ * ----------------.EXAMPLE -------------------------
+ * struct item {
+ * int id;
+ * struct item *prev, *next;
+ * }
+ *
+ * struct item *list = NULL:
+ *
+ * int main() {
+ * struct item *item;
+ * ... allocate and populate item ...
+ * DL_APPEND(list, item);
+ * }
+ * --------------------------------------------------
+ *
+ * For doubly-linked lists, the append and delete macros are O(1)
+ * For singly-linked lists, append and delete are O(n) but prepend is O(1)
+ * The sort macro is O(n log(n)) for all types of single/double/circular lists.
+ */
+
+
+/******************************************************************************
+ * doubly linked list macros (non-circular) *
+ *****************************************************************************/
+#define DL_PREPEND(head,add) \
+do { \
+ (add)->next = head; \
+ if (head) { \
+ (add)->prev = (head)->prev; \
+ (head)->prev = (add); \
+ } else { \
+ (add)->prev = (add); \
+ } \
+ (head) = (add); \
+} while (0)
+
+#define DL_APPEND(head,add) \
+do { \
+ if (head) { \
+ (add)->prev = (head)->prev; \
+ (head)->prev->next = (add); \
+ (head)->prev = (add); \
+ (add)->next = NULL; \
+ } else { \
+ (head)=(add); \
+ (head)->prev = (head); \
+ (head)->next = NULL; \
+ } \
+} while (0);
+
+#define DL_DELETE(head,del) \
+do { \
+ if ((del)->prev == (del)) { \
+ (head)=NULL; \
+ } else if ((del)==(head)) { \
+ (del)->next->prev = (del)->prev; \
+ (head) = (del)->next; \
+ } else { \
+ (del)->prev->next = (del)->next; \
+ if ((del)->next) { \
+ (del)->next->prev = (del)->prev; \
+ } else { \
+ (head)->prev = (del)->prev; \
+ } \
+ } \
+} while (0);
+
+
+#define DL_FOREACH(head,el) \
+ for(el=head;el;el=el->next)
+
+#define DL_FOREACH_SAFE(head,el,tmp) \
+ for(el=head,tmp=el->next;el;el=tmp,tmp=(el) ? (el->next) : NULL)
+
+#endif /* UTLIST_H */
+