summaryrefslogtreecommitdiffstats
path: root/src/libwindowmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libwindowmanager.cpp')
-rw-r--r--src/libwindowmanager.cpp90
1 files changed, 81 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));
}