+ if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
+ add_task("remove surface", [s](struct controller *c) {
+ c->sprops.erase(s->id);
+ c->surfaces.erase(s->id);
+ });
+ }
+}
+
+void controller::add_proxy_to_id_mapping(struct ivi_controller_surface *p,
+ uint32_t id) {
+ logdebug("Add surface proxy mapping for %p (%u)", p, id);
+ this->surface_proxy_to_id[uintptr_t(p)] = id;
+ this->sprops[id].id = id;
+}
+
+void controller::remove_proxy_to_id_mapping(struct ivi_controller_surface *p) {
+ logdebug("Remove surface proxy mapping for %p", p);
+ this->surface_proxy_to_id.erase(uintptr_t(p));
+}
+
+void controller::add_proxy_to_id_mapping(struct ivi_controller_layer *p,
+ uint32_t id) {
+ logdebug("Add layer proxy mapping for %p (%u)", p, id);
+ this->layer_proxy_to_id[uintptr_t(p)] = id;
+ this->lprops[id].id = id;
+}
+
+void controller::remove_proxy_to_id_mapping(struct ivi_controller_layer *p) {
+ logdebug("Remove layer proxy mapping for %p", p);
+ this->layer_proxy_to_id.erase(uintptr_t(p));
+}
+
+void controller::add_proxy_to_id_mapping(struct wl_output *p, uint32_t id) {
+ logdebug("Add screen proxy mapping for %p (%u)", p, id);
+ this->screen_proxy_to_id[uintptr_t(p)] = id;
+}
+
+void controller::remove_proxy_to_id_mapping(struct wl_output *p) {
+ logdebug("Remove screen proxy mapping for %p", p);
+ this->screen_proxy_to_id.erase(uintptr_t(p));
+}
+
+void controller::add_task(char const *name,
+ std::function<void(struct controller *)> &&f) {
+ this->pending.emplace_back(std::make_pair(name, f));
+}
+
+void controller::execute_pending() {
+ if (!this->pending.empty()) {
+ for (auto &t : this->pending) {
+ logdebug("executing task '%s'", t.first);
+ t.second(this);
+ }
+ this->pending.clear();
+ ivi_controller_commit_changes(this->proxy.get());
+ // XXX: No flush here...
+ }