diff -urN libX11-1.6.2-orig/include/X11/Xlibint.h libX11-1.6.2/include/X11/Xlibint.h
--- libX11-1.6.2-orig/include/X11/Xlibint.h	2013-09-09 10:37:20 +0900
+++ libX11-1.6.2/include/X11/Xlibint.h	2015-03-07 05:35:08 +0900
@@ -204,6 +204,11 @@
 		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 */
 };
 
@@ -957,6 +962,12 @@
     XGenericEventCookie*	/* out */
 );
 
+extern Bool _XUnknownEventCookie(
+    Display*             /* dpy */,
+    XGenericEventCookie* /* re */,
+    xGenericEvent**      /* event */
+);
+
 extern Status _XUnknownNativeEvent(
     Display*	/* dpy */,
     XEvent*	/* re */,
@@ -1133,6 +1144,17 @@
     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 -urN libX11-1.6.2-orig/src/InitExt.c libX11-1.6.2/src/InitExt.c
--- libX11-1.6.2-orig/src/InitExt.c	2013-09-09 10:37:20 +0900
+++ libX11-1.6.2/src/InitExt.c	2015-03-07 05:35:08 +0900
@@ -292,6 +292,26 @@
 	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 -urN libX11-1.6.2-orig/src/SendEvent.c libX11-1.6.2/src/SendEvent.c
--- libX11-1.6.2-orig/src/SendEvent.c	2013-09-09 10:37:20 +0900
+++ libX11-1.6.2/src/SendEvent.c	2015-03-07 06:48:09 +0900
@@ -27,6 +27,7 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
+#include <X11/extensions/geproto.h>
 #include "Xlibint.h"
 
 /*
@@ -41,33 +42,93 @@
     long event_mask,
     XEvent *event)
 {
-    register xSendEventReq *req;
-    xEvent ev;
-    register Status (**fp)(
-                Display *       /* dpy */,
-                XEvent *        /* re */,
-                xEvent *        /* event */);
     Status status;
 
-    /* initialize all of the event's fields first, before setting
-     * the meaningful ones later.
-     */
-    memset (&ev, 0, sizeof (ev));
-
     LockDisplay (dpy);
 
     /* call through display to find proper conversion routine */
 
-    fp = &dpy->wire_vec[event->type & 0177];
-    if (*fp == NULL) *fp = _XEventToWire;
-    status = (**fp)(dpy, event, &ev);
-
-    if (status) {
-	GetReq(SendEvent, req);
-	req->destination = w;
-	req->propagate = propagate;
-	req->eventMask = event_mask;
-	req->event = ev;
+    if (event->type == GenericEvent) {
+        static Bool ext_initialized = False;
+        static _XExtension *ext = NULL;
+        XGenericEventCookie *xcookie = (XGenericEventCookie *) event;
+        xGenericEvent *ev = NULL;
+        register Status (**fp)(
+            Display *            /* dpy */,
+            XGenericEventCookie* /* re */,
+            xGenericEvent **     /* event */);
+
+        if (!ext_initialized) {
+            for (ext = dpy->ext_procs; ext; ext = ext->next) {
+                if (ext->name && strcmp (ext->name, GE_NAME) == 0)
+                    break;
+            }
+
+            ext_initialized = True;
+        }
+
+        /* No XGE */
+        if (!ext)
+            return False;
+
+        fp = &dpy->generic_wire_vec[xcookie->extension & 0x7F];
+
+        if (!fp || !*fp)
+            return False;
+
+        status = (**fp)(dpy, xcookie, &ev);
+
+        if (status && ev) {
+            register xGESendEventReq *req;
+            register long len;
+
+            GetReq (GESendEvent, req);
+
+            req->reqType = ext->codes.major_opcode;
+            req->ReqType = X_GESendEvent;
+            req->destination = w;
+            req->propagate = propagate;
+            req->eventMask = event_mask;
+
+            len = ev->length;
+            len += SIZEOF (xEvent) >> 2;
+
+            if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+                SetReqLen(req, len, len);
+                Data (dpy, (char *)ev, len << 2);
+            } else {
+                XFree(ev);
+                return False;
+            }
+        }
+
+        if (ev)
+            XFree(ev);
+    } else {
+        xEvent ev;
+        register Status (**fp)(
+            Display *       /* dpy */,
+            XEvent *        /* re */,
+            xEvent *        /* event */);
+
+        /* initialize all of the event's fields first, before setting
+         * the meaningful ones later.
+         */
+        memset (&ev, 0, sizeof (ev));
+
+        fp = &dpy->wire_vec[event->type & 0177];
+        if (*fp == NULL) *fp = _XEventToWire;
+        status = (**fp)(dpy, event, &ev);
+
+        if (status) {
+            register xSendEventReq *req;
+
+            GetReq(SendEvent, req);
+            req->destination = w;
+            req->propagate = propagate;
+            req->eventMask = event_mask;
+            req->event = ev;
+        }
     }
 
     UnlockDisplay(dpy);
diff -urN libX11-1.6.2-orig/src/XlibInt.c libX11-1.6.2/src/XlibInt.c
--- libX11-1.6.2-orig/src/XlibInt.c	2013-09-09 10:37:20 +0900
+++ libX11-1.6.2/src/XlibInt.c	2015-03-07 05:35:08 +0900
@@ -875,6 +875,20 @@
 	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(
