summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-28 13:19:47 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit743884774843259d92ec2b3745caa7e91805af53 (patch)
tree10f1e0a2eafa07a03331cbe3331e43fd5badad5e
parent3a0a0018eec4a3a2cbcb34cf2f2033f86e6f9504 (diff)
app: scene setup according to ids.json
* Setup layers as specified in ids.json. * Map surfaces to their layers. * Complain about unknown surfaces (i.e. those w/o a mapping). Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
-rw-r--r--src/app.cpp73
-rw-r--r--src/app.hpp2
2 files changed, 40 insertions, 35 deletions
diff --git a/src/app.cpp b/src/app.cpp
index e04b89b..939d569 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -42,7 +42,7 @@ result<struct layout> layout_from_json(json const &j) {
DB(j);
auto &ja = j["areas"];
- auto l = wm::layout{j["name"].get<std::string>(), uint32_t(ja.size()), {}};
+ auto l = layout{j["name"].get<std::string>(), uint32_t(ja.size()), {}};
if (ja.size() > layout::MAX_N_AREAS) {
return Err<struct layout>("Invalid number of areas in layout");
@@ -92,22 +92,16 @@ struct result<surface_id_to_layer_map>
// \___|_|\__,_|___/___/ /_/ \_\ .__/| .__/ |_|_| |_| |_| .__/|_|
// |_| |_| |_|
App::App(wl::display *d)
- : api{this}, chooks{this}, display{d}, controller{} {
+ : api{this},
+ chooks{this},
+ display{d},
+ controller{},
+ outputs(),
+ layouts(load_layout("../layout.json").unwrap()),
+ surface2layer(load_layer_ids("../ids.json").unwrap()) {
// layouts(load_layout("../layout.json").unwrap()) {
assert(g_app == nullptr);
g_app = this;
-
- auto a = load_layout("../layout.json");
- auto b = a.map_err([](char const *e) -> char const * {
- DB("Could not load layout: " << e);
- return e;
- });
-
- auto c = load_layer_ids("../ids.json");
- auto e = c.map_err([](char const *e) -> char const * {
- DB("Could not load ids: " << e);
- return e;
- });
}
App::~App() { g_app = nullptr; }
@@ -195,21 +189,22 @@ int App::init_layout() {
// Clear screen
s->clear();
- // Setup our dummy scene...
- c->layer_create(100, 0, 0); // bottom layer, anything else
- c->layer_create(1000, 0, 0); // top layer, mandelbrot
-
- auto &l100 = c->layers[100];
- auto &l1k = c->layers[1000];
-
- // Set layers fullscreen
- l100->set_destination_rectangle(0, 0, o->width, o->height);
- l1k->set_destination_rectangle(0, 0, o->width, o->height);
- l100->set_visibility(1);
- l1k->set_visibility(1);
+ // Quick and dirty setup of layers
+ // XXX: This likely needs to be sorted by order (note, we don't (yet?)
+ // do any zorder arrangement).
+ std::vector<unsigned> ls;
+ ls.reserve(this->surface2layer.mapping.size());
+ for (auto const &i: this->surface2layer.mapping) {
+ c->layer_create(i.layer_id, o->width, o->height);
+ auto &l = layers[i.layer_id];
+ l->set_destination_rectangle(0, 0, o->width, o->height);
+ l->set_visibility(1);
+ DB("Setting up layer " << i.layer_id << " for surfaces " << i.id_min << " through " << i.id_max);
+ ls.push_back(unsigned(i.layer_id));
+ }
// Add layers to screen
- s->set_render_order({100, 1000});
+ s->set_render_order(ls);
c->commit_changes();
@@ -220,14 +215,22 @@ int App::init_layout() {
void App::surface_created(uint32_t surface_id) {
DB("surface_id is " << surface_id);
- this->controller->add_task("fullscreen surface", [surface_id](struct genivi::controller *c) {
- auto &s = c->surfaces[surface_id];
- s->set_destination_rectangle(0, 0, c->output_size.w, c->output_size.h);
- s->set_visibility(1);
- uint32_t lid = surface_id == 0x16180 ? 1000 : 100;
- c->layers[lid]->add_surface(s.get());
- logdebug("Surface %u now fullscreen on layer %u", surface_id, lid);
- });
+ int layer_id =
+ this->surface2layer.get_layer_for_surface(surface_id).value_or(-1);
+ if (layer_id == -1) {
+ logerror("Surface %d (0x%x) is not part of any layer!", surface_id,
+ surface_id);
+ } else {
+ this->controller->add_task(
+ "fullscreen surface", [layer_id, surface_id](struct genivi::controller *c) {
+ auto &s = c->surfaces[surface_id];
+ s->set_destination_rectangle(0, 0, c->output_size.w,
+ c->output_size.h);
+ s->set_visibility(1);
+ c->layers[layer_id]->add_surface(s.get());
+ logdebug("Surface %u now fullscreen on layer %u", surface_id, layer_id);
+ });
+ }
}
void App::surface_removed(uint32_t surface_id) {
diff --git a/src/app.hpp b/src/app.hpp
index 0e38bc0..512f272 100644
--- a/src/app.hpp
+++ b/src/app.hpp
@@ -13,6 +13,7 @@
#include "wayland.hpp"
#include "layout.hpp"
#include "controller_hooks.hpp"
+#include "layers.hpp"
namespace wl {
struct display;
@@ -35,6 +36,7 @@ struct App {
std::vector<std::unique_ptr<struct wl::output>> outputs;
layouts_type layouts;
+ surface_id_to_layer_map surface2layer;
App(wl::display *d);
~App();