#include "all.h"
#include "yajl_utils.h"
+#include <stdint.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <fcntl.h>
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);
}
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) {
ystr("urgent");
y(bool, con->urgent);
- if (con->mark != NULL) {
- ystr("mark");
- ystr(con->mark);
+ if (!TAILQ_EMPTY(&(con->marks_head))) {
+ ystr("marks");
+ y(array_open);
+
+ mark_t *mark;
+ TAILQ_FOREACH(mark, &(con->marks_head), marks) {
+ ystr(mark->name);
+ }
+
+ y(array_close);
}
ystr("focused");
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);
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);
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) { \
} \
} while (0)
- YSTR_IF_SET(tray_output);
-
ystr("tray_padding");
y(integer, config->tray_padding);
ystr("modifier");
switch (config->modifier) {
+ case M_NONE:
+ ystr("none");
+ break;
case M_CONTROL:
ystr("ctrl");
break;
case M_MOD3:
ystr("Mod3");
break;
- /*
- case M_MOD4:
- ystr("Mod4");
- break;
- */
case M_MOD5:
ystr("Mod5");
break;
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);
y(array_open);
Con *con;
- TAILQ_FOREACH(con, &all_cons, all_cons)
- if (con->mark != NULL)
- ystr(con->mark);
+ TAILQ_FOREACH(con, &all_cons, all_cons) {
+ mark_t *mark;
+ TAILQ_FOREACH(mark, &(con->marks_head), marks) {
+ ystr(mark->name);
+ }
+ }
y(array_close);
/* To get a properly terminated buffer, we copy
* message_size bytes out of the buffer */
- char *bar_id = scalloc(message_size + 1, 1);
- strncpy(bar_id, (const char *)message, message_size);
+ char *bar_id = NULL;
+ sasprintf(&bar_id, "%.*s", message_size, message);
LOG("IPC: looking for config for bar ID \"%s\"\n", bar_id);
Barconfig *current, *config = NULL;
TAILQ_FOREACH(current, &barconfigs, configs) {
config = current;
break;
}
+ free(bar_id);
if (!config) {
/* If we did not find a config for the given ID, the reply will contain
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).
*
/* 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,
handle_get_marks,
handle_get_bar_config,
handle_get_version,
+ handle_get_binding_modes,
};
/*
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);