X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fmain.cpp;h=f5d33c7fbebc30c17aae74aea362dd97a7c80217;hb=8e831f9b2e461c94a8ee0e229812bcf2d42ae2a5;hp=e78b42f497d4e29f1806da34fa1535344704e214;hpb=77fcaa36178e739044b8ce4e68388440c4379a74;p=staging%2Fwindowmanager.git diff --git a/src/main.cpp b/src/main.cpp index e78b42f..f5d33c7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -179,6 +179,15 @@ int binding_init() noexcept { return -1; } +#define CHECK_WAYLAND() \ + do { \ + if (g_wayland == nullptr) { \ + afb_req_fail(req, "failed", \ + "Binding not initialized, did the compositor die?"); \ + return; \ + } \ + } while (0) + // _ _ _ _ ____ // __| | ___| |__ _ _ __ _ ___| |_ __ _| |_ _ _ ___ / /\ \ // / _` |/ _ \ '_ \| | | |/ _` | / __| __/ _` | __| | | / __| | | | @@ -189,11 +198,7 @@ void debug_status(struct afb_req req) noexcept { // Quick and dirty, dump current surfaces and layers AFB_REQ_DEBUG(req, "status"); - if (g_wayland == nullptr) { - afb_req_fail(req, "failed", - "Binding not initialized, did the compositor die?"); - return; - } + CHECK_WAYLAND(); try { json j; @@ -228,8 +233,39 @@ void debug_status(struct afb_req req) noexcept { } } +void debug_surfaces(afb_req req) { + CHECK_WAYLAND(); + + 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) { + CHECK_WAYLAND(); + + 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