I read the documentation on xcb_poll_for_event and it says that the function
returns the next event or error from the server...
Here is a prototype that is used on my system:
xcb_generic_event_t* xcb_poll_for_event(xcb_connection_t* c)
The question is simple, how to determine if the return was an error and get some error code subsequently?
I ask because, as I understand, it is not a habit of XCB to "just cast" a return pointer to some other pointer. The xcb_generic_event_t struct does have a response_type field, but no documentation avaible on that field. Can someone share an example?
Update
The x.org web has few examples about handling erros in the event loop. On of the examples state:
For requests which have no reply (for example xcb_map_window), errors will be delivered to the event loop (you will receive an X11 event of type 0 when calling xcb_poll_for_event)
The code of the example with the error handling:
if (event->response_type == 0) {
fprintf("Received X11 error %d\n", error->error_code);
free(event);
continue;
}
But again, where did this error variable came from? It is not declared/defined in any place of the example.
Relevant link to the documentation: xcb-requests