- try {
- json j;
-
- if (!g_wayland->controller->surfaces.empty()) {
- auto js = json::array();
- for (auto const &i : g_wayland->controller->surfaces) {
- auto const &r = i.second->dst_rect;
- auto const &s = i.second->size;
- js.push_back({{"id", i.first},
- {"size", {s.w, s.h}},
- {"dst_rect", {r.w, r.h, r.x, r.y}}});
- }
- j["surfaces"] = js;
- }
-
- if (!g_wayland->controller->layers.empty()) {
- auto js = json::array();
- for (auto const &i : g_wayland->controller->layers) {
- auto const &r = i.second->dst_rect;
- auto const &s = i.second->size;
- js.push_back({{"id", i.first},
- {"size", {s.w, s.h}},
- {"dst_rect", {r.w, r.h, r.x, r.y}}});
- }
- j["layers"] = js;
- }
-
- afb_req_success(req, json_tokener_parse(j.dump().c_str()), "status");
- } catch (std::exception &e) {
- afb_req_fail_f(req, "failed", "Uncaught exception: %s", e.what());
- }