]> git.sur5r.net Git - i3/i3/blobdiff - src/ipc.c
Merge branch 'fix-dump-log-errmsg'
[i3/i3] / src / ipc.c
index 3733034dec5713ae6fabaef1988beadf83010088..60ce814540d6c7a3c61ac3969b1a652770226c06 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -97,7 +97,7 @@ void ipc_send_event(const char *event, uint32_t message_type, const char *payloa
  * when exiting or restarting only!
  *
  */
-void ipc_shutdown() {
+void ipc_shutdown(void) {
     ipc_client *current;
     while (!TAILQ_EMPTY(&all_clients)) {
         current = TAILQ_FIRST(&all_clients);
@@ -125,12 +125,18 @@ IPC_HANDLER(command) {
     if (command_output->needs_tree_render)
         tree_render();
 
-    /* If no reply was provided, we just use the default success message */
-    ipc_send_message(fd, strlen(command_output->json_output),
-                     I3_IPC_REPLY_TYPE_COMMAND,
-                     (const uint8_t*)command_output->json_output);
+    const unsigned char *reply;
+#if YAJL_MAJOR >= 2
+    size_t length;
+#else
+    unsigned int length;
+#endif
+    yajl_gen_get_buf(command_output->json_gen, &reply, &length);
+
+    ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_COMMAND,
+                     (const uint8_t*)reply);
 
-    free(command_output->json_output);
+    yajl_gen_free(command_output->json_gen);
 }
 
 static void dump_rect(yajl_gen gen, const char *name, Rect r) {
@@ -443,6 +449,9 @@ IPC_HANDLER(get_outputs) {
         ystr("active");
         y(bool, output->active);
 
+        ystr("primary");
+        y(bool, output->primary);
+
         ystr("rect");
         y(map_open);
         ystr("x");