summaryrefslogtreecommitdiffstats
path: root/src/json_helper.cpp
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-07-10 10:44:29 +0200
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>2017-08-08 17:24:00 +0200
commit0c673801b78c98fe116b4d14bf37fb18f8b749dc (patch)
tree2600e18722fa4e0694ed33afbadf0c0b83640ebf /src/json_helper.cpp
parent8c587d6defaf73c1ddbe50d88f6fdd7360b63507 (diff)
Track surface/layer properties with one struct
As both share the exact same properties this makes sense, we now can write code once and work on both layer and surface properties. This however is only relevant in the wayland "level" of things, as in WM semantics layers are always fullscreen. Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
Diffstat (limited to 'src/json_helper.cpp')
-rw-r--r--src/json_helper.cpp45
1 files changed, 16 insertions, 29 deletions
diff --git a/src/json_helper.cpp b/src/json_helper.cpp
index 823c030..07f18a8 100644
--- a/src/json_helper.cpp
+++ b/src/json_helper.cpp
@@ -6,32 +6,27 @@
using json = nlohmann::json;
-template <typename T>
-json_object *to_json_(T const *s) {
+json_object *to_json(genivi::surface_properties const &s) {
auto j = json::object({
- {"id", s->id},
- {"size", {{"width", s->size.w}, {"height", s->size.h}}},
+ {"id", s.id},
+ {"size", {{"width", s.size.w}, {"height", s.size.h}}},
{"dst",
- {{"width", s->dst_rect.w},
- {"height", s->dst_rect.h},
- {"x", s->dst_rect.x},
- {"y", s->dst_rect.y}}},
+ {{"width", s.dst_rect.w},
+ {"height", s.dst_rect.h},
+ {"x", s.dst_rect.x},
+ {"y", s.dst_rect.y}}},
{"src",
- {{"width", s->src_rect.w},
- {"height", s->src_rect.h},
- {"x", s->src_rect.x},
- {"y", s->src_rect.y}}},
- {"visibility", s->visibility},
- {"opacity", s->opacity},
- {"orientation", s->orientation},
+ {{"width", s.src_rect.w},
+ {"height", s.src_rect.h},
+ {"x", s.src_rect.x},
+ {"y", s.src_rect.y}}},
+ {"visibility", s.visibility},
+ {"opacity", s.opacity},
+ {"orientation", s.orientation},
});
return json_tokener_parse(j.dump().c_str());
}
-json_object *to_json(genivi::surface const *s) { return to_json_(s); }
-
-json_object *to_json(genivi::layer const *l) { return to_json_(l); }
-
json_object *to_json(genivi::screen const *s) {
auto o = json_object_new_object();
json_object_object_add(o, "id", json_object_new_int(s->id));
@@ -44,22 +39,14 @@ json_object *to_json_(T const &s) {
if (!s.empty()) {
for (auto const &i : s) {
- json_object_array_add(a, to_json(i.second.get()));
+ json_object_array_add(a, to_json(i.second));
}
}
return a;
}
-json_object *to_json(genivi::controller::surface_map_type const &s) {
- return to_json_(s);
-}
-
-json_object *to_json(genivi::controller::layer_map_type const &l) {
- return to_json_(l);
-}
-
-json_object *to_json(genivi::controller::screen_map_type const &s) {
+json_object *to_json(genivi::controller::props_map const &s) {
return to_json_(s);
}