From 7e77b238f7f10d4141f2c35c4c192e9be8813eef Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 24 Sep 2010 13:20:16 +0200 Subject: [PATCH 1/2] Add XESetEventCookieToWire() This function allows registering a handler in extensions to convert XGenericEvents to the wire protocol. Signed-off-by: Carlos Garnacho --- 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