Add a new IPC event for changes on windows.
Added new event id (I3_IPC_EVENT_WINDOW) so that a an IPC client can subscribe to events on windows. Added a basic window event that gets triggered when a window gets successfully reparented. This new event also dumps the container data, so that IPC clients can get the initial window name. IPC clients wishing to see window events should subscribe to 'window'.
This commit is contained in:
committed by
Michael Stapelberg
parent
e215fd43c0
commit
3facbbca5c
35
src/manage.c
35
src/manage.c
@ -10,6 +10,9 @@
|
||||
*
|
||||
*/
|
||||
#include "all.h"
|
||||
#include "yajl_utils.h"
|
||||
|
||||
#include <yajl/yajl_gen.h>
|
||||
|
||||
/*
|
||||
* Go through all existing windows (if the window manager is restarted) and manage them
|
||||
@ -72,6 +75,35 @@ void restore_geometry(void) {
|
||||
xcb_aux_sync(conn);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following function sends a new window event, which consists
|
||||
* of fields "change" and "container", the latter containing a dump
|
||||
* of the window's container.
|
||||
*
|
||||
*/
|
||||
static void ipc_send_window_new_event(Con *con) {
|
||||
setlocale(LC_NUMERIC, "C");
|
||||
yajl_gen gen = ygenalloc();
|
||||
|
||||
y(map_open);
|
||||
|
||||
ystr("change");
|
||||
ystr("new");
|
||||
|
||||
ystr("container");
|
||||
dump_node(gen, con, false);
|
||||
|
||||
y(map_close);
|
||||
|
||||
const unsigned char *payload;
|
||||
ylength length;
|
||||
y(get_buf, &payload, &length);
|
||||
|
||||
ipc_send_event("window", I3_IPC_EVENT_WINDOW, (const char *)payload);
|
||||
y(free);
|
||||
setlocale(LC_NUMERIC, "");
|
||||
}
|
||||
|
||||
/*
|
||||
* Do some sanity checks and then reparent the window.
|
||||
*
|
||||
@ -428,6 +460,9 @@ void manage_window(xcb_window_t window, xcb_get_window_attributes_cookie_t cooki
|
||||
}
|
||||
tree_render();
|
||||
|
||||
/* Send an event about window creation */
|
||||
ipc_send_window_new_event(nc);
|
||||
|
||||
geom_out:
|
||||
free(geom);
|
||||
out:
|
||||
|
Reference in New Issue
Block a user