17 std::vector<std::unique_ptr<wl::output>> outputs;
18 std::unique_ptr<genivi::controller> c;
22 int check_events(struct wl::display *d, struct conn *c, int fd)
24 struct pollfd pfd[2] = {
25 { .fd = d->get_fd(), .events = POLLIN, .revents = 0 },
26 { .fd = fd, .events = POLLIN, .revents = 0 }
31 if (poll(pfd, fd != -1 ? 2 : 1, -1) != -1 && errno != EINTR) {
34 if (pfd[0].revents & POLLIN) {
41 if (fd != -1 && (pfd[1].revents & POLLIN)) {
44 while (read(pfd[1].fd, buf, 10) == 10)
47 // Display current status
48 for (auto const &i : c->c->surfaces) {
49 printf("Surface %d\n", i.first);
58 int main(int argc, char **argv) {
59 lognotice("WinMan ver. %s", WINMAN_VERSION_STRING);
61 if (!getenv("XDG_RUNTIME_DIR"))
62 fatal("Environment variable XDG_RUNTIME_DIR not set");
64 auto d = std::make_unique<wl::display>();
66 fatal("Could not connect to compositor");
70 d->r->add_global_handler(
71 "ivi_controller", [&](wl_registry *r, uint32_t name, uint32_t v) {
72 c.c = std::make_unique<genivi::controller>(r, name, v);
75 d->r->add_global_handler(
76 "wl_output", [&](wl_registry *r, uint32_t name, uint32_t v) {
77 c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
80 // First level objects
82 // Second level objects
84 // Third level objects
88 fatal("ivi_controller global not available");
90 while (check_events(d.get(), &c, STDIN_FILENO) != -1) {