+void
+check_conn(void)
+{
+ int errcode = xcb_connection_has_error(conn);
+#ifdef XCB_CONN_ERROR
+ char *s;
+ switch (errcode) {
+ case XCB_CONN_ERROR:
+ s = "Socket error, pipe error or other stream error.";
+ break;
+ case XCB_CONN_CLOSED_EXT_NOTSUPPORTED:
+ s = "Extension not supported.";
+ break;
+ case XCB_CONN_CLOSED_MEM_INSUFFICIENT:
+ s = "Insufficient memory.";
+ break;
+ case XCB_CONN_CLOSED_REQ_LEN_EXCEED:
+ s = "Request length was exceeded.";
+ break;
+ case XCB_CONN_CLOSED_PARSE_ERR:
+ s = "Error parsing display string.";
+ break;
+ default:
+ s = "Unknown error.";
+ }
+ if (errcode)
+ errx(errcode, "X CONNECTION ERROR: %s", s);
+#else
+ if (errcode)
+ errx(errcode, "X CONNECTION ERROR");
+#endif
+}
+