util: merge common code for xcb_connect