summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-03 10:37:01 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit04c862b9957ea86959bd533cb1ac497ddb52759d (patch)
tree54a1e9d7718f340605727a08552d080037f1cc2e
parentccd8c4d8957c4a561ae1d2d9a53525fe2a4e4329 (diff)
app/api: add demo_activate_surface() api_binding
* Added "main_surface" entry to layers.json. * This surface is never made invisible by activate_surface(). Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r--generate-binding-glue.py1
-rw-r--r--layers.json5
-rw-r--r--src/app.cpp39
-rw-r--r--src/app.hpp1
-rw-r--r--src/layers.cpp5
-rw-r--r--src/layers.hpp1
6 files changed, 52 insertions, 0 deletions
diff --git a/generate-binding-glue.py b/generate-binding-glue.py
index 2a422d2..7aaad36 100644
--- a/generate-binding-glue.py
+++ b/generate-binding-glue.py
@@ -107,6 +107,7 @@ API = {
{ 'name': 'surfaceid', 'type': 'uint32_t', 'jtype': 'int' },
],
},
+ { 'name': 'demo_activate_surface', 'args': [ { 'name': 'surfaceid', 'type': 'uint32_t', 'jtype': 'int' } ] },
{ 'name': 'debug_status', },
{ 'name': 'debug_layers', },
{ 'name': 'debug_surfaces', },
diff --git a/layers.json b/layers.json
index f7cdfe5..0d31a5b 100644
--- a/layers.json
+++ b/layers.json
@@ -1,5 +1,10 @@
{
"comment": "Surface ID to Layer ID mapping",
+
+ "main_surface": {
+ "surface_id": "1000",
+ "comment": "This surface should never be made invisible (The HomeScreen)"
+ },
"mappings": [
{
"type": "single",
diff --git a/src/app.cpp b/src/app.cpp
index 5791f21..713fd1e 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -319,6 +319,36 @@ void App::surface_set_layout(uint32_t surface_id) {
surface_id, layer_id, x, y, w, h);
}
+char const *App::activate_surface(uint32_t surface_id) {
+ if (! this->controller->surface_exists(surface_id)) {
+ return "Surface does not exist";
+ }
+
+ // This shouild involve a policy check, but as we do not (yet) have
+ // such a thing, we will just switch to this surface.
+ // XXX: input focus missing!!1
+
+ // Make it visible, no (or little effect) if already visible
+ auto &s = this->controller->surfaces[surface_id];
+ s->set_visibility(1);
+
+ // Set all others invisible
+ for (auto &i: this->controller->surfaces) {
+ auto &si = this->controller->sprops[i.second->id];
+ // XXX: filtering out homescreen ID ... set this in a known place!!1
+ if (si.visibility == 1 && si.id != s->id && int(si.id) != this->layers.main_surface) {
+ i.second->set_visibility(0);
+ }
+ }
+
+ // commit changes
+ this->controller->commit_changes();
+ this->display->flush();
+
+ // no error
+ return nullptr;
+}
+
void App::add_task(char const *name, std::function<void()> &&f) {
this->pending.emplace_back(std::make_pair(name, f));
}
@@ -400,6 +430,15 @@ binding_api::result_type binding_api::debug_terminate() {
return Ok(json_object_new_object());
}
+binding_api::result_type binding_api::demo_activate_surface(
+ uint32_t surfaceid) {
+ char const *e = this->app->activate_surface(surfaceid);
+ if (e) {
+ return Err<json_object *>(e);
+ }
+ return Ok(json_object_new_object());
+}
+
// _ _ _ _ _
// ___ ___ _ __ | |_ _ __ ___ | | | ___ _ __ | |__ ___ ___ | | _____
// / __/ _ \| '_ \| __| '__/ _ \| | |/ _ \ '__|| '_ \ / _ \ / _ \| |/ / __|
diff --git a/src/app.hpp b/src/app.hpp
index 3f899ce..9df1573 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -70,6 +70,7 @@ struct App {
int dispatch_events();
int init_layout();
void surface_set_layout(uint32_t surface_id);
+ char const *activate_surface(uint32_t surface_id);
void add_task(char const *name, std::function<void()> &&f);
void execute_pending();
diff --git a/src/layers.cpp b/src/layers.cpp
index b5ce2ed..6eae48a 100644
--- a/src/layers.cpp
+++ b/src/layers.cpp
@@ -71,6 +71,11 @@ struct result<struct layer_map> to_layer_map(nlohmann::json const &j) {
}
}
+ auto msi = j.find("main_surface");
+ if (msi != j.end()) {
+ stl.main_surface = get<int>((*msi)["surface_id"]);
+ }
+
// Check lookup
auto jtests = j.value("tests", json());
diff --git a/src/layers.hpp b/src/layers.hpp
index a6df4a0..a02eb00 100644
--- a/src/layers.hpp
+++ b/src/layers.hpp
@@ -68,6 +68,7 @@ struct layer_map {
storage_type mapping;
layers_type layers;
+ int main_surface;
optional<int> get_layer_id(int surface_id);
optional<genivi::rect> get_layer_rect(int surface_id);