X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fipc.c;h=73f8d8cb99eb0c7132b09b4a35f8deee52da5519;hb=f354f534357798eb3ba497b7143132f41ff090f6;hp=00b468fbbdf18cc671dcd6f5147e79d51df86c72;hpb=1f660a4cc401ecbeb4cc5244fb71b8285f9f4b65;p=i3%2Fi3 diff --git a/src/ipc.c b/src/ipc.c index 00b468fb..73f8d8cb 100644 --- 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 #include #include #include @@ -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) { @@ -441,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); @@ -476,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"); @@ -608,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; @@ -623,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; @@ -956,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). * @@ -1032,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, @@ -1041,6 +1064,7 @@ handler_t handlers[8] = { handle_get_marks, handle_get_bar_config, handle_get_version, + handle_get_binding_modes, }; /* @@ -1079,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);