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 handle_xcb_event(event);
27 void xcb_io_cb(struct ev_loop *loop, ev_io *w, int revents) {
30 int main(int argc, char **argv) {
31 main_loop = ev_default_loop(0);
34 init_connection("/home/mero/.i3/ipc.sock");
38 ev_io *xcb_io = malloc(sizeof(ev_io));
39 ev_prepare *ev_prep = malloc(sizeof(ev_prepare));
40 ev_check *ev_chk = malloc(sizeof(ev_check));
42 ev_io_init(xcb_io, &xcb_io_cb, xcb_get_file_descriptor(xcb_connection), EV_READ);
43 ev_prepare_init(ev_prep, &ev_prepare_cb);
44 ev_check_init(ev_chk, &ev_check_cb);
46 ev_io_start(main_loop, xcb_io);
47 ev_prepare_start(main_loop, ev_prep);
48 ev_check_start(main_loop, ev_chk);
50 i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
51 i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
53 ev_loop(main_loop, 0);
55 ev_prepare_stop(main_loop, ev_prep);
56 ev_check_stop(main_loop, ev_chk);
64 FREE_SLIST(outputs, i3_output);