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) {
23 struct pollfd pfd[2] = {{.fd = d->get_fd(), .events = POLLIN, .revents = 0},
24 {.fd = fd, .events = POLLIN, .revents = 0}};
28 if (poll(pfd, fd != -1 ? 2 : 1, -1) != -1 && errno != EINTR) {
31 if (pfd[0].revents & POLLIN) {
38 if (fd != -1 && (pfd[1].revents & POLLIN)) {
41 // read all there is ...
42 while (read(pfd[1].fd, buf, sizeof(buf)) == sizeof(buf))
45 // Display current status
46 if (!c->c->surfaces.empty()) {
48 for (auto const &i : c->c->surfaces) {
49 struct genivi::rect const &r = i.second->dst_rect;
50 struct genivi::size const &s = i.second->size;
51 printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h,
62 void init_layout(struct conn &c) {
63 struct wl::output &o = *c.outputs.begin()->get();
64 struct genivi::screen &s = *c.c->screens.begin()->second;
65 auto &layers = c.c->layers;
67 // Setup our dummy scene...
68 if (layers.find(100) == layers.end()) {
69 logdebug("Creating layer 100 with output dimensions (%ux%u)", o.width, o.height);
70 c.c->layer_create(100, o.width, o.height);
73 struct genivi::layer &l = *c.c->layers[100].get();
75 l.set_destination_rectangle(0, 0, o.width, o.height);
78 logdebug("Add layer 100 to screen %u", s.id);
81 c.c->commit_changes();
82 // Note: this does not flush the display!
86 int main(int argc, char **argv) {
87 lognotice("WinMan ver. %s", WINMAN_VERSION_STRING);
89 if (!getenv("XDG_RUNTIME_DIR"))
90 fatal("Environment variable XDG_RUNTIME_DIR not set");
92 auto d = std::make_unique<wl::display>();
94 fatal("Could not connect to compositor");
98 d->r->add_global_handler(
99 "ivi_controller", [&](wl_registry *r, uint32_t name, uint32_t v) {
100 c.c = std::make_unique<genivi::controller>(r, name, v);
103 d->r->add_global_handler(
104 "wl_output", [&](wl_registry *r, uint32_t name, uint32_t v) {
105 c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
108 // First level objects
110 // Second level objects
112 // Third level objects
116 fatal("ivi_controller global not available");
118 if (c.outputs.empty())
119 fatal("no output was set up!");
123 while (check_events(d.get(), &c, STDIN_FILENO) != -1) {
124 c.c->execute_pending();