gri3-wm/i3bar/src/main.c

68 lines
1.5 KiB
C
Raw Normal View History

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