summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/main.cpp153
-rw-r--r--src/util.c9
-rw-r--r--src/util.h6
-rw-r--r--src/wayland.cpp242
-rw-r--r--src/wayland.hpp212
6 files changed, 489 insertions, 135 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 86e7ecd..b11d397 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,6 +3,8 @@ wlproto(IVI_CON ivi-controller)
add_executable(winman
main.cpp
+ wayland.cpp
+ wayland.hpp
util.c
util.h
${IVI_APP_PROTO}
diff --git a/src/main.cpp b/src/main.cpp
index 794d9af..0c010ea 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,171 +1,54 @@
#include "util.h"
-
-#include "ivi-controller-client-protocol.h"
+#include "wayland.hpp"
#include <stdlib.h>
#include <string.h>
-#include <wayland-client.h>
-
#include <map>
#include <memory>
#include <string>
#include <vector>
-struct ivi_surface;
-struct ivi_layer;
-
struct conn {
- wl_display *d;
- wl_registry *r;
- ivi_controller *c;
- std::vector<std::unique_ptr<wl_output, void (*)(wl_output *)>> outputs;
- std::map<uint32_t, std::unique_ptr<ivi_layer>> layers;
- std::map<uint32_t, std::unique_ptr<ivi_surface>> surfaces;
+ std::vector<std::unique_ptr<wl::output>> outputs;
+ std::unique_ptr<genivi::controller> c;
~conn();
};
-struct ivi_surface {
- ivi_controller_surface *controller;
- uint32_t id;
- conn *con;
- ivi_surface(ivi_controller_surface *c, uint32_t i, conn *co)
- : controller(c), id(i), con(co) {}
- ~ivi_surface() { ivi_controller_surface_destroy(this->controller, 1); }
-};
-
-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); }
-};
-
conn::~conn() {
- this->layers.clear();
- this->surfaces.clear();
- ivi_controller_destroy(this->c);
this->outputs.clear();
- wl_registry_destroy(this->r);
- wl_display_disconnect(this->d);
}
-static ivi_controller_surface_listener cs_listener = {};
-
-static ivi_controller_layer_listener cl_listener = {};
-
-static void c_screen(void *data, struct ivi_controller *ivi_controller,
- uint32_t id_screen, struct ivi_controller_screen *screen) {
- lognotice("ivi_controller @ %p screen %u (%x) @ %p", ivi_controller,
- id_screen, id_screen, screen);
-}
-
-static void c_layer(void *data, struct ivi_controller *ivi_controller,
- uint32_t id_layer) {
- lognotice("ivi_controller @ %p layer %u (%x)", ivi_controller, id_layer,
- id_layer);
- auto c = static_cast<conn *>(data);
- auto i = std::make_unique<ivi_layer>(
- ivi_controller_layer_create(c->c, id_layer, 0, 0), id_layer, c);
- ivi_controller_layer_add_listener(i->controller, &cl_listener, i.get());
- c->layers[id_layer] = std::move(i);
-}
-
-static void c_surface(void *data, struct ivi_controller *ivi_controller,
- uint32_t id_surface) {
- lognotice("ivi_controller @ %p surface %u (%x)", ivi_controller, id_surface,
- id_surface);
- auto c = static_cast<conn *>(data);
- auto i = std::make_unique<ivi_surface>(
- ivi_controller_surface_create(c->c, id_surface), id_surface, c);
- ivi_controller_surface_add_listener(i->controller, &cs_listener, i.get());
- c->surfaces[id_surface] = std::move(i);
-}
-
-static void c_error(void *data, struct ivi_controller *ivi_controller,
- int32_t object_id, int32_t object_type, int32_t error_code,
- const char *error_text) {
- lognotice("ivi_controller @ %p error o %i t %i c %i text %s", ivi_controller,
- object_id, object_type, error_code, error_text);
-}
-
-static struct ivi_controller_listener c_listener = {c_screen, c_layer,
- c_surface, c_error};
-
-static void o_geometry(void *data, struct wl_output *wl_output, int32_t x,
- int32_t y, int32_t physical_width,
- int32_t physical_height, int32_t subpixel,
- const char *make, const char *model, int32_t transform) {
- lognotice("output @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
- wl_output, x, y, physical_width, physical_height, subpixel, make,
- model, transform);
-}
-
-static void o_mode(void *data, struct wl_output *wl_output, uint32_t flags,
- int32_t width, int32_t height, int32_t refresh) {
- lognotice("output @ %p mode f %x w %i h %i r %i", wl_output, flags, width,
- height, refresh);
-}
-
-static void o_done(void *data, struct wl_output *wl_output) {
- lognotice("output @ %p done");
-}
-
-static void o_scale(void *data, struct wl_output *wl_output, int32_t factor) {
- lognotice("output @ %p scale %i", wl_output, factor);
-}
-
-static struct wl_output_listener o_listener = {o_geometry, o_mode, o_done,
- o_scale};
-
-static void r_global(void *data, struct wl_registry *r, uint32_t name,
- char const *iface, uint32_t v) {
- struct conn *c = static_cast<conn *>(data);
-
- if (strcmp(iface, "ivi_controller") == 0) {
- c->c = static_cast<ivi_controller *>(
- wl_registry_bind(r, name, &ivi_controller_interface, v));
- ivi_controller_add_listener(c->c, &c_listener, c);
- } else if (strcmp(iface, "wl_output") == 0) {
- auto o = static_cast<wl_output *>(
- wl_registry_bind(r, name, &wl_output_interface, v));
- c->outputs.emplace_back(std::unique_ptr<wl_output, void (*)(wl_output *)>(
- o, wl_output_destroy));
- wl_output_add_listener(o, &o_listener, c);
- } else {
- lognotice("registry @ %p global n %u i %s v %u", r, name, iface, v);
- }
-}
-
-static void r_global_remove(void *data, struct wl_registry *r, uint32_t name) {}
-
-static struct wl_registry_listener r_listener = {r_global, r_global_remove};
-
int main(int argc, char **argv) {
lognotice("WinMan ver. %s", WINMAN_VERSION_STRING);
if (!getenv("XDG_RUNTIME_DIR"))
fatal("Environment variable XDG_RUNTIME_DIR not set");
+ auto d = std::make_unique<wl::display>();
+ if (!d->d)
+ fatal("Could not connect to compositor");
+
struct conn c = {};
- c.d = wl_display_connect(NULL);
- if (!c.d)
- fatal("Could not connect to compositor");
- c.r = wl_display_get_registry(c.d);
- wl_registry_add_listener(c.r, &r_listener, &c);
+ d->r->add_global_handler("ivi_controller", [&](wl_registry *r, uint32_t name, uint32_t v) {
+ c.c = std::make_unique<genivi::controller>(r, name, v);
+ });
+
+ d->r->add_global_handler("wl_output", [&](wl_registry *r, uint32_t name, uint32_t v) {
+ c.outputs.emplace_back(std::make_unique<wl::output>(r, name, v));
+ });
// First level objects
- wl_display_roundtrip(c.d);
+ d->roundtrip();
// Second level objects
- wl_display_roundtrip(c.d);
+ d->roundtrip();
+ // Third level objects
+ /* wl_display_roundtrip(c.d); */
if (!c.c)
fatal("ivi_controller global not available");
-
// main loop
return 0;
diff --git a/src/util.c b/src/util.c
index ee4b7b6..0ce7c27 100644
--- a/src/util.c
+++ b/src/util.c
@@ -53,3 +53,12 @@ void fatal(char const *fmt, ...) {
va_end(a);
abort();
}
+
+#ifdef DEBUG_OUTPUT
+void logdebug(char const *fmt, ...) {
+ va_list a;
+ va_start(a, fmt);
+ log_("debug", stdout, fmt, a);
+ va_end(a);
+}
+#endif
diff --git a/src/util.h b/src/util.h
index 27d1015..600c638 100644
--- a/src/util.h
+++ b/src/util.h
@@ -9,6 +9,12 @@ void lognotice(char const *fmt, ...);
void logerror(char const *fmt, ...);
void fatal(char const *fmt, ...);
+#ifdef DEBUG_OUTPUT
+void logdebug(char const *fmt, ...);
+#else
+inline void logdebug(char const *fmt, ...) {}
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/wayland.cpp b/src/wayland.cpp
new file mode 100644
index 0000000..c88b5c6
--- /dev/null
+++ b/src/wayland.cpp
@@ -0,0 +1,242 @@
+#include "wayland.hpp"
+
+// _
+// _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
+// | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
+// | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
+// |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
+// |_|
+namespace wl {
+
+// _ _ _
+// __| (_)___ _ __ | | __ _ _ _
+// / _` | / __| '_ \| |/ _` | | | |
+// | (_| | \__ \ |_) | | (_| | |_| |
+// \__,_|_|___/ .__/|_|\__,_|\__, |
+// |_| |___/
+display::display()
+ : d(std::unique_ptr<wl_display, void (*)(wl_display *)>(
+ wl_display_connect(NULL), wl_display_disconnect)),
+ r(std::make_unique<registry>(d.get())) {}
+
+void display::roundtrip() { wl_display_roundtrip(this->d.get()); }
+
+// _ _
+// _ __ ___ __ _(_)___| |_ _ __ _ _
+// | '__/ _ \/ _` | / __| __| '__| | | |
+// | | | __/ (_| | \__ \ |_| | | |_| |
+// |_| \___|\__, |_|___/\__|_| \__, |
+// |___/ |___/
+registry::registry(wl_display *d) : wayland_proxy(wl_display_get_registry(d)) {
+ wl_registry_add_listener(this->proxy, &listener, this);
+}
+
+registry::~registry() {
+ wl_registry_destroy(this->proxy);
+ this->proxy = nullptr;
+}
+
+void registry::add_global_handler(char const *iface, binder bind) {
+ this->bindings[iface] = bind;
+}
+
+void registry::event_global(uint32_t name, char const *iface, uint32_t v) {
+ auto b = this->bindings.find(iface);
+ if (b != this->bindings.end())
+ b->second(this->proxy, name, v);
+ else
+ logdebug("registry @ %p global n %u i %s v %u", this->proxy, name, iface,
+ v);
+}
+
+void registry::event_global_remove(uint32_t name) {}
+
+constexpr wl_registry_listener registry::listener;
+
+void registry::s_global(void *data, struct wl_registry *r, uint32_t name,
+ char const *iface, uint32_t v) {
+ static_cast<registry *>(data)->event_global(name, iface, v);
+}
+
+void registry::s_global_remove(void *data, struct wl_registry *r,
+ uint32_t name) {
+ static_cast<registry *>(data)->event_global_remove(name);
+}
+
+// _ _
+// ___ _ _| |_ _ __ _ _| |_
+// / _ \| | | | __| '_ \| | | | __|
+// | (_) | |_| | |_| |_) | |_| | |_
+// \___/ \__,_|\__| .__/ \__,_|\__|
+// |_|
+output::output(wl_registry *r, uint32_t name, uint32_t v)
+ : wayland_proxy(wl_registry_bind(r, name, &wl_output_interface, v)) {
+ wl_output_add_listener(this->proxy, &listener, this);
+}
+
+void output::event_geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
+ int32_t subpel, char const *make, char const *model,
+ int32_t tx) {
+ logdebug(
+ "wl::output @ %p x %i y %i w %i h %i spel %x make %s model %s tx %i",
+ this->proxy, x, y, pw, ph, subpel, make, model, tx);
+}
+
+void output::event_mode(uint32_t flags, int32_t w, int32_t h, int32_t r) {
+ logdebug("wl::output @ %p mode f %x w %i h %i r %i", this->proxy, flags, w,
+ h, r);
+}
+
+void output::event_done() { logdebug("wl::output @ %p done", this->proxy); }
+
+void output::event_scale(int32_t factor) {
+ logdebug("wl::output @ %p scale %i", this->proxy, factor);
+}
+
+void output::s_geometry(void *data, struct wl_output *wl_output, int32_t x,
+ int32_t y, int32_t physical_width,
+ int32_t physical_height, int32_t subpixel,
+ const char *make, const char *model,
+ int32_t transform) {
+ static_cast<output *>(data)->event_geometry(
+ x, y, physical_width, physical_height, subpixel, make, model, transform);
+}
+
+void output::s_mode(void *data, struct wl_output *wl_output, uint32_t flags,
+ int32_t width, int32_t height, int32_t refresh) {
+ static_cast<output *>(data)->event_mode(flags, width, height, refresh);
+}
+
+void output::s_done(void *data, struct wl_output *wl_output) {
+ static_cast<output *>(data)->event_done();
+}
+
+void output::s_scale(void *data, struct wl_output *wl_output, int32_t factor) {
+ static_cast<output *>(data)->event_scale(factor);
+}
+
+constexpr wl_output_listener output::listener;
+}
+
+// _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
+// | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
+// | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
+// |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
+// |_|
+// _ _
+// __ _ ___ _ __ (_)_ _(_)
+// / _` |/ _ \ '_ \| \ \ / / |
+// | (_| | __/ | | | |\ V /| |
+// \__, |\___|_| |_|_| \_/ |_|
+// |___/
+namespace genivi {
+
+// _ _ _
+// ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
+// / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
+// | (_| (_) | | | | |_| | | (_) | | | __/ |
+// \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
+//
+controller::controller(wl_registry *r, uint32_t name, uint32_t version)
+ : wayland_proxy(
+ wl_registry_bind(r, name, &ivi_controller_interface, version)) {
+ ivi_controller_add_listener(this->proxy, &listener, this);
+}
+
+controller::~controller() {}
+
+void controller::event_screen(uint32_t id,
+ struct ivi_controller_screen *screen) {
+ logdebug("genivi::controller @ %p screen %u (%x) @ %p", this->proxy, id, id,
+ screen);
+ this->screens[id] = std::make_unique<struct screen>(id, screen);
+}
+
+void controller::event_layer(uint32_t id) {
+ logdebug("genivi::controller @ %p layer %u (%x)", this->proxy, id, id);
+ this->layers[id] = std::make_unique<layer>(id, this->proxy);
+}
+
+void controller::event_surface(uint32_t id) {
+ logdebug("genivi::controller @ %p surface %u (%x)", this->proxy, id, id);
+ this->surfaces[id] = std::make_unique<surface>(id, this->proxy);
+}
+
+void controller::event_error(int32_t object_id, int32_t object_type,
+ int32_t error_code, const char *error_text) {
+ logdebug("genivi::controller @ %p error o %i t %i c %i text %s", this->proxy,
+ object_id, object_type, error_code, error_text);
+}
+
+void controller::s_screen(void *data, struct ivi_controller *ivi_controller,
+ uint32_t id_screen,
+ struct ivi_controller_screen *screen) {
+ static_cast<controller *>(data)->event_screen(id_screen, screen);
+}
+
+void controller::s_layer(void *data, struct ivi_controller *ivi_controller,
+ uint32_t id_layer) {
+ static_cast<controller *>(data)->event_layer(id_layer);
+}
+
+void controller::s_surface(void *data, struct ivi_controller *ivi_controller,
+ uint32_t id_surface) {
+ static_cast<controller *>(data)->event_surface(id_surface);
+}
+
+void controller::s_error(void *data, struct ivi_controller *ivi_controller,
+ int32_t object_id, int32_t object_type,
+ int32_t error_code, const char *error_text) {
+ static_cast<controller *>(data)->event_error(object_id, object_type,
+ error_code, error_text);
+}
+
+constexpr ivi_controller_listener controller::listener;
+
+// _
+// | | __ _ _ _ ___ _ __
+// | |/ _` | | | |/ _ \ '__|
+// | | (_| | |_| | __/ |
+// |_|\__,_|\__, |\___|_|
+// |___/
+layer::layer(uint32_t i, ivi_controller *c)
+ : wayland_proxy(ivi_controller_layer_create(c, i, 0, 0)), id(i) {
+ ivi_controller_layer_add_listener(this->proxy, &listener, this);
+}
+
+layer::~layer() {
+ logdebug("%s layer %i @ %p", __func__, this->id, this->proxy);
+ ivi_controller_layer_destroy(this->proxy, 1);
+ this->proxy = nullptr;
+}
+
+constexpr ivi_controller_layer_listener layer::listener;
+
+// __
+// ___ _ _ _ __ / _| __ _ ___ ___
+// / __| | | | '__| |_ / _` |/ __/ _ \
+// \__ \ |_| | | | _| (_| | (_| __/
+// |___/\__,_|_| |_| \__,_|\___\___|
+//
+surface::surface(uint32_t i, ivi_controller *c)
+ : wayland_proxy(ivi_controller_surface_create(c, i)), id(i) {
+ ivi_controller_surface_add_listener(this->proxy, &listener, this);
+}
+
+surface::~surface() {
+ logdebug("%s surface %i @ %p", __func__, this->id, this->proxy);
+ ivi_controller_surface_destroy(this->proxy, 1);
+ this->proxy = nullptr;
+}
+
+constexpr ivi_controller_surface_listener surface::listener;
+
+//
+// ___ ___ _ __ ___ ___ _ __
+/// __|/ __| '__/ _ \/ _ \ '_ \
+//\__ \ (__| | | __/ __/ | | |
+//|___/\___|_| \___|\___|_| |_|
+//
+screen::screen(uint32_t i, ivi_controller_screen *p)
+ : wayland_proxy(p), id(i) {}
+}
diff --git a/src/wayland.hpp b/src/wayland.hpp
new file mode 100644
index 0000000..5cafd1a
--- /dev/null
+++ b/src/wayland.hpp
@@ -0,0 +1,212 @@
+#ifndef WM_WAYLAND_HPP
+#define WM_WAYLAND_HPP
+
+#include "ivi-controller-client-protocol.h"
+
+#include "util.h"
+
+#include <functional>
+#include <map>
+#include <memory>
+
+// _ _
+// __ ____ _ _ _| | __ _ _ __ __| | _ __ _ __ _____ ___ _
+// \ \ /\ / / _` | | | | |/ _` | '_ \ / _` | | '_ \| '__/ _ \ \/ / | | |
+// \ V V / (_| | |_| | | (_| | | | | (_| | | |_) | | | (_) > <| |_| |
+// \_/\_/ \__,_|\__, |_|\__,_|_| |_|\__,_|____| .__/|_| \___/_/\_\\__, |
+// |___/ |_____|_| |___/
+template <typename ProxyT>
+struct wayland_proxy {
+ ProxyT *proxy;
+
+ wayland_proxy(void *p) : proxy(static_cast<ProxyT *>(p)) {}
+
+ virtual ~wayland_proxy() {
+ // If this is the nullptr, then it means it already was destroyed by a
+ // custom wayland dtor
+ logdebug("%s %p @ %p", __func__, this, this->proxy);
+ if (proxy) {
+ wl_proxy_destroy(reinterpret_cast<wl_proxy *>(proxy));
+ }
+ }
+};
+
+// _
+// _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___ __ _| |
+// | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \ \ \ /\ / / |
+// | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/ \ V V /| |
+// |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___| \_/\_/ |_|
+// |_|
+namespace wl {
+struct registry;
+
+// _ _ _
+// __| (_)___ _ __ | | __ _ _ _
+// / _` | / __| '_ \| |/ _` | | | |
+// | (_| | \__ \ |_) | | (_| | |_| |
+// \__,_|_|___/ .__/|_|\__,_|\__, |
+// |_| |___/
+struct display {
+ std::unique_ptr<wl_display, void (*)(wl_display *)> d;
+ std::unique_ptr<registry> r;
+
+ display();
+ void roundtrip();
+};
+
+// _ _
+// _ __ ___ __ _(_)___| |_ _ __ _ _
+// | '__/ _ \/ _` | / __| __| '__| | | |
+// | | | __/ (_| | \__ \ |_| | | |_| |
+// |_| \___|\__, |_|___/\__|_| \__, |
+// |___/ |___/
+struct registry : public wayland_proxy<wl_registry> {
+ typedef std::function<void(wl_registry *, uint32_t, uint32_t)> binder;
+ std::map<std::string, binder> bindings;
+
+ registry(wl_display *d);
+ ~registry();
+
+ void add_global_handler(char const *iface, binder bind);
+
+ void event_global(uint32_t name, char const *iface, uint32_t v);
+ void event_global_remove(uint32_t name);
+
+ static void s_global(void *data, struct wl_registry *r, uint32_t name,
+ char const *iface, uint32_t v);
+
+ static void s_global_remove(void *data, struct wl_registry *r,
+ uint32_t name);
+
+ static constexpr wl_registry_listener listener = {s_global, s_global_remove};
+};
+
+// _ _
+// ___ _ _| |_ _ __ _ _| |_
+// / _ \| | | | __| '_ \| | | | __|
+// | (_) | |_| | |_| |_) | |_| | |_
+// \___/ \__,_|\__| .__/ \__,_|\__|
+// |_|
+struct output : wayland_proxy<wl_output> {
+ output(wl_registry *registry, uint32_t name, uint32_t version);
+
+ void event_geometry(int32_t x, int32_t y, int32_t pw, int32_t ph,
+ int32_t subpel, char const *make, char const *model,
+ int32_t tx);
+ void event_mode(uint32_t flags, int32_t w, int32_t h, int32_t r);
+ void event_done();
+ void event_scale(int32_t factor);
+
+ static void s_geometry(void *data, struct wl_output *wl_output, int32_t x,
+ int32_t y, int32_t physical_width,
+ int32_t physical_height, int32_t subpixel,
+ const char *make, const char *model,
+ int32_t transform);
+
+ static void s_mode(void *data, struct wl_output *wl_output, uint32_t flags,
+ int32_t width, int32_t height, int32_t refresh);
+
+ static void s_done(void *data, struct wl_output *wl_output);
+
+ static void s_scale(void *data, struct wl_output *wl_output, int32_t factor);
+
+ static constexpr wl_output_listener listener = {s_geometry, s_mode, s_done,
+ s_scale};
+};
+};
+
+// _ __ __ _ _ __ ___ ___ ___ _ __ __ _ ___ ___
+// | '_ \ / _` | '_ ` _ \ / _ \/ __| '_ \ / _` |/ __/ _ \
+// | | | | (_| | | | | | | __/\__ \ |_) | (_| | (_| __/
+// |_| |_|\__,_|_| |_| |_|\___||___/ .__/ \__,_|\___\___|
+// |_|
+// _ _
+// __ _ ___ _ __ (_)_ _(_)
+// / _` |/ _ \ '_ \| \ \ / / |
+// | (_| | __/ | | | |\ V /| |
+// \__, |\___|_| |_|_| \_/ |_|
+// |___/
+namespace genivi {
+
+// __
+// ___ _ _ _ __ / _| __ _ ___ ___
+// / __| | | | '__| |_ / _` |/ __/ _ \
+// \__ \ |_| | | | _| (_| | (_| __/
+// |___/\__,_|_| |_| \__,_|\___\___|
+//
+struct surface : public wayland_proxy<ivi_controller_surface> {
+ uint32_t id;
+
+ surface(uint32_t i, ivi_controller *c);
+ ~surface() override;
+
+ static constexpr ivi_controller_surface_listener listener = {};
+};
+
+// _
+// | | __ _ _ _ ___ _ __
+// | |/ _` | | | |/ _ \ '__|
+// | | (_| | |_| | __/ |
+// |_|\__,_|\__, |\___|_|
+// |___/
+struct layer : public wayland_proxy<ivi_controller_layer> {
+ uint32_t id;
+
+ layer(uint32_t i, ivi_controller *c);
+ ~layer() override;
+
+ static constexpr ivi_controller_layer_listener listener = {};
+};
+
+//
+// ___ ___ _ __ ___ ___ _ __
+/// __|/ __| '__/ _ \/ _ \ '_ \
+//\__ \ (__| | | __/ __/ | | |
+//|___/\___|_| \___|\___|_| |_|
+//
+struct screen : public wayland_proxy<ivi_controller_screen> {
+ uint32_t id;
+
+ screen(uint32_t i, ivi_controller_screen *p);
+};
+
+// _ _ _
+// ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __
+// / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|
+// | (_| (_) | | | | |_| | | (_) | | | __/ |
+// \___\___/|_| |_|\__|_| \___/|_|_|\___|_|
+//
+struct controller : public wayland_proxy<ivi_controller> {
+ std::map<uint32_t, std::unique_ptr<surface>> surfaces;
+ std::map<uint32_t, std::unique_ptr<layer>> layers;
+ std::map<uint32_t, std::unique_ptr<screen>> screens;
+
+ controller(wl_registry *r, uint32_t name, uint32_t version);
+ ~controller() override;
+
+ void event_screen(uint32_t id, ivi_controller_screen *screen);
+ void event_layer(uint32_t id);
+ void event_surface(uint32_t id);
+ void event_error(int32_t oid, int32_t otype, int32_t code, char const *text);
+
+ // thunks...
+ static void s_screen(void *data, struct ivi_controller *ivi_controller,
+ uint32_t id_screen,
+ struct ivi_controller_screen *screen);
+
+ static void s_layer(void *data, struct ivi_controller *ivi_controller,
+ uint32_t id_layer);
+
+ static void s_surface(void *data, struct ivi_controller *ivi_controller,
+ uint32_t id_surface);
+
+ static void s_error(void *data, struct ivi_controller *ivi_controller,
+ int32_t object_id, int32_t object_type,
+ int32_t error_code, const char *error_text);
+
+ static constexpr ivi_controller_listener listener = {s_screen, s_layer,
+ s_surface, s_error};
+};
+}
+
+#endif // !WM_WAYLAND_HPP