From 54c34361d08386c751897ee215554c9ea1efd108 Mon Sep 17 00:00:00 2001 From: Marcus Fritzsch Date: Wed, 12 Jul 2017 15:59:37 +0200 Subject: Generating binding API glue code using generate-binding.py Signed-off-by: Marcus Fritzsch --- src/app.cpp | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'src/app.cpp') diff --git a/src/app.cpp b/src/app.cpp index 5da4f9d..74f3bfa 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -3,28 +3,48 @@ // #include "app.hpp" +#include "util.hpp" +#include "json_helper.hpp" +#include "wayland.hpp" + +#include namespace wm { App::App() - : api{this} + : api{this}, display{}, controller{} {} - result App::API::register_surface(uint32_t appid, + binding_api::result_type binding_api::register_surface(uint32_t appid, uint32_t surfid) { - return Err("not implemented"); + logdebug("%s appid %u surfid %u", __func__, appid, surfid); + if (appid > 0xff) { + return Err("invalid appid"); + } + + if (surfid > 0xffff) { + return Err("invalid surfaceid"); + } + + return Ok(json_object_new_int((appid << 16) + surfid)); } - result App::API::debug_layers() const { - return Err("not implemented"); + binding_api::result_type binding_api::debug_layers() { + logdebug("%s", __func__); + return Ok(to_json(this->app->controller->lprops)); } - result App::API::debug_surfaces() const { - return Err("not implemented"); + binding_api::result_type binding_api::debug_surfaces() { + logdebug("%s", __func__); + return Ok(to_json(this->app->controller->sprops)); } - result App::API::debug_status() const { - return Err("not implemented"); + binding_api::result_type binding_api::debug_status() { + logdebug("%s", __func__); + json_object *jr = json_object_new_object(); + json_object_object_add(jr, "surfaces", to_json(this->app->controller->sprops)); + json_object_object_add(jr, "layers", to_json(this->app->controller->lprops)); + return Ok(jr); } } // namespace wm \ No newline at end of file -- cgit 1.2.3-korg