summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-08 12:03:50 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-08 12:19:58 +0900
commit25d7a9506643d28929393af5d4c97dffe7570300 (patch)
tree7fdbb3d54ef7e18f46bf07ce586785e31dfcfc8b
parent9b60cab010d68353e4b676f91391739d53a0dedf (diff)
Fix API getArea and syncDraw handler
Change-Id: Ib614f90c68f63977e4c6bdac5962a34cf7ff193a Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/libwindowmanager.cpp36
-rw-r--r--src/libwindowmanager.h2
2 files changed, 24 insertions, 14 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp
index 880e48d..3cab866 100644
--- a/src/libwindowmanager.cpp
+++ b/src/libwindowmanager.cpp
@@ -54,6 +54,7 @@ class LibWindowmanager::Impl {
/* Key for json obejct */
const char *kKeyDrawingName = "drawing_name";
const char *kKeyDrawingArea = "drawing_area";
+ const char *kKeyDrawingRect = "drawing_rect";
// This is the LibWindowmanager interface impl
int init(int port, char const *token);
@@ -144,7 +145,6 @@ void onCall(void *closure, const char *api, const char *verb,
/* called when wsj1 receives an event */
void onEvent(void *closure, const char *event, afb_wsj1_msg *msg) {
TRACE();
-
// check API name in event
if (0 != strncmp(wmAPI, event, strlen(wmAPI))) {
HMI_ERROR("libwm", "Unknown event: %s", event);
@@ -806,14 +806,16 @@ void LibWindowmanager::Impl::event(char const *et, json_object *object) {
if(_on_sync_draw && emit) {
json_object_object_get_ex(object, kKeyDrawingArea, &j_val);
const char* area = json_object_get_string(j_val);
- json_object_object_get_ex(object, "x", &j_val);
- unsigned x = json_object_get_int(j_val);
- json_object_object_get_ex(object, "y", &j_val);
- unsigned y = json_object_get_int(j_val);
- json_object_object_get_ex(object, "width", &j_val);
- unsigned w = json_object_get_int(j_val);
- json_object_object_get_ex(object, "height", &j_val);
- unsigned h = json_object_get_int(j_val);
+ json_object *j_rect;
+ json_object_object_get_ex(object, kKeyDrawingRect, &j_rect);
+ json_object_object_get_ex(j_rect, "x", &j_val);
+ int x = json_object_get_int(j_val);
+ json_object_object_get_ex(j_rect, "y", &j_val);
+ int y = json_object_get_int(j_val);
+ json_object_object_get_ex(j_rect, "width", &j_val);
+ int w = json_object_get_int(j_val);
+ json_object_object_get_ex(j_rect, "height", &j_val);
+ int h = json_object_get_int(j_val);
Rect rect(x, y, w, h);
return _on_sync_draw(role, area, rect);
}
@@ -1025,18 +1027,26 @@ int LibWindowmanager::getAreaInfo(const char *role, Rect *out_rect) {
json_object *out = json_object_new_object();
json_object_object_add(object, this->kKeyDrawingName, json_object_new_string(role));
int ret = this->d->getAreaInfo(object, out);
+
+ out_rect->set_left(0);
+ out_rect->set_top(0);
+ out_rect->set_width(0);
+ out_rect->set_height(0);
+
if(!ret) {
json_object *j_val;
- if (json_object_object_get_ex(object, "x", &j_val)) {
+ json_object *j_rect;
+ json_object_object_get_ex(out, kKeyDrawingRect, &j_rect);
+ if (json_object_object_get_ex(j_rect, "x", &j_val)) {
out_rect->set_left(json_object_get_int(j_val));
}
- if (json_object_object_get_ex(object, "y", &j_val)) {
+ if (json_object_object_get_ex(j_rect, "y", &j_val)) {
out_rect->set_top(json_object_get_int(j_val));
}
- if (json_object_object_get_ex(object, "width", &j_val)) {
+ if (json_object_object_get_ex(j_rect, "width", &j_val)) {
out_rect->set_width(json_object_get_int(j_val));
}
- if (json_object_object_get_ex(object, "height", &j_val)) {
+ if (json_object_object_get_ex(j_rect, "height", &j_val)) {
out_rect->set_height(json_object_get_int(j_val));
}
}
diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h
index 5bfc9c4..10715ce 100644
--- a/src/libwindowmanager.h
+++ b/src/libwindowmanager.h
@@ -62,7 +62,7 @@ public:
using handler_fun = std::function<void(json_object *)>;
using visible_handler = std::function<void(const char*, bool visible)>;
using active_handler = std::function<void(const char*, bool active)>;
- using sync_draw_handler = std::function<void(const char*, const char*, const Rect&)>;
+ using sync_draw_handler = std::function<void(const char*, const char*, Rect)>;
using flush_draw_handler= std::function<void(const char*)>;
using screen_updated_handler = std::function<void(const std::vector<std::string>&)>;
using error_handler = std::function<void(int err, const std::string&)>;