app/wayland: move late-tasks to App
[staging/windowmanager.git] / src / wayland.cpp
index 3be264b..672dab0 100644 (file)
@@ -426,9 +426,9 @@ void controller::layer_screen(struct layer * /*l*/, struct wl_output *screen) {
 
 void controller::layer_destroyed(struct layer *l) {
    logdebug("genivi::layer %s @ %p", __func__, this->proxy.get());
-   add_task("remove layer", [l](struct controller *c) {
-      c->lprops.erase(l->id);
-      c->layers.erase(l->id);
+   this->chooks->add_task("remove layer", [l, this] {
+      this->lprops.erase(l->id);
+      this->layers.erase(l->id);
    });
 }
 
@@ -662,9 +662,9 @@ void controller::surface_content(struct surface *s, int32_t content_state) {
    if (content_state == IVI_CONTROLLER_SURFACE_CONTENT_STATE_CONTENT_REMOVED) {
       // XXX is this the right thing to do?
       this->chooks->surface_removed(s->id);
-      add_task("remove surface", [s](struct controller *c) {
-         c->sprops.erase(s->id);
-         c->surfaces.erase(s->id);
+      this->chooks->add_task("remove surface", [this, s] {
+         this->sprops.erase(s->id);
+         this->surfaces.erase(s->id);
       });
    }
 }
@@ -703,23 +703,6 @@ void controller::remove_proxy_to_id_mapping(struct wl_output *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...
-   }
-}
-
 //
 //  ___  ___ _ __ ___  ___ _ __
 // / __|/ __| '__/ _ \/ _ \ '_ \