+
+/*
+ * For the workspace "focus" event we send, along the usual "change" field,
+ * also the current and previous workspace, in "current" and "old"
+ * respectively.
+ */
+void ipc_send_workspace_focus_event(Con *current, Con *old) {
+ setlocale(LC_NUMERIC, "C");
+ yajl_gen gen = ygenalloc();
+
+ y(map_open);
+
+ ystr("change");
+ ystr("focus");
+
+ ystr("current");
+ dump_node(gen, current, false);
+
+ ystr("old");
+ if (old == NULL)
+ y(null);
+ else
+ dump_node(gen, old, false);
+
+ y(map_close);
+
+ const unsigned char *payload;
+ ylength length;
+ y(get_buf, &payload, &length);
+
+ ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload);
+ y(free);
+ setlocale(LC_NUMERIC, "");
+}
+
+/**
+ * For the window events we send, along the usual "change" field,
+ * also the window container, in "container".
+ */
+void ipc_send_window_event(const char *property, Con *con) {
+ DLOG("Issue IPC window %s event (con = %p, window = 0x%08x)\n",
+ property, con, (con->window ? con->window->id : XCB_WINDOW_NONE));
+
+ setlocale(LC_NUMERIC, "C");
+ yajl_gen gen = ygenalloc();
+
+ y(map_open);
+
+ ystr("change");
+ ystr(property);
+
+ ystr("container");
+ dump_node(gen, con, false);
+
+ y(map_close);
+
+ const unsigned char *payload;
+ ylength length;
+ y(get_buf, &payload, &length);
+
+ ipc_send_event("window", I3_IPC_EVENT_WINDOW, (const char *)payload);
+ y(free);
+ setlocale(LC_NUMERIC, "");
+}
+
+/**
+ * For the barconfig update events, we send the serialized barconfig.
+ */
+void ipc_send_barconfig_update_event(Barconfig *barconfig) {
+ DLOG("Issue barconfig_update event for id = %s\n", barconfig->id);
+ setlocale(LC_NUMERIC, "C");
+ yajl_gen gen = ygenalloc();
+
+ dump_bar_config(gen, barconfig);
+
+ const unsigned char *payload;
+ ylength length;
+ y(get_buf, &payload, &length);
+
+ ipc_send_event("barconfig_update", I3_IPC_EVENT_BARCONFIG_UPDATE, (const char *)payload);
+ y(free);
+ setlocale(LC_NUMERIC, "");
+}