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,
57 if (!c->c->layers.empty()) {
59 for (auto const &i : c->c->layers) {
60 struct genivi::rect const &r = i.second->dst_rect;
61 struct genivi::size const &s = i.second->size;
62 printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h,
73 void init_layout(struct conn &c) {
74 auto &o = c.outputs.front();
75 auto &s = c.c->screens.begin()->second;
76 auto &layers = c.c->layers;
78 // XXX: Write output dimensions to ivi controller...
79 c.c->output_size = genivi::size{uint32_t(o->width), uint32_t(o->height)};
87 // Setup our dummy scene...
88 c.c->layer_create(100, 0, 0); // bottom layer, anything else
89 c.c->layer_create(1000, 0, 0); // top layer, mandelbrot
91 auto &l100 = c.c->layers[100];
92 auto &l1k = c.c->layers[1000];
94 // Set layers fullscreen
95 l100->set_destination_rectangle(0, 0, o->width, o->height);
96 l1k->set_destination_rectangle(0, 0, o->width, o->height);
98 // Add layers to screen
99 s->add_layer(l100.get());
100 s->add_layer(l1k.get());
102 c.c->commit_changes();
103 // Note: this does not flush the display!
107 int main(int argc, char **argv) {
108 lognotice("WinMan ver. %s", WINMAN_VERSION_STRING);
110 if (!getenv("XDG_RUNTIME_DIR"))
111 fatal("Environment variable XDG_RUNTIME_DIR not set");
113 auto d = std::make_unique<wl::display>();
115 fatal("Could not connect to compositor");
119 d->r->add_global_handler(
120 "ivi_controller", [&](wl_registry *r, uint32_t name, uint32_t v) {
121 c.c = std::make_unique<genivi::controller>(r, name, v);
124 d->r->add_global_handler(
125 "wl_output", [&](wl_registry *r, uint32_t name, uint32_t v) {
126 c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
129 // First level objects
131 // Second level objects
133 // Third level objects
137 fatal("ivi_controller global not available");
139 if (c.outputs.empty())
140 fatal("no output was set up!");
144 while (check_events(d.get(), &c, STDIN_FILENO) != -1) {
145 c.c->execute_pending();