summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-10-22 16:20:48 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-10-22 16:20:48 +0900
commit0d13409db30964eaec8747b7eaf929f193672a0c (patch)
tree9af90225ab84d741ff8142f1f18f10c6c423a780
parent4efe5e5a1de120bbdeef38987861a50829a953a6 (diff)
Add setRenderOrder
Change-Id: I939f051c014358ef9f80dd0556b130a43dd234e9 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/libwindowmanager.cpp90
-rw-r--r--src/libwindowmanager.h1
2 files changed, 82 insertions, 9 deletions
diff --git a/src/libwindowmanager.cpp b/src/libwindowmanager.cpp
index db5afc1..e03f638 100644
--- a/src/libwindowmanager.cpp
+++ b/src/libwindowmanager.cpp
@@ -33,6 +33,9 @@ extern "C" {
#define UNUSED(x) (void)(x)
+using std::string;
+using std::vector;
+
namespace {
/* Key for json obejct */
static const char g_kKeyDrawingName[] = "drawing_name";
@@ -60,6 +63,7 @@ class LibWindowmanager::Impl {
int activateWindow(json_object *object);
int deactivateWindow(json_object *object);
int endDraw(json_object *object);
+ int setRenderOrder(json_object* object);
int getDisplayInfo(json_object *object);
int getAreaInfo(json_object *in_obj, json_object *out_obj);
@@ -339,15 +343,60 @@ int LibWindowmanager::Impl::requestSurfaceXDG(json_object *object) {
}
int LibWindowmanager::Impl::setRole(json_object *object) {
+ TRACE();
HMI_DEBUG("libwm", "called");
- return this->api_call("setRole", object, [](bool ok, json_object *j) {
- if (!ok) {
- HMI_ERROR("libwm", "API Call setRole() failed: %s",
- j != nullptr ? json_object_to_json_string_ext(
- j, JSON_C_TO_STRING_PRETTY)
- : "no-info");
- }
- });
+
+ json_object *val;
+ const char *tmp_label;
+ if (json_object_object_get_ex(object, g_kKeyDrawingName, &val)) {
+ tmp_label = json_object_get_string(val);
+ }
+ else {
+ HMI_DEBUG("libwm", "Not found key \"%s\"", g_kKeyDrawingName);
+ return -EINVAL;
+ }
+
+ // DrawingName in "object" is overwritten in api_call("RequestSurface")
+ // So it is neccesary to copy it.
+ const char *label = std::string(tmp_label).c_str();
+
+ if (this->labels.find(label) != this->labels.end()) {
+ HMI_ERROR("libwm", "Surface label already known!");
+ return -EINVAL;
+ }
+
+ // Store application name first
+ // because it may not return from setenv
+ HMI_DEBUG("libwm", "Insert application name: %s\n", label);
+ this->labels.insert(this->labels.end(), label);
+
+ int rc = -1;
+ /* send the request */
+ int rc2 =
+ this->api_call("setRole", object, [&rc](bool ok, json_object *j) {
+ if (ok) {
+ json_object *val;
+ if (json_object_object_get_ex(j, g_kKeyResponse, &val)) {
+ rc = json_object_get_int(val);
+ }
+ else {
+ HMI_ERROR("libwm", "Not found key \"response\"");
+ rc = -EINVAL;
+ return;
+ }
+ }
+ });
+
+ if (rc2 < 0) {
+ rc = rc2;
+ }
+
+ if (rc < 0) {
+ HMI_ERROR("libwm", "Erase application name: %s", label);
+ this->labels.erase(label);
+ }
+
+ return rc;
}
int LibWindowmanager::Impl::activateWindow(json_object *object) {
@@ -389,6 +438,19 @@ int LibWindowmanager::Impl::endDraw(json_object *object) {
});
}
+int LibWindowmanager::Impl::setRenderOrder(json_object *object) {
+ TRACE();
+ HMI_DEBUG("libwm", "called");
+ return this->api_call("setRenderOrder", object, [](bool ok, json_object *j) {
+ if (!ok) {
+ HMI_ERROR("libwm", "API Call setRenderOrder() failed: %s",
+ j != nullptr ? json_object_to_json_string_ext(
+ j, JSON_C_TO_STRING_PRETTY)
+ : "no-info");
+ }
+ });
+}
+
int LibWindowmanager::Impl::getDisplayInfo(json_object *object) {
TRACE();
HMI_DEBUG("libwm", "called");
@@ -944,7 +1006,7 @@ int LibWindowmanager::setRole(const char* role, bool request)
{
pid_t pid = getpid(); // need surface rendering process
json_object* object = json_object_new_object();
- json_object_object_add(object, "role", json_object_new_string(role));
+ json_object_object_add(object, g_kKeyDrawingName, json_object_new_string(role));
json_object_object_add(object, "pid", json_object_new_int(pid));
json_object_object_add(object, "request_surface_id", json_object_new_boolean(request));
@@ -1044,6 +1106,16 @@ int LibWindowmanager::getAreaInfo(const char *label, json_object *out_obj) {
return this->d->getAreaInfo(object, out_obj);
}
+int LibWindowmanager::setRenderOrder(const vector<string>& render_order) {
+ json_object* object = json_object_new_object();
+ json_object *array = json_object_new_array();
+ for(const auto& i: render_order) {
+ json_object_array_add(array, json_object_new_string(i.c_str()));
+ }
+ json_object_object_add(object, "render_order", array);
+ return this->d->setRenderOrder(object);
+}
+
void LibWindowmanager::set_event_handler(enum EventType et, handler_fun f) {
return this->d->set_event_handler(et, std::move(f));
}
diff --git a/src/libwindowmanager.h b/src/libwindowmanager.h
index ebcf0e1..d51b89a 100644
--- a/src/libwindowmanager.h
+++ b/src/libwindowmanager.h
@@ -123,6 +123,7 @@ public:
int activateWindow(const char* role);
int deactivateWindow(const char* role);
int endDraw(const char* role);
+ int setRenderOrder(const std::vector<std::string>& render_order);
struct Screen getScreenInfo();
int getAreaInfo(const char* role, Rect *out_rect);
void setEventHandler(const WMHandler& wmh);