Ported over some message types from -next.
This commit is contained in:
parent
dab83ba413
commit
5d830e7a27
@ -27,7 +27,16 @@
|
|||||||
#define I3_IPC_MESSAGE_TYPE_COMMAND 0
|
#define I3_IPC_MESSAGE_TYPE_COMMAND 0
|
||||||
|
|
||||||
/** Requests the current workspaces from i3 */
|
/** Requests the current workspaces from i3 */
|
||||||
#define I3_IPC_MESSAGE_TYPE_GET_TREE 1
|
#define I3_IPC_MESSAGE_TYPE_GET_WORKSPACES 1
|
||||||
|
|
||||||
|
/** Subscribe to the specified events */
|
||||||
|
#define I3_IPC_MESSAGE_TYPE_SUBSCRIBE 2
|
||||||
|
|
||||||
|
/** Requests the current outputs from i3 */
|
||||||
|
#define I3_IPC_MESSAGE_TYPE_GET_OUTPUTS 3
|
||||||
|
|
||||||
|
/** Requests the tree layout from i3 */
|
||||||
|
#define I3_IPC_MESSAGE_TYPE_GET_TREE 4
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -39,7 +48,17 @@
|
|||||||
#define I3_IPC_REPLY_TYPE_COMMAND 0
|
#define I3_IPC_REPLY_TYPE_COMMAND 0
|
||||||
|
|
||||||
/** Workspaces reply type */
|
/** Workspaces reply type */
|
||||||
#define I3_IPC_REPLY_TYPE_TREE 1
|
#define I3_IPC_REPLY_TYPE_WORKSPACES 1
|
||||||
|
|
||||||
|
/** Subscription reply type */
|
||||||
|
#define I3_IPC_REPLY_TYPE_SUBSCRIBE 2
|
||||||
|
|
||||||
|
/** Outputs reply type */
|
||||||
|
#define I3_IPC_REPLY_TYPE_OUTPUTS 3
|
||||||
|
|
||||||
|
/** Tree reply type */
|
||||||
|
#define I3_IPC_REPLY_TYPE_TREE 4
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Events from i3 to clients. Events have the first bit set high.
|
* Events from i3 to clients. Events have the first bit set high.
|
||||||
|
157
src/ipc.c
157
src/ipc.c
@ -239,7 +239,6 @@ void dump_node(yajl_gen gen, struct Con *con, bool inplace_restart) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IPC_HANDLER(tree) {
|
IPC_HANDLER(tree) {
|
||||||
printf("tree\n");
|
|
||||||
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
||||||
dump_node(gen, croot, false);
|
dump_node(gen, croot, false);
|
||||||
|
|
||||||
@ -252,68 +251,66 @@ IPC_HANDLER(tree) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
/*
|
||||||
* Formats the reply message for a GET_WORKSPACES request and sends it to the
|
* Formats the reply message for a GET_WORKSPACES request and sends it to the
|
||||||
* client
|
* client
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IPC_HANDLER(get_workspaces) {
|
IPC_HANDLER(get_workspaces) {
|
||||||
Workspace *ws;
|
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
||||||
|
y(array_open);
|
||||||
|
|
||||||
Client *last_focused = SLIST_FIRST(&(c_ws->focus_stack));
|
Con *focused_ws = con_get_workspace(focused);
|
||||||
if (last_focused == SLIST_END(&(c_ws->focus_stack)))
|
|
||||||
last_focused = NULL;
|
|
||||||
|
|
||||||
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
Con *output;
|
||||||
y(array_open);
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes) {
|
||||||
|
Con *ws;
|
||||||
|
TAILQ_FOREACH(ws, &(output->nodes_head), nodes) {
|
||||||
|
assert(ws->type == CT_WORKSPACE);
|
||||||
|
y(map_open);
|
||||||
|
|
||||||
TAILQ_FOREACH(ws, workspaces, workspaces) {
|
ystr("num");
|
||||||
if (ws->output == NULL)
|
y(integer, con_num_children(ws));
|
||||||
continue;
|
|
||||||
|
|
||||||
y(map_open);
|
ystr("name");
|
||||||
ystr("num");
|
ystr(ws->name);
|
||||||
y(integer, ws->num + 1);
|
|
||||||
|
|
||||||
ystr("name");
|
ystr("visible");
|
||||||
ystr(ws->utf8_name);
|
y(bool, workspace_is_visible(ws));
|
||||||
|
|
||||||
ystr("visible");
|
ystr("focused");
|
||||||
y(bool, ws->output->current_workspace == ws);
|
y(bool, ws == focused_ws);
|
||||||
|
|
||||||
ystr("focused");
|
ystr("rect");
|
||||||
y(bool, c_ws == ws);
|
y(map_open);
|
||||||
|
ystr("x");
|
||||||
|
y(integer, ws->rect.x);
|
||||||
|
ystr("y");
|
||||||
|
y(integer, ws->rect.y);
|
||||||
|
ystr("width");
|
||||||
|
y(integer, ws->rect.width);
|
||||||
|
ystr("height");
|
||||||
|
y(integer, ws->rect.height);
|
||||||
|
y(map_close);
|
||||||
|
|
||||||
ystr("rect");
|
ystr("output");
|
||||||
y(map_open);
|
ystr(output->name);
|
||||||
ystr("x");
|
|
||||||
y(integer, ws->rect.x);
|
|
||||||
ystr("y");
|
|
||||||
y(integer, ws->rect.y);
|
|
||||||
ystr("width");
|
|
||||||
y(integer, ws->rect.width);
|
|
||||||
ystr("height");
|
|
||||||
y(integer, ws->rect.height);
|
|
||||||
y(map_close);
|
|
||||||
|
|
||||||
ystr("output");
|
ystr("urgent");
|
||||||
ystr(ws->output->name);
|
y(bool, ws->urgent);
|
||||||
|
|
||||||
ystr("urgent");
|
y(map_close);
|
||||||
y(bool, ws->urgent);
|
|
||||||
|
|
||||||
y(map_close);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
y(array_close);
|
y(array_close);
|
||||||
|
|
||||||
const unsigned char *payload;
|
const unsigned char *payload;
|
||||||
unsigned int length;
|
unsigned int length;
|
||||||
y(get_buf, &payload, &length);
|
y(get_buf, &payload, &length);
|
||||||
|
|
||||||
ipc_send_message(fd, payload, I3_IPC_REPLY_TYPE_WORKSPACES, length);
|
ipc_send_message(fd, payload, I3_IPC_REPLY_TYPE_WORKSPACES, length);
|
||||||
y(free);
|
y(free);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -322,48 +319,50 @@ IPC_HANDLER(get_workspaces) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
IPC_HANDLER(get_outputs) {
|
IPC_HANDLER(get_outputs) {
|
||||||
Output *output;
|
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
||||||
|
y(array_open);
|
||||||
|
|
||||||
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
Output *output;
|
||||||
y(array_open);
|
TAILQ_FOREACH(output, &outputs, outputs) {
|
||||||
|
y(map_open);
|
||||||
|
|
||||||
TAILQ_FOREACH(output, &outputs, outputs) {
|
ystr("name");
|
||||||
y(map_open);
|
ystr(output->name);
|
||||||
|
|
||||||
ystr("name");
|
ystr("active");
|
||||||
ystr(output->name);
|
y(bool, output->active);
|
||||||
|
|
||||||
ystr("active");
|
ystr("rect");
|
||||||
y(bool, output->active);
|
y(map_open);
|
||||||
|
ystr("x");
|
||||||
|
y(integer, output->rect.x);
|
||||||
|
ystr("y");
|
||||||
|
y(integer, output->rect.y);
|
||||||
|
ystr("width");
|
||||||
|
y(integer, output->rect.width);
|
||||||
|
ystr("height");
|
||||||
|
y(integer, output->rect.height);
|
||||||
|
y(map_close);
|
||||||
|
|
||||||
ystr("rect");
|
/*
|
||||||
y(map_open);
|
* XXX
|
||||||
ystr("x");
|
* No idea how to handle this, where should we get this data from?
|
||||||
y(integer, output->rect.x);
|
* I think we might need to keep a reference to the CT_OUTPUT Con in Output
|
||||||
ystr("y");
|
*/
|
||||||
y(integer, output->rect.y);
|
ystr("current_workspace");
|
||||||
ystr("width");
|
y(null);
|
||||||
y(integer, output->rect.width);
|
|
||||||
ystr("height");
|
|
||||||
y(integer, output->rect.height);
|
|
||||||
y(map_close);
|
|
||||||
|
|
||||||
ystr("current_workspace");
|
y(map_close);
|
||||||
if (output->current_workspace == NULL)
|
}
|
||||||
y(null);
|
|
||||||
else y(integer, output->current_workspace->num + 1);
|
|
||||||
|
|
||||||
y(map_close);
|
y(array_close);
|
||||||
}
|
|
||||||
|
|
||||||
y(array_close);
|
const unsigned char *payload;
|
||||||
|
unsigned int length;
|
||||||
|
y(get_buf, &payload, &length);
|
||||||
|
|
||||||
const unsigned char *payload;
|
ipc_send_message(fd, payload, I3_IPC_REPLY_TYPE_OUTPUTS, length);
|
||||||
unsigned int length;
|
y(free);
|
||||||
y(get_buf, &payload, &length);
|
|
||||||
|
|
||||||
ipc_send_message(fd, payload, I3_IPC_REPLY_TYPE_OUTPUTS, length);
|
|
||||||
y(free);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -441,12 +440,14 @@ IPC_HANDLER(subscribe) {
|
|||||||
ipc_send_message(fd, (const unsigned char*)reply,
|
ipc_send_message(fd, (const unsigned char*)reply,
|
||||||
I3_IPC_REPLY_TYPE_SUBSCRIBE, strlen(reply));
|
I3_IPC_REPLY_TYPE_SUBSCRIBE, strlen(reply));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The index of each callback function corresponds to the numeric
|
/* The index of each callback function corresponds to the numeric
|
||||||
* value of the message type (see include/i3/ipc.h) */
|
* value of the message type (see include/i3/ipc.h) */
|
||||||
handler_t handlers[2] = {
|
handler_t handlers[5] = {
|
||||||
handle_command,
|
handle_command,
|
||||||
|
handle_get_workspaces,
|
||||||
|
handle_subscribe,
|
||||||
|
handle_get_outputs,
|
||||||
handle_tree
|
handle_tree
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user