1XGetEventData(3) XLIB FUNCTIONS XGetEventData(3)
2
3
4
6 XGetEventData, XFreeEventData, XGenericEventCookie - retrieve and free
7 additional event data through cookies.
8
10 Bool XGetEventData(Display *display, XGenericEventCookie *cookie);
11
12 void XFreeEventData(Display *display, XGenericEventCookie *cookie);
13
14
15
17 display Specifies the connection to the X server.
18
19 cookie Specifies the cookie to free or retrieve the data for.
20
21
23 typedef struct {
24 int type;
25 unsigned long serial;
26 Bool send_event;
27 Display *display;
28 int extension;
29 int evtype;
30 unsigned int cookie;
31 void *data;
32 } XGenericEventCookie;
33
34
36 Some extension XGenericEvents require additional memory to store infor‐
37 mation. For these events, the library returns a XGenericEventCookie
38 with a token ('cookie') unique to this event. The XGenericEvent‐
39 Cookie's data pointer is undefined until XGetEventData is called.
40
41 The XGetEventData function retrieves this extra data for the given
42 cookie. No round-trip to the server is required. If the cookie is in‐
43 valid or the event is not an event handled by cookie handlers, False is
44 returned. If XGetEventData returns True, the cookie's data pointer
45 points to the memory containing the event information. A client must
46 call XFreeEventData to free this memory. XGetEventData returns False
47 for multiple calls for the same event cookie.
48
49 The XFreeEventData function frees the data associated with a cookie. A
50 client must call XFreeEventData for each cookie claimed with XGetEvent‐
51 Data.
52
53
55 XEvent event;
56 XGenericEventCookie *cookie = &ev;
57
58 XNextEvent(display, &event);
59 if (XGetEventData(display, cookie)) {
60 handle_cookie_event(cookie->data);
61 } else
62 handle_event(&event);
63 }
64 XFreeEventData(display, cookie);
65
66
68 A cookie is defined as unclaimed if it has been returned to the client
69 through XNextEvent but its data has not been retrieved via XGetEvent‐
70 Data. Subsequent calls to XNextEvent may free memory associated with
71 unclaimed cookies. Multi-threaded X clients must ensure that
72 XGetEventData is called before the next call to XNextEvent.
73
74
76 XNextEvent(3),
77 Xlib - C Language X Interface
78
79
80
81
82X Version 11 libX11 1.8.7 XGetEventData(3)