diff options
author | Mattias Andrée <maandree@kth.se> | 2020-06-20 20:57:49 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2020-06-20 20:57:49 +0200 |
commit | f9d0ddbf9024aa434898bb90a640cc45ce35a95f (patch) | |
tree | fa1945d8facbda91db1ec87915ba26ee7e6a1e2a | |
parent | Misc. (diff) | |
download | libaxl-f9d0ddbf9024aa434898bb90a640cc45ce35a95f.tar.gz libaxl-f9d0ddbf9024aa434898bb90a640cc45ce35a95f.tar.bz2 libaxl-f9d0ddbf9024aa434898bb90a640cc45ce35a95f.tar.xz |
Add LIBAXL_SYNTHETIC_EVENT_BIT
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
l--------- | LIBAXL_SYNTHETIC_EVENT_BIT.3 | 1 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | libaxl.h | 10 | ||||
-rw-r--r-- | libaxl_receive.c | 2 |
4 files changed, 12 insertions, 2 deletions
diff --git a/LIBAXL_SYNTHETIC_EVENT_BIT.3 b/LIBAXL_SYNTHETIC_EVENT_BIT.3 new file mode 120000 index 0000000..54e5c3e --- /dev/null +++ b/LIBAXL_SYNTHETIC_EVENT_BIT.3 @@ -0,0 +1 @@ +union_libaxl_input.3
\ No newline at end of file @@ -281,6 +281,7 @@ MAN3 =\ LIBAXL_REQUEST_UNMAP_SUBWINDOWS.3\ LIBAXL_REQUEST_UNMAP_WINDOW.3\ LIBAXL_REQUEST_WARP_POINTER.3\ + LIBAXL_SYNTHETIC_EVENT_BIT.3\ libaxl_attach.3\ libaxl_close.3\ libaxl_context_create.3\ @@ -50,14 +50,22 @@ typedef struct libaxl_context LIBAXL_CONTEXT; /* TODO man */ #define LIBAXL_ERROR_INVALID_HANDSHAKE_RESPONSE -12 #define LIBAXL_ERROR_OUT_OF_RESOURCE_IDS -13 #define LIBAXL_ERROR_PROTOCOL_NOT_SUPPORTED -14 +#define LIBAXL_ERROR_USER_DOES_NOT_EXIST -15 +#define LIBAXL_ERROR_USER_DOES_NOT_HAVE_A_HOME -16 -union libaxl_input { /* TODO doc, man */ +union libaxl_input { /* TODO doc, man (also LIBAXL_SYNTHETIC_EVENT_BIT) */ uint8_t type; union libaxl_error error; /* if .type = LIBAXL_ERROR */ union libaxl_reply reply; /* if .type = LIBAXL_REPLY */ union libaxl_event event; /* otherwise (.type = event type) */ }; +/** + * Bit that is set in `.type` of `union libaxl_input` if the + * event a synthetic event. + */ +#define LIBAXL_SYNTHETIC_EVENT_BIT 0x80U + _LIBAXL_GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))) LIBAXL_CONNECTION *libaxl_connect(const char *restrict, char **restrict); /* TODO man doc */ diff --git a/libaxl_receive.c b/libaxl_receive.c index 227e149..b17cdc9 100644 --- a/libaxl_receive.c +++ b/libaxl_receive.c @@ -252,7 +252,7 @@ libaxl_receive(LIBAXL_CONTEXT *restrict ctx, union libaxl_input *restrict msgp, } code = *(uint8_t *)inbuf; - code &= 0x7F; /* Synthetic events have the highest bit set. */ + code &= ~LIBAXL_SYNTHETIC_EVENT_BIT; if (code == LIBAXL_REPLY) { n = (uint64_t)ntohl(*(uint32_t *)&inbuf[4]); |