summaryrefslogtreecommitdiff
path: root/event/xcb_event.h
blob: 5d94e4b73552dbafa1b9add228eaf1a95ad1216e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef EVENTS_H
#define EVENTS_H

#include <X11/XCB/xcb.h>

typedef struct EventHandlers EventHandlers;
EventHandlers *allocEventHandlers(XCBConnection *c);
void freeEventHandlers(EventHandlers *evenths);
XCBConnection *getXCBConnection(EventHandlers *evenths);

void eventLoop(EventHandlers *evenths);

typedef int (*GenericEventHandler)(void *data, XCBConnection *c, XCBGenericEvent *event);
typedef int (*GenericErrorHandler)(void *data, XCBConnection *c, XCBGenericError *error);

void setEventHandler(EventHandlers *evenths, int event, GenericEventHandler handler, void *data);
void setErrorHandler(EventHandlers *evenths, int error, GenericErrorHandler handler, void *data);

#define MAKE_HANDLER(cls,kind) \
static inline void set##kind##cls##Handler(EventHandlers *evenths, int (*handler)(void *, XCBConnection *, XCB##kind##cls *), void *data) \
{ \
	set##cls##Handler(evenths, XCB##kind, (GenericEventHandler) handler, data); \
}

MAKE_HANDLER(Event, KeyPress)
MAKE_HANDLER(Event, KeyRelease)
MAKE_HANDLER(Event, ButtonPress)
MAKE_HANDLER(Event, ButtonRelease)
MAKE_HANDLER(Event, MotionNotify)
MAKE_HANDLER(Event, EnterNotify)
MAKE_HANDLER(Event, LeaveNotify)
MAKE_HANDLER(Event, FocusIn)
MAKE_HANDLER(Event, FocusOut)
MAKE_HANDLER(Event, KeymapNotify)
MAKE_HANDLER(Event, Expose)
MAKE_HANDLER(Event, GraphicsExposure)
MAKE_HANDLER(Event, NoExposure)
MAKE_HANDLER(Event, VisibilityNotify)
MAKE_HANDLER(Event, CreateNotify)
MAKE_HANDLER(Event, DestroyNotify)
MAKE_HANDLER(Event, UnmapNotify)
MAKE_HANDLER(Event, MapNotify)
MAKE_HANDLER(Event, MapRequest)
MAKE_HANDLER(Event, ReparentNotify)
MAKE_HANDLER(Event, ConfigureNotify)
MAKE_HANDLER(Event, ConfigureRequest)
MAKE_HANDLER(Event, GravityNotify)
MAKE_HANDLER(Event, ResizeRequest)
MAKE_HANDLER(Event, CirculateNotify)
MAKE_HANDLER(Event, CirculateRequest)
MAKE_HANDLER(Event, PropertyNotify)
MAKE_HANDLER(Event, SelectionClear)
MAKE_HANDLER(Event, SelectionRequest)
MAKE_HANDLER(Event, SelectionNotify)
MAKE_HANDLER(Event, ColormapNotify)
MAKE_HANDLER(Event, ClientMessage)
MAKE_HANDLER(Event, MappingNotify)

#endif /* EVENTS_H */