[PATCH libX11 3/5] Add XESetEventCookieToWire for GenericEvents
Carlos Garnacho
carlosg at gnome.org
Fri Sep 24 11:57:08 PDT 2010
Since the usual handler to convert events to the wire protocol passes an xEvent, they don't work for events larger than 32bytes, so XESetEventCookieToWire() has been added to register a handler able to deal with GenericEvents so they can be converted to the wire protocol if necessary.
Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
---
include/X11/Xlibint.h | 22 ++++++++++++++++++++++
src/InitExt.c | 20 ++++++++++++++++++++
src/XlibInt.c | 14 ++++++++++++++
3 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
index 77f0dc7..ac660a5 100644
--- a/include/X11/Xlibint.h
+++ b/include/X11/Xlibint.h
@@ -196,6 +196,11 @@ struct _XDisplay
Display * /* dpy */,
XGenericEventCookie * /* in */,
XGenericEventCookie * /* out*/);
+ /* vector for generic event to wire, index is (extension - 128) */
+ Bool (*generic_wire_vec[128])(
+ Display * /* dpy */,
+ XGenericEventCookie * /* Xlib event */,
+ xGenericEvent ** /* wire event */);
void *cookiejar; /* cookie events returned but not claimed */
};
@@ -1024,6 +1029,12 @@ extern Bool _XUnknownCopyEventCookie(
XGenericEventCookie* /* out */
);
+extern Bool _XUnknownEventCookie(
+ Display* /* dpy */,
+ XGenericEventCookie* /* re */,
+ xGenericEvent** /* event */
+);
+
extern Status _XUnknownNativeEvent(
Display* /* dpy */,
XEvent* /* re */,
@@ -1200,6 +1211,17 @@ extern Bool (*XESetCopyEventCookie(
Display*, XGenericEventCookie*, XGenericEventCookie*
);
+extern Bool (*XESetEventCookieToWire(
+ Display* /* display */,
+ int /* extension */,
+ Bool (*) (
+ Display* /* display */,
+ XGenericEventCookie* /* re */,
+ xGenericEvent** /* event */
+ ) /* proc */
+))(
+ Display*, XGenericEventCookie*, xGenericEvent**
+);
extern Status (*XESetEventToWire(
Display* /* display */,
diff --git a/src/InitExt.c b/src/InitExt.c
index cb9191d..8012d7b 100644
--- a/src/InitExt.c
+++ b/src/InitExt.c
@@ -293,6 +293,26 @@ CopyEventCookieType XESetCopyEventCookie(
return (CopyEventCookieType)oldproc;
}
+typedef Bool (*EventCookieToWireType) (
+ Display* /* display */,
+ XGenericEventCookie* /* re */,
+ xGenericEvent** /* event */
+);
+
+EventCookieToWireType XESetEventCookieToWire(
+ Display *dpy, /* display */
+ int extension, /* extension major opcode */
+ EventCookieToWireType proc /* routine to call for generic events */
+ )
+{
+ EventCookieToWireType oldproc;
+ if (proc == NULL) proc = (EventCookieToWireType)_XUnknownEventCookie;
+ LockDisplay (dpy);
+ oldproc = dpy->generic_wire_vec[extension & 0x7F];
+ dpy->generic_wire_vec[extension & 0x7F] = proc;
+ UnlockDisplay (dpy);
+ return (EventCookieToWireType)oldproc;
+}
typedef Status (*EventToWireType) (
Display* /* display */,
diff --git a/src/XlibInt.c b/src/XlibInt.c
index 11a85ba..e094e7d 100644
--- a/src/XlibInt.c
+++ b/src/XlibInt.c
@@ -992,6 +992,20 @@ _XUnknownCopyEventCookie(
return(False);
}
+Bool
+_XUnknownEventCookie(
+ Display *dpy, /* pointer to display structure */
+ XGenericEventCookie *re, /* pointer to the event being converted to wire protocol */
+ xGenericEvent **event) /* wire protocol event */
+{
+#ifdef notdef
+ fprintf(stderr,
+ "Xlib: unhandled cookie event! extension number = %d, display = %x\n.",
+ re->extension, dpy);
+#endif
+ return(False);
+}
+
/*ARGSUSED*/
Status
_XUnknownNativeEvent(
--
1.7.0.4
More information about the xorg-devel
mailing list