summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app.cpp52
-rw-r--r--src/app.hpp7
2 files changed, 33 insertions, 26 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());
+}
+
// _ _ _ _ _ _ _
// | |__ (_)_ __ __| (_)_ __ __ _ __ _ _ __ (_) (_)_ __ ___ _ __ | |
// | '_ \| | '_ \ / _` | | '_ \ / _` | / _` | '_ \| | | | '_ ` _ \| '_ \| |
diff --git a/src/app.hpp b/src/app.hpp
index 3e3a56e..fa26e39 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -131,11 +131,11 @@ struct App {
App &operator=(App &&) = delete;
int init();
- int init_layout();
+ int init_layers();
int dispatch_events();
- void surface_set_layout(uint32_t surface_id);
+ void surface_init_layout(uint32_t surface_id);
// Allocate a surface ID for this role
result<int> request_surface(char const *drawing_name);
@@ -154,6 +154,9 @@ struct App {
void emit_syncdraw(char const *label);
void emit_flushdraw(char const *label);
void emit_visible(char const *label, bool is_visible);
+
+ void activate(unsigned id);
+ void deactivate(unsigned id);
};
} // namespace wm