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));
297 if (con->type != CT_ROOT && con->type != CT_OUTPUT) {
299 ystr(con_get_output(con)->name);
303 switch (con->layout) {
305 DLOG("About to dump layout=default, this is a bug in the code.\n");
328 ystr("workspace_layout");
329 switch (con->workspace_layout) {
340 DLOG("About to dump workspace_layout=%d (none of default/stacked/tabbed), this is a bug.\n", con->workspace_layout);
345 ystr("last_split_layout");
346 switch (con->layout) {
356 switch (con->border_style) {
368 ystr("current_border_width");
369 y(integer, con->current_border_width);
371 dump_rect(gen, "rect", con->rect);
372 dump_rect(gen, "deco_rect", con->deco_rect);
373 dump_rect(gen, "window_rect", con->window_rect);
374 dump_rect(gen, "geometry", con->geometry);
377 if (con->window && con->window->name)
378 ystr(i3string_as_utf8(con->window->name));
379 else if (con->name != NULL)
384 if (con->title_format != NULL) {
385 ystr("title_format");
386 ystr(con->title_format);
389 if (con->type == CT_WORKSPACE) {
391 y(integer, con->num);
396 y(integer, con->window->id);
400 if (con->window && !inplace_restart) {
401 /* Window properties are useless to preserve when restarting because
402 * they will be queried again anyway. However, for i3-save-tree(1),
403 * they are very useful and save i3-save-tree dealing with X11. */
404 ystr("window_properties");
407 #define DUMP_PROPERTY(key, prop_name) \
409 if (con->window->prop_name != NULL) { \
411 ystr(con->window->prop_name); \
415 DUMP_PROPERTY("class", class_class);
416 DUMP_PROPERTY("instance", class_instance);
417 DUMP_PROPERTY("window_role", role);
419 if (con->window->name != NULL) {
421 ystr(i3string_as_utf8(con->window->name));
424 ystr("transient_for");
425 if (con->window->transient_for == XCB_NONE)
428 y(integer, con->window->transient_for);
436 if (con->type != CT_DOCKAREA || !inplace_restart) {
437 TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
438 dump_node(gen, node, inplace_restart);
443 ystr("floating_nodes");
445 TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
446 dump_node(gen, node, inplace_restart);
452 TAILQ_FOREACH(node, &(con->focus_head), focused) {
453 y(integer, (uintptr_t)node);
457 ystr("fullscreen_mode");
458 y(integer, con->fullscreen_mode);
461 y(bool, con->sticky);
464 switch (con->floating) {
465 case FLOATING_AUTO_OFF:
468 case FLOATING_AUTO_ON:
471 case FLOATING_USER_OFF:
474 case FLOATING_USER_ON:
482 TAILQ_FOREACH(match, &(con->swallow_head), matches) {
483 /* We will generate a new restart_mode match specification after this
484 * loop, so skip this one. */
485 if (match->restart_mode)
488 if (match->dock != M_DONTCHECK) {
490 y(integer, match->dock);
491 ystr("insert_where");
492 y(integer, match->insert_where);
495 #define DUMP_REGEX(re_name) \
497 if (match->re_name != NULL) { \
499 ystr(match->re_name->pattern); \
504 DUMP_REGEX(instance);
505 DUMP_REGEX(window_role);
512 if (inplace_restart) {
513 if (con->window != NULL) {
516 y(integer, con->window->id);
517 ystr("restart_mode");
524 if (inplace_restart && con->window != NULL) {
526 y(integer, con->depth);
532 static void dump_bar_bindings(yajl_gen gen, Barconfig *config) {
533 if (TAILQ_EMPTY(&(config->bar_bindings)))
539 struct Barbinding *current;
540 TAILQ_FOREACH(current, &(config->bar_bindings), bindings) {
544 y(integer, current->input_code);
546 ystr(current->command);
554 static void dump_bar_config(yajl_gen gen, Barconfig *config) {
560 if (config->num_outputs > 0) {
563 for (int c = 0; c < config->num_outputs; c++)
564 ystr(config->outputs[c]);
568 if (!TAILQ_EMPTY(&(config->tray_outputs))) {
569 ystr("tray_outputs");
572 struct tray_output_t *tray_output;
573 TAILQ_FOREACH(tray_output, &(config->tray_outputs), tray_outputs) {
574 ystr(tray_output->output);
580 #define YSTR_IF_SET(name) \
582 if (config->name) { \
584 ystr(config->name); \
588 ystr("tray_padding");
589 y(integer, config->tray_padding);
591 YSTR_IF_SET(socket_path);
594 switch (config->mode) {
607 ystr("hidden_state");
608 switch (config->hidden_state) {
619 switch (config->modifier) {
646 dump_bar_bindings(gen, config);
649 if (config->position == P_BOTTOM)
654 YSTR_IF_SET(status_command);
657 if (config->separator_symbol) {
658 ystr("separator_symbol");
659 ystr(config->separator_symbol);
662 ystr("workspace_buttons");
663 y(bool, !config->hide_workspace_buttons);
665 ystr("strip_workspace_numbers");
666 y(bool, config->strip_workspace_numbers);
668 ystr("binding_mode_indicator");
669 y(bool, !config->hide_binding_mode_indicator);
672 y(bool, config->verbose);
675 #define YSTR_IF_SET(name) \
677 if (config->colors.name) { \
679 ystr(config->colors.name); \
685 YSTR_IF_SET(background);
686 YSTR_IF_SET(statusline);
687 YSTR_IF_SET(separator);
688 YSTR_IF_SET(focused_background);
689 YSTR_IF_SET(focused_statusline);
690 YSTR_IF_SET(focused_separator);
691 YSTR_IF_SET(focused_workspace_border);
692 YSTR_IF_SET(focused_workspace_bg);
693 YSTR_IF_SET(focused_workspace_text);
694 YSTR_IF_SET(active_workspace_border);
695 YSTR_IF_SET(active_workspace_bg);
696 YSTR_IF_SET(active_workspace_text);
697 YSTR_IF_SET(inactive_workspace_border);
698 YSTR_IF_SET(inactive_workspace_bg);
699 YSTR_IF_SET(inactive_workspace_text);
700 YSTR_IF_SET(urgent_workspace_border);
701 YSTR_IF_SET(urgent_workspace_bg);
702 YSTR_IF_SET(urgent_workspace_text);
703 YSTR_IF_SET(binding_mode_border);
704 YSTR_IF_SET(binding_mode_bg);
705 YSTR_IF_SET(binding_mode_text);
713 setlocale(LC_NUMERIC, "C");
714 yajl_gen gen = ygenalloc();
715 dump_node(gen, croot, false);
716 setlocale(LC_NUMERIC, "");
718 const unsigned char *payload;
720 y(get_buf, &payload, &length);
722 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_TREE, payload);
727 * Formats the reply message for a GET_WORKSPACES request and sends it to the
731 IPC_HANDLER(get_workspaces) {
732 yajl_gen gen = ygenalloc();
735 Con *focused_ws = con_get_workspace(focused);
738 TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
739 if (con_is_internal(output))
742 TAILQ_FOREACH(ws, &(output_get_content(output)->nodes_head), nodes) {
743 assert(ws->type == CT_WORKSPACE);
753 y(bool, workspace_is_visible(ws));
756 y(bool, ws == focused_ws);
761 y(integer, ws->rect.x);
763 y(integer, ws->rect.y);
765 y(integer, ws->rect.width);
767 y(integer, ws->rect.height);
782 const unsigned char *payload;
784 y(get_buf, &payload, &length);
786 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_WORKSPACES, payload);
791 * Formats the reply message for a GET_OUTPUTS request and sends it to the
795 IPC_HANDLER(get_outputs) {
796 yajl_gen gen = ygenalloc();
800 TAILQ_FOREACH(output, &outputs, outputs) {
807 y(bool, output->active);
810 y(bool, output->primary);
815 y(integer, output->rect.x);
817 y(integer, output->rect.y);
819 y(integer, output->rect.width);
821 y(integer, output->rect.height);
824 ystr("current_workspace");
826 if (output->con && (ws = con_get_fullscreen_con(output->con, CF_OUTPUT)))
836 const unsigned char *payload;
838 y(get_buf, &payload, &length);
840 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_OUTPUTS, payload);
845 * Formats the reply message for a GET_MARKS request and sends it to the
849 IPC_HANDLER(get_marks) {
850 yajl_gen gen = ygenalloc();
854 TAILQ_FOREACH(con, &all_cons, all_cons) {
856 TAILQ_FOREACH(mark, &(con->marks_head), marks) {
863 const unsigned char *payload;
865 y(get_buf, &payload, &length);
867 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_MARKS, payload);
872 * Returns the version of i3
875 IPC_HANDLER(get_version) {
876 yajl_gen gen = ygenalloc();
880 y(integer, MAJOR_VERSION);
883 y(integer, MINOR_VERSION);
886 y(integer, PATCH_VERSION);
888 ystr("human_readable");
891 ystr("loaded_config_file_name");
892 ystr(current_configpath);
896 const unsigned char *payload;
898 y(get_buf, &payload, &length);
900 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_VERSION, payload);
905 * Formats the reply message for a GET_BAR_CONFIG request and sends it to the
909 IPC_HANDLER(get_bar_config) {
910 yajl_gen gen = ygenalloc();
912 /* If no ID was passed, we return a JSON array with all IDs */
913 if (message_size == 0) {
916 TAILQ_FOREACH(current, &barconfigs, configs) {
921 const unsigned char *payload;
923 y(get_buf, &payload, &length);
925 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BAR_CONFIG, payload);
930 /* To get a properly terminated buffer, we copy
931 * message_size bytes out of the buffer */
933 sasprintf(&bar_id, "%.*s", message_size, message);
934 LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
935 Barconfig *current, *config = NULL;
936 TAILQ_FOREACH(current, &barconfigs, configs) {
937 if (strcmp(current->id, bar_id) != 0)
946 /* If we did not find a config for the given ID, the reply will contain
947 * a null 'id' field. */
955 dump_bar_config(gen, config);
958 const unsigned char *payload;
960 y(get_buf, &payload, &length);
962 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BAR_CONFIG, payload);
967 * Returns a list of configured binding modes
970 IPC_HANDLER(get_binding_modes) {
971 yajl_gen gen = ygenalloc();
975 SLIST_FOREACH(mode, &modes, modes) {
980 const unsigned char *payload;
982 y(get_buf, &payload, &length);
984 ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BINDING_MODES, payload);
989 * Callback for the YAJL parser (will be called when a string is parsed).
992 static int add_subscription(void *extra, const unsigned char *s,
994 ipc_client *client = extra;
996 DLOG("should add subscription to extra %p, sub %.*s\n", client, (int)len, s);
997 int event = client->num_events;
999 client->num_events++;
1000 client->events = srealloc(client->events, client->num_events * sizeof(char *));
1001 /* We copy the string because it is not null-terminated and strndup()
1002 * is missing on some BSD systems */
1003 client->events[event] = scalloc(len + 1, 1);
1004 memcpy(client->events[event], s, len);
1006 DLOG("client is now subscribed to:\n");
1007 for (int i = 0; i < client->num_events; i++)
1008 DLOG("event %s\n", client->events[i]);
1015 * Subscribes this connection to the event types which were given as a JSON
1016 * serialized array in the payload field of the message.
1019 IPC_HANDLER(subscribe) {
1022 ipc_client *current, *client = NULL;
1024 /* Search the ipc_client structure for this connection */
1025 TAILQ_FOREACH(current, &all_clients, clients) {
1026 if (current->fd != fd)
1033 if (client == NULL) {
1034 ELOG("Could not find ipc_client data structure for fd %d\n", fd);
1038 /* Setup the JSON parser */
1039 static yajl_callbacks callbacks = {
1040 .yajl_string = add_subscription,
1043 p = yalloc(&callbacks, (void *)client);
1044 stat = yajl_parse(p, (const unsigned char *)message, message_size);
1045 if (stat != yajl_status_ok) {
1047 err = yajl_get_error(p, true, (const unsigned char *)message,
1049 ELOG("YAJL parse error: %s\n", err);
1050 yajl_free_error(p, err);
1052 const char *reply = "{\"success\":false}";
1053 ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_SUBSCRIBE, (const uint8_t *)reply);
1058 const char *reply = "{\"success\":true}";
1059 ipc_send_message(fd, strlen(reply), I3_IPC_REPLY_TYPE_SUBSCRIBE, (const uint8_t *)reply);
1062 /* The index of each callback function corresponds to the numeric
1063 * value of the message type (see include/i3/ipc.h) */
1064 handler_t handlers[9] = {
1066 handle_get_workspaces,
1071 handle_get_bar_config,
1073 handle_get_binding_modes,
1077 * Handler for activity on a client connection, receives a message from a
1080 * For now, the maximum message size is 2048. I’m not sure for what the
1081 * IPC interface will be used in the future, thus I’m not implementing a
1082 * mechanism for arbitrarily long messages, as it seems like overkill
1086 static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
1087 uint32_t message_type;
1088 uint32_t message_length;
1089 uint8_t *message = NULL;
1091 int ret = ipc_recv_message(w->fd, &message_type, &message_length, &message);
1092 /* EOF or other error */
1094 /* Was this a spurious read? See ev(3) */
1095 if (ret == -1 && errno == EAGAIN) {
1100 /* If not, there was some kind of error. We don’t bother
1101 * and close the connection */
1104 /* Delete the client from the list of clients */
1105 ipc_client *current;
1106 TAILQ_FOREACH(current, &all_clients, clients) {
1107 if (current->fd != w->fd)
1110 for (int i = 0; i < current->num_events; i++)
1111 free(current->events[i]);
1112 free(current->events);
1113 /* We can call TAILQ_REMOVE because we break out of the
1114 * TAILQ_FOREACH afterwards */
1115 TAILQ_REMOVE(&all_clients, current, clients);
1120 ev_io_stop(EV_A_ w);
1124 DLOG("IPC: client disconnected\n");
1128 if (message_type >= (sizeof(handlers) / sizeof(handler_t)))
1129 DLOG("Unhandled message type: %d\n", message_type);
1131 handler_t h = handlers[message_type];
1132 h(w->fd, message, 0, message_length, message_type);
1139 * Handler for activity on the listening socket, meaning that a new client
1140 * has just connected and we should accept() him. Sets up the event handler
1141 * for activity on the new connection and inserts the file descriptor into
1142 * the list of clients.
1145 void ipc_new_client(EV_P_ struct ev_io *w, int revents) {
1146 struct sockaddr_un peer;
1147 socklen_t len = sizeof(struct sockaddr_un);
1149 if ((client = accept(w->fd, (struct sockaddr *)&peer, &len)) < 0) {
1157 /* Close this file descriptor on exec() */
1158 (void)fcntl(client, F_SETFD, FD_CLOEXEC);
1160 set_nonblock(client);
1162 struct ev_io *package = scalloc(1, sizeof(struct ev_io));
1163 ev_io_init(package, ipc_receive_message, client, EV_READ);
1164 ev_io_start(EV_A_ package);
1166 DLOG("IPC: new client connected on fd %d\n", w->fd);
1168 ipc_client *new = scalloc(1, sizeof(ipc_client));
1171 TAILQ_INSERT_TAIL(&all_clients, new, clients);
1175 * Creates the UNIX domain socket at the given path, sets it to non-blocking
1176 * mode, bind()s and listen()s on it.
1179 int ipc_create_socket(const char *filename) {
1182 FREE(current_socketpath);
1184 char *resolved = resolve_tilde(filename);
1185 DLOG("Creating IPC-socket at %s\n", resolved);
1186 char *copy = sstrdup(resolved);
1187 const char *dir = dirname(copy);
1188 if (!path_exists(dir))
1189 mkdirp(dir, DEFAULT_DIR_MODE);
1192 /* Unlink the unix domain socket before */
1195 if ((sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0) {
1201 (void)fcntl(sockfd, F_SETFD, FD_CLOEXEC);
1203 struct sockaddr_un addr;
1204 memset(&addr, 0, sizeof(struct sockaddr_un));
1205 addr.sun_family = AF_LOCAL;
1206 strncpy(addr.sun_path, resolved, sizeof(addr.sun_path) - 1);
1207 if (bind(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_un)) < 0) {
1213 set_nonblock(sockfd);
1215 if (listen(sockfd, 5) < 0) {
1221 current_socketpath = resolved;
1226 * Generates a json workspace event. Returns a dynamically allocated yajl
1227 * generator. Free with yajl_gen_free().
1229 yajl_gen ipc_marshal_workspace_event(const char *change, Con *current, Con *old) {
1230 setlocale(LC_NUMERIC, "C");
1231 yajl_gen gen = ygenalloc();
1239 if (current == NULL)
1242 dump_node(gen, current, false);
1248 dump_node(gen, old, false);
1252 setlocale(LC_NUMERIC, "");
1258 * For the workspace events we send, along with the usual "change" field, also
1259 * the workspace container in "current". For focus events, we send the
1260 * previously focused workspace in "old".
1262 void ipc_send_workspace_event(const char *change, Con *current, Con *old) {
1263 yajl_gen gen = ipc_marshal_workspace_event(change, current, old);
1265 const unsigned char *payload;
1267 y(get_buf, &payload, &length);
1269 ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
1275 * For the window events we send, along the usual "change" field,
1276 * also the window container, in "container".
1278 void ipc_send_window_event(const char *property, Con *con) {
1279 DLOG("Issue IPC window %s event (con = %p, window = 0x%08x)\n",
1280 property, con, (con->window ? con->window->id : XCB_WINDOW_NONE));
1282 setlocale(LC_NUMERIC, "C");
1283 yajl_gen gen = ygenalloc();
1291 dump_node(gen, con, false);
1295 const unsigned char *payload;
1297 y(get_buf, &payload, &length);
1299 ipc_send_event("window", I3_IPC_EVENT_WINDOW, (const char *)payload);
1301 setlocale(LC_NUMERIC, "");
1305 * For the barconfig update events, we send the serialized barconfig.
1307 void ipc_send_barconfig_update_event(Barconfig *barconfig) {
1308 DLOG("Issue barconfig_update event for id = %s\n", barconfig->id);
1309 setlocale(LC_NUMERIC, "C");
1310 yajl_gen gen = ygenalloc();
1312 dump_bar_config(gen, barconfig);
1314 const unsigned char *payload;
1316 y(get_buf, &payload, &length);
1318 ipc_send_event("barconfig_update", I3_IPC_EVENT_BARCONFIG_UPDATE, (const char *)payload);
1320 setlocale(LC_NUMERIC, "");
1324 * For the binding events, we send the serialized binding struct.
1326 void ipc_send_binding_event(const char *event_type, Binding *bind) {
1327 DLOG("Issue IPC binding %s event (sym = %s, code = %d)\n", event_type, bind->symbol, bind->keycode);
1329 setlocale(LC_NUMERIC, "C");
1331 yajl_gen gen = ygenalloc();
1339 dump_binding(gen, bind);
1343 const unsigned char *payload;
1345 y(get_buf, &payload, &length);
1347 ipc_send_event("binding", I3_IPC_EVENT_BINDING, (const char *)payload);
1350 setlocale(LC_NUMERIC, "");