Generating binding API glue code using generate-binding.py
[staging/windowmanager.git] / src / app.cpp
1 //
2 // Created by mfritzsc on 7/11/17.
3 //
4
5 #include "app.hpp"
6 #include "util.hpp"
7 #include "json_helper.hpp"
8 #include "wayland.hpp"
9
10 #include <json-c/json.h>
11
12 namespace wm {
13
14     App::App()
15             : api{this}, display{}, controller{}
16     {}
17
18     binding_api::result_type binding_api::register_surface(uint32_t appid,
19                                                           uint32_t surfid) {
20         logdebug("%s appid %u surfid %u", __func__, appid, surfid);
21         if (appid > 0xff) {
22             return Err<json_object *>("invalid appid");
23         }
24
25         if (surfid > 0xffff) {
26             return Err<json_object *>("invalid surfaceid");
27         }
28
29         return Ok(json_object_new_int((appid << 16) + surfid));
30     }
31
32     binding_api::result_type binding_api::debug_layers() {
33         logdebug("%s", __func__);
34         return Ok(to_json(this->app->controller->lprops));
35     }
36
37     binding_api::result_type binding_api::debug_surfaces() {
38         logdebug("%s", __func__);
39         return Ok(to_json(this->app->controller->sprops));
40     }
41
42     binding_api::result_type binding_api::debug_status() {
43         logdebug("%s", __func__);
44         json_object *jr = json_object_new_object();
45         json_object_object_add(jr, "surfaces", to_json(this->app->controller->sprops));
46         json_object_object_add(jr, "layers", to_json(this->app->controller->lprops));
47         return Ok(jr);
48     }
49
50 } // namespace wm