I struggled with this topic a while ago.
Take a look at http://marc.info/?l=freedesktop-xcb&m=129381953404497 .
The key is to store the cookie for WM_DELETE_WINDOW in a separate cookie ...
xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(c, 0, 16, "WM_DELETE_WINDOW"); xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(c, cookie2, 0);
and in the event loop compare client_message with cookie2
case XCB_CLIENT_MESSAGE: { if((*(xcb_client_message_event_t*)event).data.data32[0] == (*reply2).atom) ... }
source share