def wait_for_reply(self, sequence): error_p = ffi.new("xcb_generic_error_t **") data = lib.xcb_wait_for_reply(self._conn, sequence, error_p) data = ffi.gc(data, lib.free) try: self._process_error(error_p[0]) finally: if error_p[0] != ffi.NULL: lib.free(error_p[0]) if data == ffi.NULL: # No data and no error => bad sequence number raise XcffibException("Bad sequence number %d" % sequence) reply = ffi.cast("xcb_generic_reply_t *", data) # why is this 32 and not sizeof(xcb_generic_reply_t) == 8? return CffiUnpacker(data, known_max=32 + reply.length * 4)
def wait_for_reply(self, sequence): error_p = ffi.new("xcb_generic_error_t **") data = lib.xcb_wait_for_reply(self._conn, sequence, error_p) data = ffi.gc(data, lib.free) try: self._process_error(error_p[0]) finally: if error_p[0] != ffi.NULL: lib.free(error_p[0]) if data == ffi.NULL: # No data and no error => bad sequence number raise XcffibException("Bad sequence number %d" % sequence) reply = ffi.cast("xcb_generic_reply_t *", data) # this is 32 and not `sizeof(xcb_generic_reply_t) == 8` because, # according to the X11 protocol specs: "Every reply consists of 32 bytes # followed by zero or more additional bytes of data, as specified in the # length field." return CffiUnpacker(data, known_max=32 + reply.length * 4)
def wait_for_event(self): e = lib.xcb_wait_for_event(self._conn) e = ffi.gc(e, lib.free) self.invalid() return self.hoist_event(e)