Add helper macros for calling xcb function and wait for reply

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2018-09-30 14:38:37 +01:00
parent ff27ca4072
commit e0bc6f5f7c
1 changed files with 11 additions and 0 deletions

11
src/x.h
View File

@ -11,6 +11,17 @@
typedef struct session session_t; typedef struct session session_t;
typedef struct winprop winprop_t; typedef struct winprop winprop_t;
#define XCB_SYNCED_VOID(func, c, ...) xcb_request_check(c, func##_checked(c, __VA_ARGS__));
#define XCB_SYNCED(func, c, ...) ({ \
xcb_generic_error_t *e = NULL; \
__auto_type r = func##_reply(c, func(c, __VA_ARGS__), &e); \
if (e) { \
x_print_error(e->sequence, e->major_code, e->minor_code, e->error_code); \
free(e); \
} \
r; \
})
/** /**
* Get a specific attribute of a window. * Get a specific attribute of a window.
* *