9 std::vector<std::unique_ptr<wl::output>> outputs;
10 std::unique_ptr<genivi::controller> c;
15 // ___| |__ ___ ___| | __ _____ _____ _ __ | |_ ___ / /\ \
16 // / __| '_ \ / _ \/ __| |/ / / _ \ \ / / _ \ '_ \| __/ __| | | |
17 // | (__| | | | __/ (__| < | __/\ V / __/ | | | |_\__ \ | | |
18 // \___|_| |_|\___|\___|_|\_\___\___| \_/ \___|_| |_|\__|___/ | | |
20 int check_events(struct wl::display &d, struct conn &c, int fd) {
21 struct pollfd pfd[2] = {{.fd = d.get_fd(), .events = POLLIN, .revents = 0},
22 {.fd = fd, .events = POLLIN, .revents = 0}};
26 if (poll(pfd, fd != -1 ? 2 : 1, -1) != -1 && errno != EINTR) {
29 if ((pfd[0].revents & POLLIN) != 0) {
37 if (fd != -1 && ((pfd[1].revents & POLLIN) != 0)) {
40 // read all there is ...
41 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 auto const &r = i.second->dst_rect;
50 auto 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 auto const &r = i.second->dst_rect;
61 auto const &s = i.second->size;
62 printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h,
74 // (_)_ __ (_) |_ | | __ _ _ _ ___ _ _| |_ / /\ \
75 // | | '_ \| | __| | |/ _` | | | |/ _ \| | | | __| | | |
76 // | | | | | | |_ | | (_| | |_| | (_) | |_| | |_| | | |
77 // |_|_| |_|_|\__|___|_|\__,_|\__, |\___/ \__,_|\__| | | |
78 // |_____| |___/ \_\/_/
79 void init_layout(struct conn &c) {
80 auto &o = c.outputs.front();
81 auto &s = c.c->screens.begin()->second;
82 auto &layers = c.c->layers;
84 // XXX: Write output dimensions to ivi controller...
85 c.c->output_size = genivi::size{uint32_t(o->width), uint32_t(o->height)};
93 // Setup our dummy scene...
94 c.c->layer_create(100, 0, 0); // bottom layer, anything else
95 c.c->layer_create(1000, 0, 0); // top layer, mandelbrot
97 auto &l100 = c.c->layers[100];
98 auto &l1k = c.c->layers[1000];
100 // Set layers fullscreen
101 l100->set_destination_rectangle(0, 0, o->width, o->height);
102 l1k->set_destination_rectangle(0, 0, o->width, o->height);
103 l100->set_visibility(1);
104 l1k->set_visibility(1);
106 // Add layers to screen
107 s->set_render_order({100, 1000});
109 c.c->commit_changes();
110 // Note: this does not flush the display!
115 // _ __ ___ __ _(_)_ __ / /\ \
116 // | '_ ` _ \ / _` | | '_ \| | | |
117 // | | | | | | (_| | | | | | | | |
118 // |_| |_| |_|\__,_|_|_| |_| | | |
120 int main(int /*argc*/, char ** /*argv*/) {
121 lognotice("WinMan ver. %s", WINMAN_VERSION_STRING);
123 if (getenv("XDG_RUNTIME_DIR") == nullptr) {
124 fatal("Environment variable XDG_RUNTIME_DIR not set");
127 struct wl::display d {};
129 fatal("Could not connect to compositor");
134 d.r.add_global_handler(
135 "ivi_controller", [&c](wl_registry *r, uint32_t name, uint32_t v) {
136 c.c = std::make_unique<genivi::controller>(r, name, v);
139 d.r.add_global_handler(
140 "wl_output", [&c](wl_registry *r, uint32_t name, uint32_t v) {
141 c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
144 // First level objects
146 // Second level objects
148 // Third level objects
152 fatal("ivi_controller global not available");
155 if (c.outputs.empty()) {
156 fatal("no output was set up!");
161 while (check_events(d, c, STDIN_FILENO) != -1) {
162 c.c->execute_pending();