]> git.sur5r.net Git - i3/i3/blobdiff - src/ipc.c
parser: return a proper JSON reply on parse errors
[i3/i3] / src / ipc.c
index 0412bdae5676356f040796235be55ef714e8169e..eed63bd4e0072820095561d5b044b1feb19b9f81 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -112,14 +112,16 @@ void ipc_shutdown() {
 IPC_HANDLER(command) {
         /* To get a properly terminated buffer, we copy
          * message_size bytes out of the buffer */
-        char *command = scalloc(message_size);
+        char *command = scalloc(message_size + 1);
         strncpy(command, (const char*)message, message_size);
-        parse_command((const char*)command);
+        LOG("IPC: received: *%s*\n", 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));
 }
@@ -135,9 +137,18 @@ 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);
 
+        ystr("border");
+        y(integer, con->border_style);
+
         ystr("rect");
         y(map_open);
         ystr("x");
@@ -160,16 +171,23 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
 
         ystr("nodes");
         y(array_open);
-        Con *leaf;
-        TAILQ_FOREACH(leaf, &(con->nodes_head), nodes) {
-                dump_node(gen, leaf, inplace_restart);
+        Con *node;
+        TAILQ_FOREACH(node, &(con->nodes_head), nodes) {
+                dump_node(gen, node, 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(leaf, &(con->nodes_head), nodes) {
-                y(integer, (long int)leaf);
+        TAILQ_FOREACH(node, &(con->focus_head), nodes) {
+                y(integer, (long int)node);
         }
         y(array_close);
 
@@ -178,13 +196,13 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
 
         if (inplace_restart) {
                 if (con->window != NULL) {
-                ystr("swallows");
-                y(array_open);
-                y(map_open);
-                ystr("id");
-                y(integer, con->window->id);
-                y(map_close);
-                y(array_close);
+                       ystr("swallows");
+                       y(array_open);
+                       y(map_open);
+                       ystr("id");
+                       y(integer, con->window->id);
+                       y(map_close);
+                       y(array_close);
                 }
         }