]> git.sur5r.net Git - i3/i3/blobdiff - src/ipc.c
ipc/parser: commands can now return custom JSON replies
[i3/i3] / src / ipc.c
index e757ed2296ca416fe089d174718b3a84c3afee8b..2c105acc35e4d322beba6bd4c44ee512f21692d3 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -115,13 +115,13 @@ IPC_HANDLER(command) {
         char *command = scalloc(message_size + 1);
         strncpy(command, (const char*)message, message_size);
         LOG("IPC: received: *%s*\n", command);
-        parse_cmd((const char*)command);
+        const char *reply = parse_cmd((const char*)command);
         tree_render();
         free(command);
 
-        /* For now, every command gets a positive acknowledge
-         * (will change with the new command parser) */
-        const char *reply = "{\"success\":true}";
+        /* If no reply was provided, we just use the default success message */
+        if (reply == NULL)
+                reply = "{\"success\":true}";
         ipc_send_message(fd, (const unsigned char*)reply,
                          I3_IPC_REPLY_TYPE_COMMAND, strlen(reply));
 }
@@ -137,6 +137,12 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
         ystr("orientation");
         y(integer, con->orientation);
 
+        ystr("urgent");
+        y(integer, con->urgent);
+
+        ystr("focused");
+        y(integer, (con == focused));
+
         ystr("layout");
         y(integer, con->layout);
 
@@ -168,6 +174,13 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
         }
         y(array_close);
 
+        ystr("floating-nodes");
+        y(array_open);
+        TAILQ_FOREACH(node, &(con->floating_head), floating_windows) {
+                dump_node(gen, node, inplace_restart);
+        }
+        y(array_close);
+
         ystr("focus");
         y(array_open);
         TAILQ_FOREACH(node, &(con->focus_head), nodes) {