+namespace {
+
+void surface_visibility(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t visibility) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_visibility(s->id, visibility);
+}
+
+void surface_opacity(void *data,
+ struct ivi_controller_surface * /*ivi_controller_surface*/,
+ wl_fixed_t opacity) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_opacity(s->id, float(wl_fixed_to_double(opacity)));
+}
+
+void surface_source_rectangle(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t x, int32_t y, int32_t width, int32_t height) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_source_rectangle(s->id, x, y, width, height);
+}
+
+void surface_destination_rectangle(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t x, int32_t y, int32_t width, int32_t height) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_destination_rectangle(s->id, x, y, width, height);
+}
+
+void surface_configuration(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t width, int32_t height) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_configuration(s->id, width, height);
+}
+
+void surface_orientation(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t orientation) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_orientation(s->id, orientation);
+}
+
+void surface_pixelformat(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t pixelformat) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_pixelformat(s->id, pixelformat);
+}
+
+void surface_layer(void *data,
+ struct ivi_controller_surface * /*ivi_controller_surface*/,
+ struct ivi_controller_layer *layer) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_layer(s->id, layer);
+}
+
+void surface_stats(void *data,
+ struct ivi_controller_surface * /*ivi_controller_surface*/,
+ uint32_t redraw_count, uint32_t frame_count,
+ uint32_t update_count, uint32_t pid,
+ const char *process_name) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_stats(s->id, redraw_count, frame_count,
+ update_count, pid, process_name);
+}
+
+void surface_destroyed(
+ void *data, struct ivi_controller_surface * /*ivi_controller_surface*/) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_destroyed(s->id);
+}
+
+void surface_content(void *data,
+ struct ivi_controller_surface * /*ivi_controller_surface*/,
+ int32_t content_state) {
+ auto s = static_cast<struct surface *>(data);
+ s->parent->surface_content(s->id, content_state);
+}
+
+constexpr struct ivi_controller_surface_listener surface_listener = {
+ surface_visibility,
+ surface_opacity,
+ surface_source_rectangle,
+ surface_destination_rectangle,
+ surface_configuration,
+ surface_orientation,
+ surface_pixelformat,
+ surface_layer,
+ surface_stats,
+ surface_destroyed,
+ surface_content,
+};
+} // namespace
+
+surface::surface(uint32_t i, struct controller *c)
+ : wayland_proxy(ivi_controller_surface_create(c->proxy, i)),
+ controller_child(c, i),
+ dst_rect{},
+ src_rect{},
+ size{},
+ orientation{},
+ visibility{},
+ opacity{1.f} {
+ this->parent->add_proxy_to_id_mapping(this->proxy, i);
+ ivi_controller_surface_add_listener(this->proxy, &surface_listener, this);