Feature: implement GET_MARKS
This commit is contained in:
parent
e304902874
commit
35d7ef0ddd
13
docs/ipc
13
docs/ipc
|
@ -59,6 +59,9 @@ GET_TREE (4)::
|
|||
Gets the layout tree. i3 uses a tree as data structure which includes
|
||||
every container. The reply will be the JSON-encoded tree (see the reply
|
||||
section).
|
||||
GET_MARKS (5)::
|
||||
Gets a list of marks. The reply will be a JSON-encoded list of window marks
|
||||
(see reply section).
|
||||
|
||||
So, a typical message could look like this:
|
||||
--------------------------------------------------
|
||||
|
@ -110,6 +113,8 @@ GET_OUTPUTS (3)::
|
|||
Reply to the GET_OUTPUTS message.
|
||||
GET_TREE (4)::
|
||||
Reply to the GET_TREE message.
|
||||
GET_MARKS (5)::
|
||||
Reply to the GET_MARKS message.
|
||||
|
||||
=== COMMAND reply
|
||||
|
||||
|
@ -416,6 +421,14 @@ JSON dump:
|
|||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
=== GET_MARKS reply
|
||||
|
||||
The reply consists of a single array of strings for each
|
||||
window that has a mark.
|
||||
|
||||
If no window has a mark the response will be the empty array [].
|
||||
------------------------
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
/** Requests the tree layout from i3 */
|
||||
#define I3_IPC_MESSAGE_TYPE_GET_TREE 4
|
||||
|
||||
/** Request the current defined marks from i3 */
|
||||
#define I3_IPC_MESSAGE_TYPE_GET_MARKS 5
|
||||
|
||||
/*
|
||||
* Messages from i3 to clients
|
||||
|
@ -59,6 +61,8 @@
|
|||
/** Tree reply type */
|
||||
#define I3_IPC_REPLY_TYPE_TREE 4
|
||||
|
||||
/** Marks reply type*/
|
||||
#define I3_IPC_REPLY_TYPE_MARKS 5
|
||||
|
||||
/*
|
||||
* Events from i3 to clients. Events have the first bit set high.
|
||||
|
|
34
src/ipc.c
34
src/ipc.c
|
@ -330,6 +330,7 @@ IPC_HANDLER(tree) {
|
|||
y(free);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Formats the reply message for a GET_WORKSPACES request and sends it to the
|
||||
* client
|
||||
|
@ -460,6 +461,34 @@ IPC_HANDLER(get_outputs) {
|
|||
y(free);
|
||||
}
|
||||
|
||||
/*
|
||||
* Formats the reply message for a GET_MARKS request and sends it to the
|
||||
* client
|
||||
*
|
||||
*/
|
||||
IPC_HANDLER(get_marks) {
|
||||
#if YAJL_MAJOR >= 2
|
||||
yajl_gen gen = yajl_gen_alloc(NULL);
|
||||
#else
|
||||
yajl_gen gen = yajl_gen_alloc(NULL, NULL);
|
||||
#endif
|
||||
y(array_open);
|
||||
|
||||
Con *con;
|
||||
TAILQ_FOREACH(con, &all_cons, all_cons)
|
||||
if (con->mark != NULL)
|
||||
ystr(con->mark);
|
||||
|
||||
y(array_close);
|
||||
|
||||
const unsigned char *payload;
|
||||
unsigned int length;
|
||||
y(get_buf, &payload, &length);
|
||||
|
||||
ipc_send_message(fd, payload, I3_IPC_REPLY_TYPE_MARKS, length);
|
||||
y(free);
|
||||
}
|
||||
|
||||
/*
|
||||
* Callback for the YAJL parser (will be called when a string is parsed).
|
||||
*
|
||||
|
@ -547,12 +576,13 @@ 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[5] = {
|
||||
handler_t handlers[6] = {
|
||||
handle_command,
|
||||
handle_get_workspaces,
|
||||
handle_subscribe,
|
||||
handle_get_outputs,
|
||||
handle_tree
|
||||
handle_tree,
|
||||
handle_get_marks
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue