wayland: added a pending tasks list to controller
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Thu, 22 Jun 2017 14:23:17 +0000 (16:23 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 8 Aug 2017 15:24:00 +0000 (17:24 +0200)
With this item it is possible to append tasks to the controller, which
will be executed after the current events have been dispatched. Note,
that tasks need to check their needed resources are still alive!

Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/wayland.hpp

index 3914e38..c3d4c2f 100644 (file)
@@ -276,6 +276,21 @@ struct controller : public wayland_proxy<struct ivi_controller> {
    std::map<uint32_t, std::unique_ptr<struct layer>> layers;
    std::map<uint32_t, std::unique_ptr<struct screen>> screens;
 
+   std::vector<std::function<void(struct controller *)>> pending;
+
+   void add_task(std::function<void(struct controller *)> &&f) {
+      this->pending.emplace_back(f);
+   }
+   void execute_pending() {
+      if (!this->pending.empty()) {
+         for (auto &t : this->pending) {
+            t(this);
+         }
+         this->pending.clear();
+         ivi_controller_commit_changes(this->proxy);
+      }
+   }
+
    controller(struct wl_registry *r, uint32_t name, uint32_t version);
    ~controller() override;