-struct ivi_layer {
- ivi_controller_layer *controller;
- uint32_t id;
- conn *con;
- ivi_layer(ivi_controller_layer *c, uint32_t i, conn *co)
- : controller(c), id(i), con(co) {}
- ~ivi_layer() { ivi_controller_layer_destroy(this->controller, 1); }
-};
+namespace {
+// _ _ _ ____
+// ___| |__ ___ ___| | __ _____ _____ _ __ | |_ ___ / /\ \
+// / __| '_ \ / _ \/ __| |/ / / _ \ \ / / _ \ '_ \| __/ __| | | |
+// | (__| | | | __/ (__| < | __/\ V / __/ | | | |_\__ \ | | |
+// \___|_| |_|\___|\___|_|\_\___\___| \_/ \___|_| |_|\__|___/ | | |
+// |_____| \_\/_/
+int check_events(struct wl::display &d, struct conn &c, int fd) {
+ struct pollfd pfd[2] = {{.fd = d.get_fd(), .events = POLLIN, .revents = 0},
+ {.fd = fd, .events = POLLIN, .revents = 0}};
+
+ d.flush();
+
+ if (poll(pfd, fd != -1 ? 2 : 1, -1) != -1 && errno != EINTR) {
+ int ret = 0;
+
+ if ((pfd[0].revents & POLLIN) != 0) {
+ ret = d.dispatch();
+ }
+
+ if (ret == -1) {
+ return ret;
+ }
+
+ if (fd != -1 && ((pfd[1].revents & POLLIN) != 0)) {
+ char buf[256];
+
+ // read all there is ...
+ while (read(pfd[1].fd, buf, sizeof(buf)) == sizeof(buf)) {
+ ;
+ }
+
+ // Display current status
+ if (!c.c->surfaces.empty()) {
+ puts("Surfaces:");
+ for (auto const &i : c.c->surfaces) {
+ auto const &r = i.second->dst_rect;
+ auto const &s = i.second->size;
+ printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h,
+ r.x, r.y);
+ }
+ puts("\b\b ");
+ }
+
+ if (!c.c->layers.empty()) {
+ puts("Layers:");
+ for (auto const &i : c.c->layers) {
+ auto const &r = i.second->dst_rect;
+ auto const &s = i.second->size;
+ printf("%d [%ux%u] (%ux%u@%dx%d), ", i.first, s.w, s.h, r.w, r.h,
+ r.x, r.y);
+ }
+ puts("\b\b ");
+ }
+ }
+ }