]> git.sur5r.net Git - i3/i3/blobdiff - src/ipc.c
Ensure all *.[ch] files include config.h
[i3/i3] / src / ipc.c
index 68cc417a86383aec4773ba95d2c2dcb98f651164..73f8d8cb99eb0c7132b09b4a35f8deee52da5519 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -1,5 +1,3 @@
-#undef I3__FILE__
-#define I3__FILE__ "ipc.c"
 /*
  * vim:ts=4:sw=4:expandtab
  *
@@ -10,8 +8,10 @@
  *
  */
 #include "all.h"
+
 #include "yajl_utils.h"
 
+#include <stdint.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <fcntl.h>
@@ -71,6 +71,9 @@ void ipc_shutdown(void) {
         current = TAILQ_FIRST(&all_clients);
         shutdown(current->fd, SHUT_RDWR);
         close(current->fd);
+        for (int i = 0; i < current->num_events; i++)
+            free(current->events[i]);
+        free(current->events);
         TAILQ_REMOVE(&all_clients, current, clients);
         free(current);
     }
@@ -214,7 +217,7 @@ static void dump_binding(yajl_gen gen, Binding *bind) {
 void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
     y(map_open);
     ystr("id");
-    y(integer, (long int)con);
+    y(integer, (uintptr_t)con);
 
     ystr("type");
     switch (con->type) {
@@ -372,6 +375,11 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
     else
         y(null);
 
+    if (con->title_format != NULL) {
+        ystr("title_format");
+        ystr(con->title_format);
+    }
+
     if (con->type == CT_WORKSPACE) {
         ystr("num");
         y(integer, con->num);
@@ -436,7 +444,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
     ystr("focus");
     y(array_open);
     TAILQ_FOREACH(node, &(con->focus_head), focused) {
-        y(integer, (long int)node);
+        y(integer, (uintptr_t)node);
     }
     y(array_close);
 
@@ -471,7 +479,7 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
         if (match->restart_mode)
             continue;
         y(map_open);
-        if (match->dock != -1) {
+        if (match->dock != M_DONTCHECK) {
             ystr("dock");
             y(integer, match->dock);
             ystr("insert_where");
@@ -551,6 +559,18 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
         y(array_close);
     }
 
+    if (!TAILQ_EMPTY(&(config->tray_outputs))) {
+        ystr("tray_outputs");
+        y(array_open);
+
+        struct tray_output_t *tray_output;
+        TAILQ_FOREACH(tray_output, &(config->tray_outputs), tray_outputs) {
+            ystr(tray_output->output);
+        }
+
+        y(array_close);
+    }
+
 #define YSTR_IF_SET(name)       \
     do {                        \
         if (config->name) {     \
@@ -559,8 +579,6 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
         }                       \
     } while (0)
 
-    YSTR_IF_SET(tray_output);
-
     ystr("tray_padding");
     y(integer, config->tray_padding);
 
@@ -593,6 +611,9 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
 
     ystr("modifier");
     switch (config->modifier) {
+        case M_NONE:
+            ystr("none");
+            break;
         case M_CONTROL:
             ystr("ctrl");
             break;
@@ -608,11 +629,6 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
         case M_MOD3:
             ystr("Mod3");
             break;
-        /*
-               case M_MOD4:
-               ystr("Mod4");
-               break;
-               */
         case M_MOD5:
             ystr("Mod5");
             break;
@@ -663,6 +679,9 @@ static void dump_bar_config(yajl_gen gen, Barconfig *config) {
     YSTR_IF_SET(background);
     YSTR_IF_SET(statusline);
     YSTR_IF_SET(separator);
+    YSTR_IF_SET(focused_background);
+    YSTR_IF_SET(focused_statusline);
+    YSTR_IF_SET(focused_separator);
     YSTR_IF_SET(focused_workspace_border);
     YSTR_IF_SET(focused_workspace_bg);
     YSTR_IF_SET(focused_workspace_text);
@@ -938,6 +957,28 @@ IPC_HANDLER(get_bar_config) {
     y(free);
 }
 
+/*
+ * Returns a list of configured binding modes
+ *
+ */
+IPC_HANDLER(get_binding_modes) {
+    yajl_gen gen = ygenalloc();
+
+    y(array_open);
+    struct Mode *mode;
+    SLIST_FOREACH(mode, &modes, modes) {
+        ystr(mode->name);
+    }
+    y(array_close);
+
+    const unsigned char *payload;
+    ylength length;
+    y(get_buf, &payload, &length);
+
+    ipc_send_message(fd, length, I3_IPC_REPLY_TYPE_BINDING_MODES, payload);
+    y(free);
+}
+
 /*
  * Callback for the YAJL parser (will be called when a string is parsed).
  *
@@ -1014,7 +1055,7 @@ IPC_HANDLER(subscribe) {
 
 /* The index of each callback function corresponds to the numeric
  * value of the message type (see include/i3/ipc.h) */
-handler_t handlers[8] = {
+handler_t handlers[9] = {
     handle_command,
     handle_get_workspaces,
     handle_subscribe,
@@ -1023,6 +1064,7 @@ handler_t handlers[8] = {
     handle_get_marks,
     handle_get_bar_config,
     handle_get_version,
+    handle_get_binding_modes,
 };
 
 /*
@@ -1061,6 +1103,7 @@ static void ipc_receive_message(EV_P_ struct ev_io *w, int revents) {
 
             for (int i = 0; i < current->num_events; i++)
                 free(current->events[i]);
+            free(current->events);
             /* We can call TAILQ_REMOVE because we break out of the
              * TAILQ_FOREACH afterwards */
             TAILQ_REMOVE(&all_clients, current, clients);