2010-07-22 22:43:43 -04:00
|
|
|
#include <stdio.h>
|
2010-07-22 23:04:13 -04:00
|
|
|
#include <i3/ipc.h>
|
2010-07-22 22:43:43 -04:00
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2010-07-26 17:51:51 -04:00
|
|
|
#include <stdlib.h>
|
2010-07-22 22:43:43 -04:00
|
|
|
#include <ev.h>
|
2010-07-26 17:51:51 -04:00
|
|
|
#include <xcb/xcb.h>
|
2010-07-22 22:43:43 -04:00
|
|
|
|
2010-07-21 19:15:18 -04:00
|
|
|
#include "ipc.h"
|
|
|
|
#include "outputs.h"
|
|
|
|
#include "workspaces.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "xcb.h"
|
|
|
|
|
2010-07-26 17:51:51 -04:00
|
|
|
void ev_prepare_cb(struct ev_loop *loop, ev_prepare *w, int revents) {
|
2010-08-03 15:20:11 -04:00
|
|
|
xcb_flush(xcb_connection);
|
2010-07-26 17:51:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void ev_check_cb(struct ev_loop *loop, ev_check *w, int revents) {
|
2010-08-03 15:20:11 -04:00
|
|
|
xcb_generic_event_t *event;
|
|
|
|
if ((event = xcb_poll_for_event(xcb_connection)) != NULL) {
|
|
|
|
handle_xcb_event(event);
|
|
|
|
}
|
|
|
|
free(event);
|
2010-07-26 17:51:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void xcb_io_cb(struct ev_loop *loop, ev_io *w, int revents) {
|
|
|
|
}
|
|
|
|
|
2010-07-21 19:15:18 -04:00
|
|
|
int main(int argc, char **argv) {
|
2010-08-03 15:20:11 -04:00
|
|
|
main_loop = ev_default_loop(0);
|
2010-07-21 19:15:18 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
init_xcb();
|
|
|
|
init_connection("/home/mero/.i3/ipc.sock");
|
2010-07-21 19:15:18 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
subscribe_events();
|
2010-07-21 19:15:18 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
ev_io *xcb_io = malloc(sizeof(ev_io));
|
|
|
|
ev_prepare *ev_prep = malloc(sizeof(ev_prepare));
|
|
|
|
ev_check *ev_chk = malloc(sizeof(ev_check));
|
2010-07-26 17:51:51 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
ev_io_init(xcb_io, &xcb_io_cb, xcb_get_file_descriptor(xcb_connection), EV_READ);
|
|
|
|
ev_prepare_init(ev_prep, &ev_prepare_cb);
|
|
|
|
ev_check_init(ev_chk, &ev_check_cb);
|
2010-07-26 17:51:51 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
ev_io_start(main_loop, xcb_io);
|
|
|
|
ev_prepare_start(main_loop, ev_prep);
|
|
|
|
ev_check_start(main_loop, ev_chk);
|
2010-07-26 17:51:51 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_OUTPUTS, NULL);
|
|
|
|
i3_send_msg(I3_IPC_MESSAGE_TYPE_GET_WORKSPACES, NULL);
|
2010-07-22 23:04:13 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
ev_loop(main_loop, 0);
|
2010-07-21 19:15:18 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
ev_prepare_stop(main_loop, ev_prep);
|
|
|
|
ev_check_stop(main_loop, ev_chk);
|
|
|
|
FREE(ev_prep);
|
|
|
|
FREE(ev_chk);
|
2010-07-26 17:51:51 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
ev_default_destroy();
|
|
|
|
clean_xcb();
|
2010-07-29 21:11:54 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
free_workspaces();
|
|
|
|
FREE_SLIST(outputs, i3_output);
|
2010-07-21 19:15:18 -04:00
|
|
|
|
2010-08-03 15:20:11 -04:00
|
|
|
return 0;
|
2010-07-21 19:15:18 -04:00
|
|
|
}
|