diff options
author | Drew DeVault <sir@cmpwn.com> | 2015-12-13 16:04:54 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2015-12-13 16:04:54 -0500 |
commit | e277d4e094a8294f9541048c0a4a6d0cf9c3f0bc (patch) | |
tree | 6ae1d025c35c8cc0595048d5f00c7f9255a4cfc8 /common | |
parent | 7918feb9cd7c43cb059b6a6d4ea0be8346c61535 (diff) | |
download | sway-e277d4e094a8294f9541048c0a4a6d0cf9c3f0bc.tar.xz |
Subscribe to workspace change events and redraw
Diffstat (limited to 'common')
-rw-r--r-- | common/ipc-client.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/common/ipc-client.c b/common/ipc-client.c index 5d2d5808..e92a09fe 100644 --- a/common/ipc-client.c +++ b/common/ipc-client.c @@ -39,20 +39,9 @@ int ipc_open_socket(const char *socket_path) { return socketfd; } -char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint32_t *len) { +char *ipc_recv_response(int socketfd, uint32_t *len) { char data[ipc_header_size]; uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic)); - memcpy(data, ipc_magic, sizeof(ipc_magic)); - data32[0] = *len; - data32[1] = type; - - if (write(socketfd, data, ipc_header_size) == -1) { - sway_abort("Unable to send IPC header"); - } - - if (write(socketfd, payload, *len) == -1) { - sway_abort("Unable to send IPC payload"); - } size_t total = 0; while (total < ipc_header_size) { @@ -77,3 +66,21 @@ char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint3 return response; } + +char *ipc_single_command(int socketfd, uint32_t type, const char *payload, uint32_t *len) { + char data[ipc_header_size]; + uint32_t *data32 = (uint32_t *)(data + sizeof(ipc_magic)); + memcpy(data, ipc_magic, sizeof(ipc_magic)); + data32[0] = *len; + data32[1] = type; + + if (write(socketfd, data, ipc_header_size) == -1) { + sway_abort("Unable to send IPC header"); + } + + if (write(socketfd, payload, *len) == -1) { + sway_abort("Unable to send IPC payload"); + } + + return ipc_recv_response(socketfd, len); +} |