main: add layers and surfaces API calls
authorMarcus Fritzsch <marcus_fritzsch@mentor.com>
Wed, 5 Jul 2017 14:13:46 +0000 (16:13 +0200)
committerMarcus Fritzsch <marcus_fritzsch@mentor.com>
Tue, 8 Aug 2017 15:24:00 +0000 (17:24 +0200)
Signed-off-by: Marcus Fritzsch <marcus_fritzsch@mentor.com>
src/main.cpp

index e78b42f..13e6ab2 100644 (file)
@@ -228,8 +228,35 @@ void debug_status(struct afb_req req) noexcept {
    }
 }
 
+void debug_surfaces(afb_req req) {
+   auto a = json_object_new_array();
+
+   if (!g_wayland->controller->surfaces.empty()) {
+      for (auto const &i : g_wayland->controller->surfaces) {
+         json_object_array_add(a, json_object_new_int(i.first));
+      }
+   }
+
+   afb_req_success(req, a, "surfaces");
+}
+
+void debug_layers(afb_req req) {
+   auto a = json_object_new_array();
+
+   if (!g_wayland->controller->layers.empty()) {
+      for (auto const &i : g_wayland->controller->layers) {
+         json_object_array_add(a, json_object_new_int(i.first));
+      }
+   }
+
+   afb_req_success(req, a, "surfaces");
+}
+
 const struct afb_verb_v2 verbs[] = {
-   {"status", debug_status, NULL, NULL, AFB_SESSION_NONE_V2}, {},
+   {"status", debug_status, NULL, NULL, AFB_SESSION_NONE_V2},
+   {"layers", debug_layers, NULL, NULL, AFB_SESSION_NONE_V2},
+   {"surfaces", debug_surfaces, NULL, NULL, AFB_SESSION_NONE_V2},
+   {},
 };
 }  // namespace