+int wayland::init() {
+ if (!this->display->ok()) {
+ return -1;
+ }
+
+ this->display->r.add_global_handler("wl_output", [](wl_registry *r,
+ uint32_t name,
+ uint32_t v) {
+ g_wayland->outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
+ });
+
+ this->display->r.add_global_handler(
+ "ivi_controller", [](wl_registry *r, uint32_t name, uint32_t v) {
+ g_wayland->controller =
+ std::make_unique<genivi::controller>(r, name, v);
+
+ // XXX: This protocol needs the output, so lets just add our mapping
+ // here...
+ g_wayland->controller->add_proxy_to_id_mapping(
+ g_wayland->outputs.back()->proxy.get(),
+ wl_proxy_get_id(reinterpret_cast<struct wl_proxy *>(
+ g_wayland->outputs.back()->proxy.get())));
+ });
+
+ // First level objects
+ this->display->roundtrip();
+ // Second level objects
+ this->display->roundtrip();
+ // Third level objects
+ this->display->roundtrip();
+
+ return 0;
+}
+