Find a file
Peter Hutterer 554f755e55 Add generic event cookie handling to libX11.
Generic events require more bytes than Xlib provides in the standard XEvent.
Memory allocated by the extension and stored as pointers inside the event is
prone to leak by simple 'while (1) { XNextEvent(...); }' loops.

This patch adds cookie handling for generic events. Extensions may register
a cookie handler in addition to the normal event vectors. If an extension
has registered a cookie handler, _all_ generic events for this extensions
must be handled through cookies. Otherwise, the default event handler is
used.

The cookie handler must return an XGenericEventCookie with a pointer to the
data.The rest of the event (type, serialNumber, etc.) are to be filled as
normal. When a client retrieves such a cookie event, the data is stored in
an internal queue (the 'cookiejar'). This data is freed on the next call to
XNextEvent().

New extension interfaces:
    XESetWireToEventCookie(display, extension_number, cookie_handler)

Where cookie_handler must set cookie->data. The data pointer is of arbitray
size and type but must be a single memory block. This memory block
represents the actual extension's event.

New client interfaces:
    XGetEventData(display, *cookie);
    XFreeEventData(display, *cookie);

If the client needs the actual event data, it must call XGetEventData() with
the cookie. This returns the data pointer (and removes it from the cookie
jar) and the client is then responsible for freeing the event with
XFreeEventData(). It is safe to call either function with a non-cookie
event. Events unclaimed or not handled by the XGetEventData() are cleaned up
automatically.

Example client code:
    XEvent event;
    XGenericEventCookie *cookie = &ev;

    XNextEvent(display, &event);
    if (XGetEventData(display, cookie)) {
        XIEvent *xievent = cookie->data;
        ...
    } else if (cookie->type == GenericEvent) {
        /* handle generic event */
    } else {
        /* handle extension/core event */
    }
    XFreeEventData(display, cookie);

Cookies are not multi-threading safe. Clients that use XGetEventData() must
lock between XNextEvent and XGetEventData to avoid other threads freeing
cookies.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-07-12 16:09:57 +10:00
include Add generic event cookie handling to libX11. 2009-07-12 16:09:57 +10:00
man Add generic event cookie handling to libX11. 2009-07-12 16:09:57 +10:00
modules X.Org Bug #21117: crash in get_rotate_fontname (omGeneric.c) 2009-04-27 22:35:29 -07:00
nls nls: remove more duplicated aliases 2009-05-29 11:18:42 +02:00
src Add generic event cookie handling to libX11. 2009-07-12 16:09:57 +10:00
.gitignore Janitor: ansification, make distcheck, compiler warnings. 2009-01-28 20:31:42 -02:00
acinclude.m4 dolt: allow older versions of bash to compile the library 2009-02-14 12:35:56 -05:00
AUTHORS Fix documentation typo 2008-09-08 16:42:48 -04:00
autogen.sh - For now put xtrans in X11/Xtrans/X11, since libX11 is looking for it in <X11/...> 2005-05-13 22:53:36 +00:00
configure.ac Bump to 1.2.99.1 2009-07-10 16:11:12 +10:00
COPYING - For now put xtrans in X11/Xtrans/X11, since libX11 is looking for it in <X11/...> 2005-05-13 22:53:36 +00:00
cpprules.in Add a ru_RU.UTF-8 locale 2009-04-06 17:30:52 +02:00
INSTALL - For now put xtrans in X11/Xtrans/X11, since libX11 is looking for it in <X11/...> 2005-05-13 22:53:36 +00:00
Makefile.am Janitor: ansification, make distcheck, compiler warnings. 2009-01-28 20:31:42 -02:00
NEWS Move security fixes to the top of NEWS, and fix spacing. 2007-06-03 21:41:47 -07:00
README Add README with pointers to mailing list, bugzilla & git repos 2009-02-02 20:34:31 -08:00
x11-xcb.pc.in Split public Xlib/XCB functions into libX11-xcb 2006-10-05 17:44:22 -07:00
x11.pc.in Bug 15664: xau & xdmcp not needed in x11.pc dependencies when built with xcb 2009-03-12 17:11:42 -07:00

libX11 - Core X11 protocol client library

Documentation for this library can be found in the included man pages,
the xlib spec from the doc/xorg-docs module, also available at:

	http://xorg.freedesktop.org/releases/X11R7.0/doc/PDF/xlib.pdf

and the O'Reilly Xlib books, which they have made freely available online,
though only for older versions of X11:

 - X Series Volume 2: Xlib Reference Manual (1989, covers X11R3)
	http://www.archive.org/details/xlibretmanver1102nyemiss

 - X Series Volume 2: Xlib Reference Manual, 2nd Edition (1990, covers X11R4)
	http://www.archive.org/details/xlibrefmanv115ed02nyemiss

All questions regarding this software should be directed at the
Xorg mailing list:

        http://lists.freedesktop.org/mailman/listinfo/xorg

Please submit bug reports to the Xorg bugzilla:

        https://bugs.freedesktop.org/enter_bug.cgi?product=xorg

The master development code repository can be found at:

        git://anongit.freedesktop.org/git/xorg/lib/libX11

        http://cgit.freedesktop.org/xorg/lib/libX11

For patch submission instructions, see:

	http://www.x.org/wiki/Development/Documentation/SubmittingPatches

For more information on the git code manager, see:

        http://wiki.x.org/wiki/GitPage