Like most of liblx's facilities, events are handled through callbacks. Evern LX_CONN has an event handler, which is a callback provided by the application. When the library receives an event on the wire, it unpacks it and calls the event handler, which then can inspect the event and do whatever is appropriate for the application (ignore it, use it, pass it off to other code, whatever). LX_EVENT is a struct containing an event type field (type) and a "came from SendEvent" flag (send_event), plus a union (u) with one arm for each event type. The core event types are ButtonPress Expose MappingNotify ButtonRelease FocusIn MotionNotify CirculateNotify FocusOut NoExposure CirculateRequest GraphicsExposure PropertyNotify ClientMessage GravityNotify ReparentNotify ColormapNotify KeyPress ResizeRequest ConfigureNotify KeyRelease SelectionClear ConfigureRequest KeymapNotify SelectionNotify CreateNotify LeaveNotify SelectionRequest DestroyNotify MapNotify UnmapNotify EnterNotify MapRequest VisibilityNotify Each of these has a value LX_EV_(name) and an event-specific struct LX_EVENT_(name); the union field for each event type is the event type name. For example, for ButtonPress events events, type is set to LX_EV_ButtonPress and the LX_EVENT's .u.ButtonPress is an LX_EVENT_ButtonPress struct containing the ButtonPress-specific fields. Note that event handler callbacks must be prepared to deal with unexpected events Some events are sent by the server with no way for the client to express lack of interest (MappingNotify is an example); also, SendEvent can be used to send an arbitrary event to any client which either has created a window or has keyboard focus. For example, if an application wants to exit upon receiving any ButtonPress event on a window whose ID is in a variable `quitwin' (this might be a user-interface "quit" button), its event handler could contain code like void event_handler(LX_CONN *conn, const LX_EVENT *ev) { switch (ev->type) { ... case LX_EV_ButtonPress: if (ev->u.ButtonPress.eventw == quitwin) exit(0); ... } } See extensions.txt for how extension events are handled.