As explained in Jamey’s post on the XCB mailing list, the event
loop can/should be written in a more simple way than it was before
in xcb-event. See:
<AANLkTinhIM320wUjSeHkBTVk4ysBuiSZkvfs8pMLVykO@mail.gmail.com>
or
http://lists.freedesktop.org/archives/xcb/2010-July/006292.html
dpms_turn_off_screen(conn);
while ((event = xcb_wait_for_event(conn))) {
- int type = x_event_type(event);
+ if (event->response_type == 0)
+ errx(1, "XCB: Invalid event received");
+
+ /* Strip off the highest bit (set if the event is generated) */
+ int type = (event->response_type & 0x7F);
if (type == XCB_EXPOSE) {
handle_expose_event();
return (rgb16[0] << 16) + (rgb16[1] << 8) + rgb16[2];
}
-int x_event_type(xcb_generic_event_t *event) {
- /* TODO: comment */
- assert(event->response_type != 1);
-
- if (event->response_type == 0) {
- fprintf(stderr, "error\n");
- exit(1);
- }
- int type = event->response_type;
- assert(type < 256);
- /* strip the highest bit (TODO: why?) */
- type &= 0x7F;
- assert(type >= 2);
-
- return type;
-}
-
xcb_visualtype_t *get_root_visual_type(xcb_screen_t *screen) {
xcb_visualtype_t *visual_type = NULL;
xcb_depth_iterator_t depth_iter;
#include <xcb/xcb.h>
-int x_event_type(xcb_generic_event_t *event);
xcb_visualtype_t *get_root_visual_type(xcb_screen_t *s);
xcb_window_t open_fullscreen_window(xcb_connection_t *conn, xcb_screen_t *scr, char *color);
void grab_pointer_and_keyboard(xcb_connection_t *conn, xcb_screen_t *screen);