2 #define I3__FILE__ "ipc.c"
4 * vim:ts=4:sw=4:expandtab
6 * i3 - an improved dynamic tiling window manager
7 * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
9 * ipc.c: UNIX domain socket IPC (initialization, client handling, protocol).
13 #include "yajl_utils.h"
16 #include <sys/socket.h>
21 #include <yajl/yajl_gen.h>
22 #include <yajl/yajl_parse.h>
24 char *current_socketpath = NULL;
26 TAILQ_HEAD(ipc_client_head, ipc_client) all_clients = TAILQ_HEAD_INITIALIZER(all_clients);
29 * Puts the given socket file descriptor into non-blocking mode or dies if
30 * setting O_NONBLOCK failed. Non-blocking sockets are a good idea for our
31 * IPC model because we should by no means block the window manager.
34 static void set_nonblock(int sockfd) {
35 int flags = fcntl(sockfd, F_GETFL, 0);
37 if (fcntl(sockfd, F_SETFL, flags) < 0)
38 err(-1, "Could not set O_NONBLOCK");
42 * Sends the specified event to all IPC clients which are currently connected
43 * and subscribed to this kind of event.
46 void ipc_send_event(const char *event, uint32_t message_type, const char *payload) {
48 TAILQ_FOREACH(current, &all_clients, clients) {
49 /* see if this client is interested in this event */
50 bool interested = false;
51 for (int i = 0; i < current->num_events; i++) {
52 if (strcasecmp(current->events[i], event) != 0)
60 ipc_send_message(current->fd, strlen(payload), message_type, (const uint8_t *)payload);
65 * Calls shutdown() on each socket and closes it. This function to be called
66 * when exiting or restarting only!
69 void ipc_shutdown(void) {
71 while (!TAILQ_EMPTY(&all_clients)) {
72 current = TAILQ_FIRST(&all_clients);
73 shutdown(current->fd, SHUT_RDWR);
75 for (int i = 0; i < current->num_events; i++)
76 free(current->events[i]);
77 free(current->events);
78 TAILQ_REMOVE(&all_clients, current, clients);
84 * Executes the command and returns whether it could be successfully parsed
85 * or not (at the moment, always returns true).
88 IPC_HANDLER(command) {
89 /* To get a properly terminated buffer, we copy
90 * message_size bytes out of the buffer */
91 char *command = scalloc(message_size + 1, 1);
92 strncpy(command, (const char *)message, message_size);
93 LOG("IPC: received: *%s*\n", command);
94 yajl_gen gen = yajl_gen_alloc(NULL);
96 CommandResult *result = parse_command((const char *)command, gen);
99 if (result->needs_tree_render)
102 command_result_free(result);
104 const unsigned char *reply;
106 yajl_gen_get_buf(gen, &reply, &length);
108 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_COMMAND,
109 (const uint8_t *)reply);
114 static void dump_rect(yajl_gen gen, const char *name, Rect r) {
124 y(integer, r.height);
128 static void dump_event_state_mask(yajl_gen gen, Binding *bind) {
130 for (int i = 0; i < 20; i++) {
131 if (bind->event_state_mask & (1 << i)) {
133 case XCB_KEY_BUT_MASK_SHIFT:
136 case XCB_KEY_BUT_MASK_LOCK:
139 case XCB_KEY_BUT_MASK_CONTROL:
142 case XCB_KEY_BUT_MASK_MOD_1:
145 case XCB_KEY_BUT_MASK_MOD_2:
148 case XCB_KEY_BUT_MASK_MOD_3:
151 case XCB_KEY_BUT_MASK_MOD_4:
154 case XCB_KEY_BUT_MASK_MOD_5:
157 case XCB_KEY_BUT_MASK_BUTTON_1:
160 case XCB_KEY_BUT_MASK_BUTTON_2:
163 case XCB_KEY_BUT_MASK_BUTTON_3:
166 case XCB_KEY_BUT_MASK_BUTTON_4:
169 case XCB_KEY_BUT_MASK_BUTTON_5:
172 case (I3_XKB_GROUP_MASK_1 << 16):
175 case (I3_XKB_GROUP_MASK_2 << 16):
178 case (I3_XKB_GROUP_MASK_3 << 16):
181 case (I3_XKB_GROUP_MASK_4 << 16):
190 static void dump_binding(yajl_gen gen, Binding *bind) {
193 y(integer, bind->keycode);
196 ystr((const char *)(bind->input_type == B_KEYBOARD ? "keyboard" : "mouse"));
199 if (bind->symbol == NULL)
207 // This key is only provided for compatibility, new programs should use
208 // event_state_mask instead.
210 dump_event_state_mask(gen, bind);
212 ystr("event_state_mask");
213 dump_event_state_mask(gen, bind);
218 void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
221 y(integer, (uintptr_t)con);
234 case CT_FLOATING_CON:
235 ystr("floating_con");
244 DLOG("About to dump unknown container type=%d. This is a bug.\n", con->type);
249 /* provided for backwards compatibility only. */
251 if (!con_is_split(con))
254 if (con_orientation(con) == HORIZ)
260 ystr("scratchpad_state");
261 switch (con->scratchpad_state) {
262 case SCRATCHPAD_NONE:
265 case SCRATCHPAD_FRESH:
268 case SCRATCHPAD_CHANGED:
274 if (con->percent == 0.0)
277 y(double, con->percent);
280 y(bool, con->urgent);
282 if (!TAILQ_EMPTY(&(con->marks_head))) {
287 TAILQ_FOREACH(mark, &(con->marks_head), marks) {
295 y(bool, (con == focused));
298 switch (con->layout) {
300 DLOG("About to dump layout=default, this is a bug in the code.\n");
323 ystr("workspace_layout");
324 switch (con->workspace_layout) {
335 DLOG("About to dump workspace_layout=%d (none of default/stacked/tabbed), this is a bug.\n", con->workspace_layout);
340 ystr("last_split_layout");
341 switch (con->layout) {
351 switch (con->border_style) {
363 ystr("current_border_width");
364 y(integer, con->current_border_width);
366 dump_rect(gen, "rect", con->rect);
367 dump_rect(gen, "deco_rect", con->deco_rect);
368 dump_rect(gen, "window_rect", con->window_rect);
369 dump_rect(gen, "geometry", con->geometry);
372 if (con->window && con->window->name)
373 ystr(i3string_as_utf8(con->window->name));
374 else if (con->name != NULL)
379 if (con->title_format != NULL) {
380 ystr("title_format");
381 ystr(con->title_format);
384 if (con->type == CT_WORKSPACE) {
386 y(integer, con->num);
391 y(integer, con->window->id);
395 if (con->window && !inplace_restart) {
396 /* Window properties are useless to preserve when restarting because
397 * they will be queried again anyway. However, for i3-save-tree(1),
398 * they are very useful and save i3-save-tree dealing with X11. */
399 ystr("window_properties");
402 #define DUMP_PROPERTY(key, prop_name) \
404 if (con->window->prop_name != NULL) { \
406 ystr(con->window->prop_name); \
410 DUMP_PROPERTY("class", class_class);
411 DUMP_PROPERTY("instance", class_instance);
412 DUMP_PROPERTY("window_role", role);
414 if (con->window->name != NULL) {
416 ystr(i3string_as_utf8(con->window->name));
419 ystr("transient_for");
420 if (con->window->transient_for == XCB_NONE)
423 y(integer, con->window->transient_for);
431 if (con->type != CT_DOCKAREA || !inplace_restart) {
432 TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
433 dump_node(gen, node, inplace_restart);
438 ystr("floating_nodes");
440 TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
441 dump_node(gen, node, inplace_restart);
447 TAILQ_FOREACH(node, &(con->focus_head), focused) {
448 y(integer, (uintptr_t)node);
452 ystr("fullscreen_mode");
453 y(integer, con->fullscreen_mode);
456 y(bool, con->sticky);
459 switch (con->floating) {
460 case FLOATING_AUTO_OFF:
463 case FLOATING_AUTO_ON:
466 case FLOATING_USER_OFF:
469 case FLOATING_USER_ON:
477 TAILQ_FOREACH(match, &(con->swallow_head), matches) {
478 /* We will generate a new restart_mode match specification after this
479 * loop, so skip this one. */
480 if (match->restart_mode)
483 if (match->dock != -1) {
485 y(integer, match->dock);
486 ystr("insert_where");
487 y(integer, match->insert_where);
490 #define DUMP_REGEX(re_name) \
492 if (match->re_name != NULL) { \
494 ystr(match->re_name->pattern); \
499 DUMP_REGEX(instance);
500 DUMP_REGEX(window_role);
507 if (inplace_restart) {
508 if (con->window != NULL) {
511 y(integer, con->window->id);
512 ystr("restart_mode");
519 if (inplace_restart && con->window != NULL) {
521 y(integer, con->depth);
527 static void dump_bar_bindings(yajl_gen gen, Barconfig *config) {
528 if (TAILQ_EMPTY(&(config->bar_bindings)))
534 struct Barbinding *current;
535 TAILQ_FOREACH(current, &(config->bar_bindings), bindings) {
539 y(integer, current->input_code);
541 ystr(current->command);
549 static void dump_bar_config(yajl_gen gen, Barconfig *config) {
555 if (config->num_outputs > 0) {
558 for (int c = 0; c < config->num_outputs; c++)
559 ystr(config->outputs[c]);
563 if (!TAILQ_EMPTY(&(config->tray_outputs))) {
564 ystr("tray_outputs");
567 struct tray_output_t *tray_output;
568 TAILQ_FOREACH(tray_output, &(config->tray_outputs), tray_outputs) {
569 ystr(tray_output->output);
575 #define YSTR_IF_SET(name) \
577 if (config->name) { \
579 ystr(config->name); \
583 ystr("tray_padding");
584 y(integer, config->tray_padding);
586 YSTR_IF_SET(socket_path);
589 switch (config->mode) {
602 ystr("hidden_state");
603 switch (config->hidden_state) {
614 switch (config->modifier) {
641 dump_bar_bindings(gen, config);
644 if (config->position == P_BOTTOM)
649 YSTR_IF_SET(status_command);
652 if (config->separator_symbol) {
653 ystr("separator_symbol");
654 ystr(config->separator_symbol);
657 ystr("workspace_buttons");
658 y(bool, !config->hide_workspace_buttons);
660 ystr("strip_workspace_numbers");
661 y(bool, config->strip_workspace_numbers);
663 ystr("binding_mode_indicator");
664 y(bool, !config->hide_binding_mode_indicator);
667 y(bool, config->verbose);
670 #define YSTR_IF_SET(name) \
672 if (config->colors.name) { \
674 ystr(config->colors.name); \
680 YSTR_IF_SET(background);
681 YSTR_IF_SET(statusline);
682 YSTR_IF_SET(separator);
683 YSTR_IF_SET(focused_background);
684 YSTR_IF_SET(focused_statusline);
685 YSTR_IF_SET(focused_separator);
686 YSTR_IF_SET(focused_workspace_border);
687 YSTR_IF_SET(focused_workspace_bg);
688 YSTR_IF_SET(focused_workspace_text);
689 YSTR_IF_SET(active_workspace_border);
690 YSTR_IF_SET(active_workspace_bg);
691 YSTR_IF_SET(active_workspace_text);
692 YSTR_IF_SET(inactive_workspace_border);
693 YSTR_IF_SET(inactive_workspace_bg);
694 YSTR_IF_SET(inactive_workspace_text);
695 YSTR_IF_SET(urgent_workspace_border);
696 YSTR_IF_SET(urgent_workspace_bg);
697 YSTR_IF_SET(urgent_workspace_text);
698 YSTR_IF_SET(binding_mode_border);
699 YSTR_IF_SET(binding_mode_bg);
700 YSTR_IF_SET(binding_mode_text);
708 setlocale(LC_NUMERIC, "C");
709 yajl_gen gen = ygenalloc();
710 dump_node(gen, croot, false);
711 setlocale(LC_NUMERIC, "");
713 const unsigned char *payload;
715 y(get_buf, &payload, &length);
717 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_TREE, payload);
722 * Formats the reply message for a GET_WORKSPACES request and sends it to the
726 IPC_HANDLER(get_workspaces) {
727 yajl_gen gen = ygenalloc();
730 Con *focused_ws = con_get_workspace(focused);
733 TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
734 if (con_is_internal(output))
737 TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
738 assert(ws->type == CT_WORKSPACE);
748 y(bool, workspace_is_visible(ws));
751 y(bool, ws == focused_ws);
756 y(integer, ws->rect.x);
758 y(integer, ws->rect.y);
760 y(integer, ws->rect.width);
762 y(integer, ws->rect.height);
777 const unsigned char *payload;
779 y(get_buf, &payload, &length);
781 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_WORKSPACES, payload);
786 * Formats the reply message for a GET_OUTPUTS request and sends it to the
790 IPC_HANDLER(get_outputs) {
791 yajl_gen gen = ygenalloc();
795 TAILQ_FOREACH(output, &outputs, outputs) {
802 y(bool, output->active);
805 y(bool, output->primary);
810 y(integer, output->rect.x);
812 y(integer, output->rect.y);
814 y(integer, output->rect.width);
816 y(integer, output->rect.height);
819 ystr("current_workspace");
821 if (output->con && (ws = con_get_fullscreen_con(output->con, CF_OUTPUT)))
831 const unsigned char *payload;
833 y(get_buf, &payload, &length);
835 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_OUTPUTS, payload);
840 * Formats the reply message for a GET_MARKS request and sends it to the
844 IPC_HANDLER(get_marks) {
845 yajl_gen gen = ygenalloc();
849 TAILQ_FOREACH(con, &all_cons, all_cons) {
851 TAILQ_FOREACH(mark, &(con->marks_head), marks) {
858 const unsigned char *payload;
860 y(get_buf, &payload, &length);
862 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_MARKS, payload);
867 * Returns the version of i3
870 IPC_HANDLER(get_version) {
871 yajl_gen gen = ygenalloc();
875 y(integer, MAJOR_VERSION);
878 y(integer, MINOR_VERSION);
881 y(integer, PATCH_VERSION);
883 ystr("human_readable");
886 ystr("loaded_config_file_name");
887 ystr(current_configpath);
891 const unsigned char *payload;
893 y(get_buf, &payload, &length);
895 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_VERSION, payload);
900 * Formats the reply message for a GET_BAR_CONFIG request and sends it to the
904 IPC_HANDLER(get_bar_config) {
905 yajl_gen gen = ygenalloc();
907 /* If no ID was passed, we return a JSON array with all IDs */
908 if (message_size == 0) {
911 TAILQ_FOREACH(current, &barconfigs, configs) {
916 const unsigned char *payload;
918 y(get_buf, &payload, &length);
920 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BAR_CONFIG, payload);
925 /* To get a properly terminated buffer, we copy
926 * message_size bytes out of the buffer */
928 sasprintf(&bar_id, "%.*s", message_size, message);
929 LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
930 Barconfig *current, *config = NULL;
931 TAILQ_FOREACH(current, &barconfigs, configs) {
932 if (strcmp(current->id, bar_id) != 0)
941 /* If we did not find a config for the given ID, the reply will contain
942 * a null 'id' field. */
950 dump_bar_config(gen, config);
953 const unsigned char *payload;
955 y(get_buf, &payload, &length);
957 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BAR_CONFIG, payload);
962 * Returns a list of configured binding modes
965 IPC_HANDLER(get_binding_modes) {
966 yajl_gen gen = ygenalloc();
970 SLIST_FOREACH(mode, &modes, modes) {
975 const unsigned char *payload;
977 y(get_buf, &payload, &length);
979 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BINDING_MODES, payload);
984 * Callback for the YAJL parser (will be called when a string is parsed).
987 static int add_subscription(void *extra, const unsigned char *s,
989 ipc_client *client = extra;
991 DLOG("should add subscription to extra %p, sub %.*s\n", client, (int)len, s);
992 int event = client->num_events;
994 client->num_events++;
995 client->events = srealloc(client->events, client->num_events * sizeof(char *));
996 /* We copy the string because it is not null-terminated and strndup()
997 * is missing on some BSD systems */
998 client->events[event] = scalloc(len + 1, 1);
999 memcpy(client->events[event], s, len);
1001 DLOG("client is now subscribed to:\n");
1002 for (int i = 0; i < client->num_events; i++)
1003 DLOG("event %s\n", client->events[i]);
1010 * Subscribes this connection to the event types which were given as a JSON
1011 * serialized array in the payload field of the message.
1014 IPC_HANDLER(subscribe) {
1017 ipc_client *current, *client = NULL;
1019 /* Search the ipc_client structure for this connection */
1020 TAILQ_FOREACH(current, &all_clients, clients) {
1021 if (current->fd != fd)
1028 if (client == NULL) {
1029 ELOG("Could not find ipc_client data structure for fd %d\n", fd);
1033 /* Setup the JSON parser */
1034 static yajl_callbacks callbacks = {
1035 .yajl_string = add_subscription,
1038 p = yalloc(&callbacks, (void *)client);
1039 stat = yajl_parse(p, (const unsigned char *)message, message_size);
1040 if (stat != yajl_status_ok) {
1042 err = yajl_get_error(p, true, (const unsigned char *)message,
1044 ELOG("YAJL parse error: %s\n", err);
1045 yajl_free_error(p, err);
1047 const char *reply = "{\"success\":false}";
1048 ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_SUBSCRIBE, (const uint8_t *)reply);
1053 const char *reply = "{\"success\":true}";
1054 ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_SUBSCRIBE, (const uint8_t *)reply);
1057 /* The index of each callback function corresponds to the numeric
1058 * value of the message type (see include/i3/ipc.h) */
1059 handler_t handlers[9] = {
1061 handle_get_workspaces,
1066 handle_get_bar_config,
1068 handle_get_binding_modes,
1072 * Handler for activity on a client connection, receives a message from a
1075 * For now, the maximum message size is 2048. I’m not sure for what the
1076 * IPC interface will be used in the future, thus I’m not implementing a
1077 * mechanism for arbitrarily long messages, as it seems like overkill
1081 static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
1082 uint32_t message_type;
1083 uint32_t message_length;
1084 uint8_t *message = NULL;
1086 int ret = ipc_recv_message(w->fd, &message_type, &message_length, &message);
1087 /* EOF or other error */
1089 /* Was this a spurious read? See ev(3) */
1090 if (ret == -1 && errno == EAGAIN) {
1095 /* If not, there was some kind of error. We don’t bother
1096 * and close the connection */
1099 /* Delete the client from the list of clients */
1100 ipc_client *current;
1101 TAILQ_FOREACH(current, &all_clients, clients) {
1102 if (current->fd != w->fd)
1105 for (int i = 0; i < current->num_events; i++)
1106 free(current->events[i]);
1107 free(current->events);
1108 /* We can call TAILQ_REMOVE because we break out of the
1109 * TAILQ_FOREACH afterwards */
1110 TAILQ_REMOVE(&all_clients, current, clients);
1115 ev_io_stop(EV_A_ w);
1119 DLOG("IPC: client disconnected\n");
1123 if (message_type >= (sizeof(handlers) / sizeof(handler_t)))
1124 DLOG("Unhandled message type: %d\n", message_type);
1126 handler_t h = handlers[message_type];
1127 h(w->fd, message, 0, message_length, message_type);
1134 * Handler for activity on the listening socket, meaning that a new client
1135 * has just connected and we should accept() him. Sets up the event handler
1136 * for activity on the new connection and inserts the file descriptor into
1137 * the list of clients.
1140 void ipc_new_client(EV_P_ struct ev_io *w, int revents) {
1141 struct sockaddr_un peer;
1142 socklen_t len = sizeof(struct sockaddr_un);
1144 if ((client = accept(w->fd, (struct sockaddr *)&peer, &len)) < 0) {
1152 /* Close this file descriptor on exec() */
1153 (void)fcntl(client, F_SETFD, FD_CLOEXEC);
1155 set_nonblock(client);
1157 struct ev_io *package = scalloc(1, sizeof(struct ev_io));
1158 ev_io_init(package, ipc_receive_message, client, EV_READ);
1159 ev_io_start(EV_A_ package);
1161 DLOG("IPC: new client connected on fd %d\n", w->fd);
1163 ipc_client *new = scalloc(1, sizeof(ipc_client));
1166 TAILQ_INSERT_TAIL(&all_clients, new, clients);
1170 * Creates the UNIX domain socket at the given path, sets it to non-blocking
1171 * mode, bind()s and listen()s on it.
1174 int ipc_create_socket(const char *filename) {
1177 FREE(current_socketpath);
1179 char *resolved = resolve_tilde(filename);
1180 DLOG("Creating IPC-socket at %s\n", resolved);
1181 char *copy = sstrdup(resolved);
1182 const char *dir = dirname(copy);
1183 if (!path_exists(dir))
1184 mkdirp(dir, DEFAULT_DIR_MODE);
1187 /* Unlink the unix domain socket before */
1190 if ((sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
1196 (void)fcntl(sockfd, F_SETFD, FD_CLOEXEC);
1198 struct sockaddr_un addr;
1199 memset(&addr, 0, sizeof(struct sockaddr_un));
1200 addr.sun_family = AF_LOCAL;
1201 strncpy(addr.sun_path, resolved, sizeof(addr.sun_path) - 1);
1202 if (bind(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) {
1208 set_nonblock(sockfd);
1210 if (listen(sockfd, 5) < 0) {
1216 current_socketpath = resolved;
1221 * Generates a json workspace event. Returns a dynamically allocated yajl
1222 * generator. Free with yajl_gen_free().
1224 yajl_gen ipc_marshal_workspace_event(const char *change, Con *current, Con *old) {
1225 setlocale(LC_NUMERIC, "C");
1226 yajl_gen gen = ygenalloc();
1234 if (current == NULL)
1237 dump_node(gen, current, false);
1243 dump_node(gen, old, false);
1247 setlocale(LC_NUMERIC, "");
1253 * For the workspace events we send, along with the usual "change" field, also
1254 * the workspace container in "current". For focus events, we send the
1255 * previously focused workspace in "old".
1257 void ipc_send_workspace_event(const char *change, Con *current, Con *old) {
1258 yajl_gen gen = ipc_marshal_workspace_event(change, current, old);
1260 const unsigned char *payload;
1262 y(get_buf, &payload, &length);
1264 ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
1270 * For the window events we send, along the usual "change" field,
1271 * also the window container, in "container".
1273 void ipc_send_window_event(const char *property, Con *con) {
1274 DLOG("Issue IPC window %s event (con = %p, window = 0x%08x)\n",
1275 property, con, (con->window ? con->window->id : XCB_WINDOW_NONE));
1277 setlocale(LC_NUMERIC, "C");
1278 yajl_gen gen = ygenalloc();
1286 dump_node(gen, con, false);
1290 const unsigned char *payload;
1292 y(get_buf, &payload, &length);
1294 ipc_send_event("window", I3_IPC_EVENT_WINDOW, (const char *)payload);
1296 setlocale(LC_NUMERIC, "");
1300 * For the barconfig update events, we send the serialized barconfig.
1302 void ipc_send_barconfig_update_event(Barconfig *barconfig) {
1303 DLOG("Issue barconfig_update event for id = %s\n", barconfig->id);
1304 setlocale(LC_NUMERIC, "C");
1305 yajl_gen gen = ygenalloc();
1307 dump_bar_config(gen, barconfig);
1309 const unsigned char *payload;
1311 y(get_buf, &payload, &length);
1313 ipc_send_event("barconfig_update", I3_IPC_EVENT_BARCONFIG_UPDATE, (const char *)payload);
1315 setlocale(LC_NUMERIC, "");
1319 * For the binding events, we send the serialized binding struct.
1321 void ipc_send_binding_event(const char *event_type, Binding *bind) {
1322 DLOG("Issue IPC binding %s event (sym = %s, code = %d)\n", event_type, bind->symbol, bind->keycode);
1324 setlocale(LC_NUMERIC, "C");
1326 yajl_gen gen = ygenalloc();
1334 dump_binding(gen, bind);
1338 const unsigned char *payload;
1340 y(get_buf, &payload, &length);
1342 ipc_send_event("binding", I3_IPC_EVENT_BINDING, (const char *)payload);
1345 setlocale(LC_NUMERIC, "");