diff options
author | 2017-08-02 16:16:15 +0200 | |
---|---|---|
committer | 2017-08-08 17:24:00 +0200 | |
commit | 93c2a361b2144d82ec70208225c45afd8f355bd3 (patch) | |
tree | 43801ffca32edaec732b391f4bbf5633de09f6cf /src/app.cpp | |
parent | 9b094f7e17736529e8fd1d25515112f9a1a2daac (diff) |
app/wayland: move late-tasks to App
* 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>
Diffstat (limited to 'src/app.cpp')
-rw-r--r-- | src/app.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/app.cpp b/src/app.cpp index e14984e..685f572 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -213,8 +213,7 @@ int App::dispatch_events() { this->display->flush(); // execute pending tasks, that is layout changes etc. - this->controller->execute_pending(); - this->display->roundtrip(); + this->execute_pending(); return 0; } @@ -320,6 +319,22 @@ void App::surface_set_layout(uint32_t surface_id) { 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(); + } +} + // _ _ _____ _ // _ __ _ __ _____ _(_) ___ __| | | ____|_ _____ _ __ | |_ ___ // | '_ \| '__/ _ \ \/ / |/ _ \/ _` | | _| \ \ / / _ \ '_ \| __/ __| @@ -331,10 +346,8 @@ void App::surface_created(uint32_t surface_id) { // 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) { @@ -401,4 +414,8 @@ void controller_hooks::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 |