summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 7734d97..52d6b32 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,7 +5,7 @@
#include <sys/poll.h>
-struct conn {
+struct connection {
std::vector<std::unique_ptr<wl::output>> outputs;
std::unique_ptr<genivi::controller> c;
};
@@ -17,7 +17,7 @@ namespace {
// | (__| | | | __/ (__| < | __/\ 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}};
@@ -76,7 +76,15 @@ int check_events(struct wl::display &d, struct conn &c, int fd) {
// | | | | | | |_ | | (_| | |_| | (_) | |_| | |_| | | |
// |_|_| |_|_|\__|___|_|\__,_|\__, |\___/ \__,_|\__| | | |
// |_____| |___/ \_\/_/
-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;
@@ -108,6 +116,8 @@ void init_layout(struct conn &c) {
c.c->commit_changes();
// Note: this does not flush the display!
+
+ return nullptr;
}
} // namespace
@@ -129,7 +139,7 @@ int main(int /*argc*/, char ** /*argv*/) {
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) {
@@ -148,22 +158,14 @@ int main(int /*argc*/, char ** /*argv*/) {
// 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;
}