summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libwindowmanager.cpp66
-rw-r--r--src/libwindowmanager.h3
2 files changed, 69 insertions, 0 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp
index db59dab..41cf1fe 100644
--- a/src/libwindowmanager.cpp
+++ b/src/libwindowmanager.cpp
@@ -65,6 +65,7 @@ class LibWindowmanager::Impl {
int deactivateWindow(json_object *object);
int endDraw(json_object *object);
int setRenderOrder(json_object* object);
+ int getAreaList(ChangeAreaReq* req);
int changeAreaSize(json_object* object);
int getDisplayInfo(json_object *object);
@@ -453,6 +454,65 @@ int LibWindowmanager::Impl::setRenderOrder(json_object *object) {
});
}
+int LibWindowmanager::Impl::getAreaList(ChangeAreaReq* req) {
+ TRACE();
+ json_object* obj = json_object_new_object();
+ int rc = -1;
+ /* send the request */
+ int rc2 =
+ this->api_call("getAreaList", nullptr,
+ [req, &rc](bool ok, json_object *j) {
+ if (ok) {
+ json_object *val, *jarea;
+ if (json_object_object_get_ex(j, g_kKeyResponse, &val)) {
+ HMI_DEBUG("libwm", "responce:%s", json_object_get_string(val));
+ if (json_object_object_get_ex(val, "areas", &jarea)) {
+ int size = json_object_array_length(val);
+ for(int i = 0; i < size; i++)
+ {
+ json_object* elem = json_object_array_get_idx(jarea, i);
+ Rect rect;
+ json_object *_val, *jrect;
+ std::string name;
+ json_object_object_get_ex(elem, "name", &_val);
+ name = json_object_get_string(_val);
+ if(json_object_object_get_ex(elem, "rect", &jrect)) {
+ if(json_object_object_get_ex(jrect, "x", &_val))
+ rect.set_left(json_object_get_int(_val));
+ if(json_object_object_get_ex(jrect, "y", &_val))
+ rect.set_top(json_object_get_int(_val));
+ if(json_object_object_get_ex(jrect, "w", &_val))
+ rect.set_width(json_object_get_int(_val));
+ if(json_object_object_get_ex(jrect, "h", &_val))
+ rect.set_height(json_object_get_int(_val));
+ }
+ req->addAreaList(name, rect);
+ }
+ rc = 0;
+ }
+ }
+ else {
+ HMI_ERROR("libwm", "Not found key \"response\"");
+ rc = -EINVAL;
+ return;
+ }
+ } else {
+ HMI_ERROR("libwm", "Windowmanager-service is not initialized: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ rc = -EPERM;
+ }
+ });
+
+ if (0 > rc2) {
+ HMI_ERROR("libwm", "api_call() failed");
+ rc = rc2;
+ }
+
+ return rc;
+}
+
int LibWindowmanager::Impl::changeAreaSize(json_object* object) {
TRACE();
return this->api_call(__func__, object, [](bool ok, json_object *j) {
@@ -718,6 +778,7 @@ int LibWindowmanager::Impl::api_call(
int rc = 0;
if ((0 == strcmp("RequestSurface", verb)) ||
(0 == strcmp("GetDisplayInfo", verb)) ||
+ (0 == strcmp("getAreaList", verb)) ||
(0 == strcmp("GetAreaInfo", verb))) {
// We need to wrap the actual onReply call once in order to
// *look* like a normal functions pointer (std::functions<>
@@ -1129,6 +1190,11 @@ int LibWindowmanager::setRenderOrder(const vector<string>& render_order) {
return this->d->setRenderOrder(object);
}
+int LibWindowmanager::getAreaList(ChangeAreaReq* req)
+{
+ return this->d->getAreaList(req);
+}
+
int LibWindowmanager::changeAreaSize(const ChangeAreaReq &req) {
json_object* object = json_object_new_object();
json_object_object_add(object, "save", json_object_new_boolean(req.getSave()));
diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h
index df02c41..2f62752 100644
--- a/src/libwindowmanager.h
+++ b/src/libwindowmanager.h
@@ -78,9 +78,11 @@ class ChangeAreaReq {
void addAreaReq(const std::string& area_name, const Rect& area_size) { this->_area_req[area_name] = area_size; }
void setSaveReq(bool save) { this->_save = save; }
bool getSave() const { return this->_save; }
+ void addAreaList(const std::string& area_name, const Rect& area_size){ this->_area_list[area_name] = area_size; }
const std::unordered_map<std::string, Rect>& getReq() const { return this->_area_req; }
private:
std::unordered_map<std::string, Rect> _area_req;
+ std::unordered_map<std::string, Rect> _area_list;
bool _save;
};
@@ -139,6 +141,7 @@ public:
int endDraw(const char* role);
int setRenderOrder(const std::vector<std::string>& render_order);
struct Screen getScreenInfo();
+ int getAreaList(ChangeAreaReq* req);
int changeAreaSize(const ChangeAreaReq& req);
int getAreaInfo(const char* role, Rect *out_rect);
void setEventHandler(const WMHandler& wmh);