* Move late-tasks to App.
* Add add_task() to controller_hooks.
* Do not roundtrip at the end of App::execute_pending(), flush() is
enough.
* Tasks are now void() functions, need to capture what is needed.
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
this->display->flush();
// execute pending tasks, that is layout changes etc.
- this->controller->execute_pending();
- this->display->roundtrip();
+ this->execute_pending();
return 0;
}
surface_id, layer_id, x, y, w, h);
}
+void App::add_task(char const *name, std::function<void()> &&f) {
+ this->pending.emplace_back(std::make_pair(name, f));
+}
+
+void App::execute_pending() {
+ if (!this->pending.empty()) {
+ for (auto &t : this->pending) {
+ logdebug("executing task '%s'", t.first);
+ t.second();
+ }
+ this->pending.clear();
+ this->controller->commit_changes();
+ this->display->flush();
+ }
+}
+
// _ _ _____ _
// _ __ _ __ _____ _(_) ___ __| | | ____|_ _____ _ __ | |_ ___
// | '_ \| '__/ _ \ \/ / |/ _ \/ _` | | _| \ \ / / _ \ '_ \| __/ __|
// We need to execute the surface setup after its creation.
// XXX: perhaps move the late-tasks functionality to App?
- this->controller->add_task("surface_set_layout",
- [surface_id, this](struct genivi::controller *) {
- this->surface_set_layout(surface_id);
- });
+ this->add_task("surface_set_layout",
+ [surface_id, this] { this->surface_set_layout(surface_id); });
}
void App::surface_removed(uint32_t surface_id) {
this->app->surface_removed(surface_id);
}
+void controller_hooks::add_task(char const *name, std::function<void()> &&f) {
+ this->app->add_task(name, std::move(f));
+}
+
} // namespace wm
layouts_type layouts;
layer_map layers;
+ typedef std::pair<char const *, std::function<void()>> name_task_pair;
+ std::vector<name_task_pair> pending;
+
App(wl::display *d);
~App();
int init_layout();
void surface_set_layout(uint32_t surface_id);
+ void add_task(char const *name, std::function<void()> &&f);
+ void execute_pending();
+
void surface_created(uint32_t surface_id);
void surface_removed(uint32_t surface_id);
};
#include <cstdint>
+#include <functional>
+
namespace wm {
struct App;
void surface_created(uint32_t surface_id);
void surface_removed(uint32_t surface_id);
+
+ void add_task(char const *name, std::function<void()> &&);
};
} // namespace wm
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);
});
}
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);
});
}
}
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...
- }
-}
-
//
// ___ ___ _ __ ___ ___ _ __
// / __|/ __| '__/ _ \/ _ \ '_ \
layer_map_type layers;
screen_map_type screens;
- typedef std::pair<char const *, std::function<void(struct controller *)>>
- name_task_pair;
- std::vector<name_task_pair> pending;
-
size output_size;
wm::controller_hooks *chooks;
void add_proxy_to_id_mapping(struct wl_output *p, uint32_t id);
void remove_proxy_to_id_mapping(struct wl_output *p);
- void add_task(char const *name,
- std::function<void(struct controller *)> &&f);
- void execute_pending();
-
-
bool surface_exists(uint32_t id) const {
return this->surfaces.find(id) != this->surfaces.end();
}