#include <sys/poll.h>
-struct conn {
+struct connection {
std::vector<std::unique_ptr<wl::output>> outputs;
std::unique_ptr<genivi::controller> c;
};
// | (__| | | | __/ (__| < | __/\ V / __/ | | | |_\__ \ | | |
// \___|_| |_|\___|\___|_|\_\___\___| \_/ \___|_| |_|\__|___/ | | |
// |_____| \_\/_/
-int check_events(struct wl::display &d, struct conn &c, int fd) {
+int check_events(struct wl::display &d, struct connection &c, int fd) {
struct pollfd pfd[2] = {{.fd = d.get_fd(), .events = POLLIN, .revents = 0},
{.fd = fd, .events = POLLIN, .revents = 0}};
// | | | | | | |_ | | (_| | |_| | (_) | |_| | |_| | | |
// |_|_| |_|_|\__|___|_|\__,_|\__, |\___/ \__,_|\__| | | |
// |_____| |___/ \_\/_/
-void init_layout(struct conn &c) {
+char const *init_layout(struct connection &c) {
+ if (!c.c) {
+ return "ivi_controller global not available";
+ }
+
+ if (c.outputs.empty()) {
+ return "no output was set up!";
+ }
+
auto &o = c.outputs.front();
auto &s = c.c->screens.begin()->second;
auto &layers = c.c->layers;
c.c->commit_changes();
// Note: this does not flush the display!
+
+ return nullptr;
}
} // namespace
fatal("Could not connect to compositor");
}
- struct conn c {};
+ struct connection c {};
d.r.add_global_handler(
"ivi_controller", [&c](wl_registry *r, uint32_t name, uint32_t v) {
// Third level objects
d.roundtrip();
- if (!c.c) {
- fatal("ivi_controller global not available");
- }
-
- if (c.outputs.empty()) {
- fatal("no output was set up!");
+ if (char const *e = init_layout(c)) {
+ fatal("Could not init layout: %s", e);
}
- init_layout(c);
-
while (check_events(d, c, STDIN_FILENO) != -1) {
c.c->execute_pending();
d.flush();
}
- d.roundtrip();
-
return 0;
}