summaryrefslogtreecommitdiffstats
path: root/src/app.cpp
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-05 11:53:17 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-09-05 12:13:30 +0200
commit43fdd0813f485907fd8659feb28b18913a1d80ce (patch)
treed92fcb41d0410faad15803e07290cb90894eee9e /src/app.cpp
parent6660e3c8783bb9481e862b93500cf4a3dac8fcc4 (diff)
App: some quality improvements, add activate/deactivate helper
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src/app.cpp')
-rw-r--r--src/app.cpp52
1 files changed, 28 insertions, 24 deletions
diff --git a/src/app.cpp b/src/app.cpp
index 3e28a5f..e4a4c4d 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -196,7 +196,7 @@ int App::init() {
// Third level objects
this->display->roundtrip();
- return init_layout();
+ return init_layers();
}
int App::dispatch_events() {
@@ -220,7 +220,7 @@ int App::dispatch_events() {
// | | | | | | |_ | | (_| | |_| | (_) | |_| | |_| | | |
// |_|_| |_|_|\__|___|_|\__,_|\__, |\___/ \__,_|\__| | | |
// |_____| |___/ \_\/_/
-int App::init_layout() {
+int App::init_layers() {
if (!this->controller) {
logerror("ivi_controller global not available");
return -1;
@@ -274,9 +274,9 @@ namespace {
void redraw_fix(App *app, std::unique_ptr<genivi::surface> &s, int x, int y, int w, int h) {
{ // XXX: Work around weston redraw issues
// trigger an update by changing the source dimensions!
- s->set_configuration(w, h);
- s->set_source_rectangle(0, 0, w, h);
- s->set_destination_rectangle(x, y, w, h);
+ s->set_configuration(w + 1, h);
+ s->set_source_rectangle(0, 0, w + 1, h);
+ s->set_destination_rectangle(x, y, w + 1, h);
app->controller->commit_changes();
app->display->roundtrip();
@@ -285,19 +285,17 @@ void redraw_fix(App *app, std::unique_ptr<genivi::surface> &s, int x, int y, int
std::this_thread::sleep_for(100ms);
// Set a different size then what we actually want.
- s->set_configuration(w + 1, h);
- s->set_source_rectangle(0, 0, w + 1, h);
- s->set_destination_rectangle(x, y, w + 1, h);
+ s->set_configuration(w, h);
+ s->set_source_rectangle(0, 0, w, h);
+ s->set_destination_rectangle(x, y, w, h);
app->controller->commit_changes();
app->display->roundtrip();
-
- std::this_thread::sleep_for(100ms);
}
}
} // namespace
-void App::surface_set_layout(uint32_t surface_id) {
+void App::surface_init_layout(uint32_t surface_id) {
if (!this->controller->surface_exists(surface_id)) {
logerror("Surface %d does not exist", int(surface_id));
return;
@@ -332,8 +330,6 @@ void App::surface_set_layout(uint32_t surface_id) {
h = this->controller->output_size.h + 1 + h;
}
- redraw_fix(this, s, x, y, w, h);
-
// configure surface to wxh dimensions
s->set_configuration(w, h);
@@ -349,6 +345,8 @@ void App::surface_set_layout(uint32_t surface_id) {
this->controller->commit_changes();
this->display->roundtrip();
+ redraw_fix(this, s, x, y, w, h);
+
this->controller->layers[layer_id]->add_surface(s.get());
// activate the main_surface right away
@@ -388,20 +386,16 @@ char const *App::activate_surface(char const *drawing_name) {
// Set all others invisible
for (auto &i : this->controller->surfaces) {
auto &si = this->controller->sprops[i.second->id];
- if (int(si.id) != this->layers.main_surface) {
- i.second->set_visibility(0);
- this->controller->commit_changes();
- this->display->flush();
+ if (si.visibility != 0 && int(si.id) != this->layers.main_surface) {
+ this->deactivate(i.second->id);
}
}
- s->set_visibility(1);
+ this->activate(s->id);
// commit changes
this->controller->commit_changes();
this->display->flush();
- this->emit_activated(drawing_name);
-
// no error
return nullptr;
}
@@ -422,10 +416,10 @@ char const *App::deactivate_surface(char const *drawing_name) {
return "Cannot deactivate main_surface";
}
+ this->deactivate(surface_id);
-
- this->emit_deactivated(drawing_name);
-
+ this->controller->commit_changes();
+ this->display->flush();
return nullptr;
}
@@ -441,7 +435,7 @@ void App::surface_created(uint32_t surface_id) {
logdebug("surface_id is %u", surface_id);
- this->surface_set_layout(surface_id);
+ this->surface_init_layout(surface_id);
}
void App::surface_removed(uint32_t surface_id) {
@@ -500,6 +494,16 @@ result<int> App::request_surface(char const *drawing_name) {
return Err<int>("Surface already present");
}
+void App::activate(unsigned id) {
+ this->controller->surfaces[id]->set_visibility(1);
+ this->emit_activated(this->lookup_name(id).value_or("unknown-name").c_str());
+}
+
+void App::deactivate(unsigned id) {
+ this->controller->surfaces[id]->set_visibility(0);
+ this->emit_deactivated(this->lookup_name(id).value_or("unknown-name").c_str());
+}
+
// _ _ _ _ _ _ _
// | |__ (_)_ __ __| (_)_ __ __ _ __ _ _ __ (_) (_)_ __ ___ _ __ | |
// | '_ \| | '_ \ / _` | | '_ \ / _` | / _` | '_ \| | | | '_ ` _ \| '_ \| |