From 44a7f1838f0e85a1a9cf5c7fa6aec67a8a60daeb Mon Sep 17 00:00:00 2001 From: Marcus Fritzsch Date: Thu, 22 Jun 2017 16:23:35 +0200 Subject: main: execute controllers pending tasks, clang-format Signed-off-by: Marcus Fritzsch --- src/main.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index a07a73c..cd8d67d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -19,12 +19,9 @@ struct conn { }; namespace { -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 } - }; +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(); @@ -39,14 +36,22 @@ int check_events(struct wl::display *d, struct conn *c, int fd) return ret; if (fd != -1 && (pfd[1].revents & POLLIN)) { - char buf[10]; + char buf[256]; - while (read(pfd[1].fd, buf, 10) == 10) + // read all there is ... + while (read(pfd[1].fd, buf, sizeof(buf)) == sizeof(buf)) ; // Display current status - for (auto const &i : c->c->surfaces) { - printf("Surface %d\n", i.first); + if (!c->c->surfaces.empty()) { + puts("Surfaces:"); + for (auto const &i : c->c->surfaces) { + struct genivi::rect const &r = i.second->dst_rect; + struct genivi::size 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 "); } } } @@ -88,7 +93,7 @@ int main(int argc, char **argv) { fatal("ivi_controller global not available"); while (check_events(d.get(), &c, STDIN_FILENO) != -1) { - ; + c.c->execute_pending(); } d->roundtrip(); -- cgit 1.2.3-korg