summaryrefslogtreecommitdiffstats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-12-20 10:34:08 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2019-02-12 02:00:41 +0000
commit692208b29ec18373960928bcbfdf4474a1af7b7b (patch)
tree72130f4f8b99e9ba2e5473c1484198e4e9ef91be /src/main.cpp
parent923df38d358f8971cf16cc78365adb2b45182bc5 (diff)
Introduce changeAreaSize and getAreaList
In CES2019 demo, these features are introduced in demo3. 1. changeAreaSize : change area definition on runtime 2. getAreaList : get area definition list v2. fix merge conflict util.hpp util.cpp Bug-AGL : SPEC-2077 Change-Id: I1fa3c9e3648c69e14a3916cbeeb9775ed94c833a Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp
index cc4386c..6483655 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -413,6 +413,73 @@ void windowmanager_getareainfo_thunk(afb_req_t req) noexcept
}
}
+void windowmanager_get_area_list(afb_req_t req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+ json_object* ret = g_afb_instance->wmgr.api_get_area_list();
+ afb_req_success(req, ret, nullptr);
+}
+
+void windowmanager_change_area_size(afb_req_t req) noexcept
+{
+ std::lock_guard<std::mutex> guard(binding_m);
+ if (g_afb_instance == nullptr)
+ {
+ afb_req_fail(req, "failed", "Binding not initialized, did the compositor die?");
+ return;
+ }
+
+ char* appid = afb_req_get_application_id(req);
+ if(appid)
+ {
+ ChangeAreaReq change_req;
+ change_req.appname = appid;
+ change_req.save = false;
+ json_object *jreq = afb_req_json(req);
+ json_object *jsave, *jareas;
+ HMI_INFO("json_check, %s", json_object_get_string(jreq));
+ if(json_object_object_get_ex(jreq, "save", &jsave))
+ {
+ change_req.save = json_object_get_boolean(jsave);
+ }
+ if (json_object_object_get_ex(jreq, "areas", &jareas))
+ {
+ int size = json_object_array_length(jareas);
+ for(int i = 0; i < size; i++)
+ {
+ json_object* elem = json_object_array_get_idx(jareas, i);
+ struct rect rect;
+ std::string name = jh::getStringFromJson(elem, "name");
+ json_object* jrect;
+ if(json_object_object_get_ex(elem, "rect", &jrect))
+ {
+ rect.x = jh::getIntFromJson(jrect, "x");
+ rect.y = jh::getIntFromJson(jrect, "y");
+ rect.w = jh::getIntFromJson(jrect, "w");
+ rect.h = jh::getIntFromJson(jrect, "h");
+ }
+ else
+ {
+ HMI_ERROR("bad request @area name :%s", name.c_str());
+ afb_req_fail(req, "failed", "bad request");
+ return;
+ }
+ change_req.area_req[name] = rect;
+ }
+ if(change_req.area_req.size() != 0)
+ {
+ g_afb_instance->wmgr.api_change_area_size(change_req);
+ }
+ afb_req_success(req, nullptr, nullptr);
+ }
+ free(appid);
+ }
+ else
+ {
+ afb_req_fail(req, "failed", nullptr);
+ }
+}
+
void windowmanager_wm_subscribe(afb_req_t req) noexcept
{
std::lock_guard<std::mutex> guard(binding_m);
@@ -498,6 +565,8 @@ const afb_verb_t windowmanager_verbs[] = {
{ .verb = "endDraw", .callback = windowmanager_enddraw },
{ .verb = "getDisplayInfo", .callback = windowmanager_getdisplayinfo_thunk },
{ .verb = "getAreaInfo", .callback = windowmanager_getareainfo_thunk },
+ { .verb = "changeAreaSize", .callback = windowmanager_change_area_size },
+ { .verb = "getAreaList", .callback = windowmanager_get_area_list },
{ .verb = "wm_subscribe", .callback = windowmanager_wm_subscribe },
{ .verb = "ping", .callback = windowmanager_ping },
{ .verb = "debug_terminate", .callback = windowmanager_debug_terminate },