config_path[0] = '\0';
int sock_fd, cli_fd, dpy_fd, max_fd, n;
struct sockaddr_un sock_address;
- size_t rsp_len = 0;
char msg[BUFSIZ] = {0};
- char rsp[BUFSIZ] = {0};
xcb_generic_event_t *event;
char opt;
cli_fd = accept(sock_fd, NULL, 0);
if (cli_fd > 0 && (n = recv(cli_fd, msg, sizeof(msg), 0)) > 0) {
msg[n] = '\0';
- if (handle_message(msg, n, rsp)) {
- rsp_len = strlen(rsp);
+ FILE *rsp = fdopen(cli_fd, "w");
+ if (rsp != NULL) {
+ int ret = handle_message(msg, n, rsp);
+ if (ret == MSG_SUBSCRIBE) {
+ add_subscriber(rsp);
+ } else {
+ if (ret != MSG_SUCCESS)
+ fprintf(rsp, "%c", ret);
+ fflush(rsp);
+ fclose(rsp);
+ }
} else {
- rsp[0] = MESSAGE_FAILURE;
- rsp_len = 1;
- }
- if (rsp_len == 1 && rsp[0] == MESSAGE_SUBSCRIBE) {
- add_subscriber(cli_fd);
- } else {
- send(cli_fd, rsp, rsp_len, 0);
+ warn("Can't open the client socket as file.\n");
close(cli_fd);
}
- rsp[0] = '\0';
}
}
#undef GETATOM
const xcb_query_extension_reply_t *qep = xcb_get_extension_data(dpy, &xcb_randr_id);
- if (qep->present && import_monitors()) {
+ if (qep->present && update_monitors()) {
randr = true;
randr_base = qep->first_event;
xcb_randr_select_input(dpy, root, XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE);
subscriber_list_t *sb = subscribe_head;
while (sb != NULL) {
subscriber_list_t *next = sb->next;
- feed_subscriber(sb);
+ if (print_status(sb->stream) != 0)
+ remove_subscriber(sb);
sb = next;
}
}