11 #include "workspaces.h"
15 void ev_prepare_cb(struct ev_loop *loop, ev_prepare *w, int revents) {
16 xcb_flush(xcb_connection);
19 void ev_check_cb(struct ev_loop *loop, ev_check *w, int revents) {
20 xcb_generic_event_t *event;
21 if ((event = xcb_poll_for_event(xcb_connection)) != NULL) {
22 switch (event->response_type & ~0x80) {
30 void xcb_io_cb(struct ev_loop *loop, ev_io *w, int revents) {
33 int main(int argc, char **argv) {
34 main_loop = ev_default_loop(0);
37 init_connection("/home/mero/.i3/ipc.sock");
41 ev_io *xcb_io = malloc(sizeof(ev_io));
42 ev_prepare *ev_prep = malloc(sizeof(ev_prepare));
43 ev_check *ev_chk = malloc(sizeof(ev_check));
45 ev_io_init(xcb_io, &xcb_io_cb, xcb_get_file_descriptor(xcb_connection), EV_READ);
46 ev_prepare_init(ev_prep, &ev_prepare_cb);
47 ev_check_init(ev_chk, &ev_check_cb);
49 ev_io_start(main_loop, xcb_io);
50 ev_prepare_start(main_loop, ev_prep);
51 ev_check_start(main_loop, ev_chk);
53 i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
54 i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
56 ev_loop(main_loop, 0);
58 ev_prepare_stop(main_loop, ev_prep);
59 ev_check_stop(main_loop, ev_chk);